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