为多个组件和API添加用户登录状态检查,确保只有在用户登录后才能查询和修改收藏状态
This commit is contained in:
@@ -5,6 +5,7 @@ import { IconSymbol, IconSymbolName } from "@/components/ui/icon-symbol";
|
||||
import { Colors } from "@/constants/theme";
|
||||
import { useTheme } from "@/context/ThemeContext";
|
||||
import { fetchFavorites, removeFavorite } from "@/lib/api";
|
||||
import { storage } from "@/lib/storage";
|
||||
import { FavoriteItem, Match } from "@/types/api";
|
||||
import { Image } from "expo-image";
|
||||
import { useRouter } from "expo-router";
|
||||
@@ -67,6 +68,13 @@ export default function FavoriteScreen() {
|
||||
if (loading) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const token = await storage.getAccessToken();
|
||||
if (!token) {
|
||||
setFavorites([]);
|
||||
setHasMore(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const currentPage = isRefresh ? 1 : page;
|
||||
const res = await fetchFavorites(activeTab, currentPage);
|
||||
if (isRefresh) {
|
||||
|
||||
Reference in New Issue
Block a user