fix: Reduce flashing of loaders in sidebar on first load

This commit is contained in:
Tom Moor
2024-06-12 21:08:37 -04:00
parent b907d1887a
commit 4ef3615516
2 changed files with 20 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ import { light as defaultTheme } from "@shared/styles/theme";
import Storage from "@shared/utils/Storage";
import Document from "~/models/Document";
import type { ConnectionStatus } from "~/scenes/Document/components/MultiplayerEditor";
import type RootStore from "./RootStore";
const UI_STORE = "UI_STORE";
@@ -82,7 +83,11 @@ class UiStore {
@observable
multiplayerErrorCode?: number;
constructor() {
rootStore: RootStore;
constructor(rootStore: RootStore) {
this.rootStore = rootStore;
// Rehydrate
const data: PersistedData = Storage.get(UI_STORE) || {};
this.languagePromptDismissed = data.languagePromptDismissed;
@@ -270,6 +275,14 @@ class UiStore {
this.mobileSidebarVisible = false;
};
@computed
get readyToShow() {
return (
!this.rootStore.auth.user ||
(this.rootStore.collections.isLoaded && this.rootStore.documents.isLoaded)
);
}
/**
* Returns the current state of the sidebar taking into account user preference
* and whether the sidebar has been hidden as part of launching in a new