mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-07 23:18:38 +08:00
fix: 登录后头像不更新 — 将 getUserInfo 合并进 login()
登录流程之前分两步:login() 只设 isLoggedIn,getUserInfo/setProfile 由 LoginModal 调用。网络抖动或 B站 session 传播延迟时 getUserInfo 抛错被静默吞掉,face 不更新,直到下次启动 restore() 才修复。 修复:login() 内部完成 getUserInfo + 持久化,LoginModal 只需 await login() 后关闭弹窗,不再重复获取头像。
This commit is contained in:
@@ -14,7 +14,7 @@ import * as FileSystem from "expo-file-system/legacy";
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
import QRCode from "react-native-qrcode-svg";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { generateQRCode, pollQRCode, getUserInfo } from "../services/bilibili";
|
||||
import { generateQRCode, pollQRCode } from "../services/bilibili";
|
||||
import { useAuthStore } from "../store/authStore";
|
||||
import { useTheme } from "../utils/theme";
|
||||
|
||||
@@ -33,7 +33,6 @@ export function LoginModal({ visible, onClose }: Props) {
|
||||
>("loading");
|
||||
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
const login = useAuthStore((s) => s.login);
|
||||
const setProfile = useAuthStore((s) => s.setProfile);
|
||||
const theme = useTheme();
|
||||
|
||||
// sheet 滑入动画
|
||||
@@ -86,14 +85,11 @@ export function LoginModal({ visible, onClose }: Props) {
|
||||
clearInterval(pollRef.current!);
|
||||
try {
|
||||
await login(result.cookie, "", "");
|
||||
if (cancelled) return;
|
||||
setStatus("done");
|
||||
const info = await getUserInfo();
|
||||
if (!cancelled) setProfile(info.face, info.uname, String(info.mid));
|
||||
} catch {
|
||||
if (!cancelled) setStatus("error");
|
||||
return;
|
||||
}
|
||||
onClose();
|
||||
if (!cancelled) onClose();
|
||||
}
|
||||
} catch {
|
||||
// Network error during poll — ignore, will retry next interval
|
||||
|
||||
Reference in New Issue
Block a user