refactor: remove get server from preload
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
import { AuthData, RenewTokenResponse } from "@/types/auth";
|
import { AuthData, RenewTokenResponse } from "@/types/auth";
|
||||||
// import { isNull, omitBy } from "lodash";
|
|
||||||
import {
|
import {
|
||||||
KEY_EXPIRE,
|
KEY_EXPIRE,
|
||||||
KEY_LOGIN_USER,
|
KEY_LOGIN_USER,
|
||||||
@@ -12,8 +11,6 @@ import {
|
|||||||
} from "../config";
|
} from "../config";
|
||||||
import { StoredUser } from "./users";
|
import { StoredUser } from "./users";
|
||||||
|
|
||||||
// import { updateUsersByLogs } from './users';
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
initialized: boolean;
|
initialized: boolean;
|
||||||
guest: boolean;
|
guest: boolean;
|
||||||
@@ -71,7 +68,6 @@ const authDataSlice = createSlice({
|
|||||||
},
|
},
|
||||||
updateLoginUser(state, { payload }: PayloadAction<Partial<StoredUser>>) {
|
updateLoginUser(state, { payload }: PayloadAction<Partial<StoredUser>>) {
|
||||||
if (!state.user) return;
|
if (!state.user) return;
|
||||||
|
|
||||||
const obj = { ...state.user, ...payload };
|
const obj = { ...state.user, ...payload };
|
||||||
Object.keys(obj).forEach((key) => {
|
Object.keys(obj).forEach((key) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -80,7 +76,6 @@ const authDataSlice = createSlice({
|
|||||||
delete obj[key];
|
delete obj[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("upppp", obj);
|
|
||||||
state.user = obj;
|
state.user = obj;
|
||||||
localStorage.setItem(KEY_LOGIN_USER, JSON.stringify(obj));
|
localStorage.setItem(KEY_LOGIN_USER, JSON.stringify(obj));
|
||||||
},
|
},
|
||||||
@@ -94,7 +89,6 @@ const authDataSlice = createSlice({
|
|||||||
localStorage.removeItem(KEY_REFRESH_TOKEN);
|
localStorage.removeItem(KEY_REFRESH_TOKEN);
|
||||||
localStorage.removeItem(KEY_UID);
|
localStorage.removeItem(KEY_UID);
|
||||||
localStorage.removeItem(KEY_PWA_INSTALLED);
|
localStorage.removeItem(KEY_PWA_INSTALLED);
|
||||||
|
|
||||||
return emptyState;
|
return emptyState;
|
||||||
},
|
},
|
||||||
updateInitialized(state, action: PayloadAction<boolean>) {
|
updateInitialized(state, action: PayloadAction<boolean>) {
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { Helmet } from "react-helmet";
|
import { Helmet } from "react-helmet";
|
||||||
import { useAppSelector } from "@/app/store";
|
import { useAppSelector } from "@/app/store";
|
||||||
|
import { useGetServerQuery } from "@/app/services/server";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
const Meta: FC<Props> = () => {
|
const Meta: FC<Props> = () => {
|
||||||
|
useGetServerQuery();
|
||||||
const { name, logo } = useAppSelector((store) => store.server);
|
const { name, logo } = useAppSelector((store) => store.server);
|
||||||
return (
|
return (
|
||||||
<Helmet>
|
<Helmet>
|
||||||
|
|||||||
+5
-19
@@ -3,11 +3,7 @@ import dayjs from "dayjs";
|
|||||||
|
|
||||||
import initCache, { useRehydrate } from "@/app/cache";
|
import initCache, { useRehydrate } from "@/app/cache";
|
||||||
import { useLazyGetFavoritesQuery, useLazyLoadMoreMessagesQuery } from "@/app/services/message";
|
import { useLazyGetFavoritesQuery, useLazyLoadMoreMessagesQuery } from "@/app/services/message";
|
||||||
import {
|
import { useLazyGetServerVersionQuery, useLazyGetSystemCommonQuery } from "@/app/services/server";
|
||||||
useLazyGetServerQuery,
|
|
||||||
useLazyGetServerVersionQuery,
|
|
||||||
useLazyGetSystemCommonQuery
|
|
||||||
} from "@/app/services/server";
|
|
||||||
import { useLazyGetContactsQuery, useLazyGetUsersQuery } from "@/app/services/user";
|
import { useLazyGetContactsQuery, useLazyGetUsersQuery } from "@/app/services/user";
|
||||||
import { useAppSelector } from "@/app/store";
|
import { useAppSelector } from "@/app/store";
|
||||||
import useLicense from "./useLicense";
|
import useLicense from "./useLicense";
|
||||||
@@ -63,10 +59,7 @@ export default function usePreload() {
|
|||||||
data: contacts
|
data: contacts
|
||||||
}
|
}
|
||||||
] = useLazyGetContactsQuery();
|
] = useLazyGetContactsQuery();
|
||||||
const [
|
|
||||||
getServer,
|
|
||||||
{ isLoading: serverLoading, isSuccess: serverSuccess, isError: serverError, data: server }
|
|
||||||
] = useLazyGetServerQuery();
|
|
||||||
const [
|
const [
|
||||||
getServerVersion,
|
getServerVersion,
|
||||||
{ data: serverVersion, isSuccess: serverVersionSuccess, isLoading: loadingServerVersion }
|
{ data: serverVersion, isSuccess: serverVersionSuccess, isLoading: loadingServerVersion }
|
||||||
@@ -100,7 +93,6 @@ export default function usePreload() {
|
|||||||
getContacts();
|
getContacts();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getServer();
|
|
||||||
getFavorites();
|
getFavorites();
|
||||||
getSystemCommon();
|
getSystemCommon();
|
||||||
}
|
}
|
||||||
@@ -114,17 +106,11 @@ export default function usePreload() {
|
|||||||
}, [canStreaming]);
|
}, [canStreaming]);
|
||||||
return {
|
return {
|
||||||
loading:
|
loading:
|
||||||
usersLoading ||
|
usersLoading || favoritesLoading || !rehydrated || loadingLicense || loadingServerVersion,
|
||||||
serverLoading ||
|
error: usersError && favoritesError,
|
||||||
favoritesLoading ||
|
success: usersSuccess && favoritesSuccess && serverVersionSuccess,
|
||||||
!rehydrated ||
|
|
||||||
loadingLicense ||
|
|
||||||
loadingServerVersion,
|
|
||||||
error: usersError && serverError && favoritesError,
|
|
||||||
success: usersSuccess && serverSuccess && favoritesSuccess && serverVersionSuccess,
|
|
||||||
data: {
|
data: {
|
||||||
users: enableContacts ? contacts : users,
|
users: enableContacts ? contacts : users,
|
||||||
server,
|
|
||||||
favorites
|
favorites
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user