refactor: replace isLoading with isSuccess
This commit is contained in:
Vendored
+1
@@ -34,6 +34,7 @@
|
||||
"boardos",
|
||||
"btns",
|
||||
"favs",
|
||||
"localforage",
|
||||
"localstorage",
|
||||
"magiclink",
|
||||
"navs",
|
||||
|
||||
@@ -23,7 +23,7 @@ export const onMessageSendStarted = async (
|
||||
if (type == "archive") return;
|
||||
// id: who send to ,from_uid: who sent
|
||||
// console.log("handlers data", content, type, properties, ignoreLocal, id);
|
||||
const isMedia = ["image", "video", "audio"].includes(properties.content_type.split('/')[0]);
|
||||
const isMedia = properties.content_type ? ["image", "video", "audio"].includes(properties.content_type.split('/')[0]) : false;
|
||||
// const isImage = properties.content_type?.startsWith("image");
|
||||
const ts = properties.local_id || +new Date();
|
||||
const tmpMsg = {
|
||||
|
||||
@@ -28,11 +28,9 @@ export const userApi = createApi({
|
||||
});
|
||||
},
|
||||
async onQueryStarted(data, { dispatch, queryFulfilled }) {
|
||||
// const local_uid = Number(localStorage.getItem(KEY_UID));
|
||||
try {
|
||||
const { data: users } = await queryFulfilled;
|
||||
dispatch(fillUsers(users));
|
||||
// }
|
||||
} catch {
|
||||
console.log("get user list error");
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@ const RequireAuth: FC<Props> = ({ children, redirectTo = "/login" }) => {
|
||||
const location = useLocation();
|
||||
const matchs = matchRoutes(GuestAllows, location);
|
||||
const allowGuest = matchs ? !!matchs[0].pathname : false;
|
||||
const { data: loginConfig, isLoading: fetchingLoginConfig } = useGetLoginConfigQuery();
|
||||
const { isLoading: checkingInitial } = useGetInitializedQuery();
|
||||
const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery();
|
||||
const { isSuccess: checkInitialSuccess } = useGetInitializedQuery();
|
||||
const { token, guest, initialized } = useAppSelector((store) => store.authData);
|
||||
// console.log("auth route", { checkInitialSuccess, loginConfigSuccess, initialized, guest: loginConfig?.guest, token, allowGuest, guest });
|
||||
|
||||
// 初始化和login配置检查
|
||||
if (checkingInitial || fetchingLoginConfig) return null;
|
||||
if (!checkInitialSuccess || !loginConfigSuccess) return null;
|
||||
// 未初始化 则先走setup 流程
|
||||
if (!initialized) return <Navigate to={`/onboarding`} replace />;
|
||||
// 开启guest 并且没token 而且是允许guest访问的路由 则先去过渡页登录
|
||||
|
||||
@@ -36,8 +36,8 @@ function HomePage() {
|
||||
guest: store.authData.guest
|
||||
};
|
||||
});
|
||||
const { loading } = usePreload();
|
||||
if (loading || !ready) {
|
||||
const { success } = usePreload();
|
||||
if (!success || !ready) {
|
||||
return <Loading reload={true} fullscreen={true} />;
|
||||
}
|
||||
const isSettingPage = pathname.startsWith("/setting");
|
||||
|
||||
Reference in New Issue
Block a user