mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 17:39:41 +05:00
feat: add button to show collections containing the release on release page
feat: add release in list widget to release page fix: redirecting if viewing not favorites collection for unauthorized user
This commit is contained in:
parent
723b620749
commit
501d3a1705
5 changed files with 117 additions and 61 deletions
|
@ -35,15 +35,22 @@ export function CollectionsFullPage(props: {
|
|||
|
||||
const getKey = (pageIndex: number, previousPageData: any) => {
|
||||
if (previousPageData && !previousPageData.content.length) return null;
|
||||
if (userStore.token) {
|
||||
if (props.type == "favorites") {
|
||||
return `${ENDPOINTS.collection.favoriteCollections}/all/${pageIndex}?token=${userStore.token}`;
|
||||
} else if (props.type == "profile") {
|
||||
return `${ENDPOINTS.collection.userCollections}/${props.profile_id}/${pageIndex}?token=${userStore.token}`;
|
||||
} else if (props.type == "release") {
|
||||
return `${ENDPOINTS.collection.releaseInCollections}/${props.release_id}/${pageIndex}?token=${userStore.token}`;
|
||||
}
|
||||
|
||||
let url;
|
||||
|
||||
if (props.type == "favorites") {
|
||||
url = `${ENDPOINTS.collection.favoriteCollections}/all/${pageIndex}`;
|
||||
} else if (props.type == "profile") {
|
||||
url = `${ENDPOINTS.collection.userCollections}/${props.profile_id}/${pageIndex}`;
|
||||
} else if (props.type == "release") {
|
||||
url = `${ENDPOINTS.collection.releaseInCollections}/${props.release_id}/${pageIndex}`;
|
||||
}
|
||||
|
||||
if (userStore.token) {
|
||||
url += `?token=${userStore.token}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
const { data, error, isLoading, size, setSize } = useSWRInfinite(
|
||||
|
@ -72,7 +79,11 @@ export function CollectionsFullPage(props: {
|
|||
}, [scrollPosition]);
|
||||
|
||||
useEffect(() => {
|
||||
if (userStore.state === "finished" && !userStore.token) {
|
||||
if (
|
||||
userStore.state === "finished" &&
|
||||
!userStore.token &&
|
||||
props.type == "favorites"
|
||||
) {
|
||||
router.push(`/login?redirect=/collections/favorites`);
|
||||
}
|
||||
}, [userStore.state, userStore.token]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue