mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-20 22:07:15 +00:00
chore: fix initial state
This commit is contained in:
parent
769b474bdc
commit
e0e4a1af8f
@ -13,7 +13,9 @@ function App() {
|
|||||||
// Redirect to sign up page if no instance owner.
|
// Redirect to sign up page if no instance owner.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!workspaceStore.profile.owner) {
|
if (!workspaceStore.profile.owner) {
|
||||||
navigateTo("/auth/signup");
|
navigateTo("/auth/signup", {
|
||||||
|
replace: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [workspaceStore.profile]);
|
}, [workspaceStore.profile]);
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@ const CommonContextProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
await Promise.all([workspaceStore.fetchWorkspaceProfile(), workspaceStore.fetchWorkspaceSetting(), userStore.fetchCurrentUser()]);
|
await workspaceStore.fetchWorkspaceProfile();
|
||||||
|
await workspaceStore.fetchWorkspaceSetting();
|
||||||
|
await userStore.fetchCurrentUser();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,17 @@ interface WorkspaceState {
|
|||||||
fetchWorkspaceSetting: () => Promise<WorkspaceSetting>;
|
fetchWorkspaceSetting: () => Promise<WorkspaceSetting>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useWorkspaceStore = create<WorkspaceState>()((set) => ({
|
const useWorkspaceStore = create<WorkspaceState>()((set, get) => ({
|
||||||
profile: WorkspaceProfile.fromPartial({}),
|
profile: WorkspaceProfile.fromPartial({}),
|
||||||
setting: WorkspaceSetting.fromPartial({}),
|
setting: WorkspaceSetting.fromPartial({}),
|
||||||
fetchWorkspaceProfile: async () => {
|
fetchWorkspaceProfile: async () => {
|
||||||
const workspaceProfile = (await workspaceServiceClient.getWorkspaceProfile({})).profile as WorkspaceProfile;
|
const workspaceProfile = (await workspaceServiceClient.getWorkspaceProfile({})).profile as WorkspaceProfile;
|
||||||
set({ profile: workspaceProfile });
|
set({ ...get(), profile: workspaceProfile });
|
||||||
return workspaceProfile;
|
return workspaceProfile;
|
||||||
},
|
},
|
||||||
fetchWorkspaceSetting: async () => {
|
fetchWorkspaceSetting: async () => {
|
||||||
const workspaceSetting = (await workspaceServiceClient.getWorkspaceSetting({})).setting as WorkspaceSetting;
|
const workspaceSetting = (await workspaceServiceClient.getWorkspaceSetting({})).setting as WorkspaceSetting;
|
||||||
set({ setting: workspaceSetting });
|
set({ ...get(), setting: workspaceSetting });
|
||||||
return workspaceSetting;
|
return workspaceSetting;
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user