fix: don't show empty notes view when the database is loading
This commit is contained in:
@@ -94,7 +94,9 @@
|
|||||||
faded="self.state.hideDate"
|
faded="self.state.hideDate"
|
||||||
label="'Date'"
|
label="'Date'"
|
||||||
)
|
)
|
||||||
p.empty-notes-list.faded(ng-if="!self.state.renderedNotes.length") No notes.
|
p.empty-notes-list.faded(
|
||||||
|
ng-if="self.state.localDataLoaded && !self.state.renderedNotes.length"
|
||||||
|
) No notes.
|
||||||
.scrollable(ng-if="self.state.renderedNotes.length")
|
.scrollable(ng-if="self.state.renderedNotes.length")
|
||||||
#notes-scrollable.infinite-scroll(
|
#notes-scrollable.infinite-scroll(
|
||||||
can-load='true',
|
can-load='true',
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import { UuidString } from '@node_modules/snjs/dist/@types/types';
|
|||||||
type NotesState = {
|
type NotesState = {
|
||||||
panelTitle: string
|
panelTitle: string
|
||||||
notes?: SNNote[]
|
notes?: SNNote[]
|
||||||
renderedNotes?: SNNote[]
|
renderedNotes: SNNote[]
|
||||||
sortBy?: string
|
sortBy?: string
|
||||||
sortReverse?: boolean
|
sortReverse?: boolean
|
||||||
showArchived?: boolean
|
showArchived?: boolean
|
||||||
@@ -37,6 +37,14 @@ type NotesState = {
|
|||||||
hideDate?: boolean
|
hideDate?: boolean
|
||||||
noteFilter: { text: string }
|
noteFilter: { text: string }
|
||||||
mutable: { showMenu: boolean }
|
mutable: { showMenu: boolean }
|
||||||
|
localDataLoaded: boolean
|
||||||
|
[WebPrefKey.TagsPanelWidth]?: number
|
||||||
|
[WebPrefKey.NotesPanelWidth]?: number
|
||||||
|
[WebPrefKey.EditorWidth]?: number
|
||||||
|
[WebPrefKey.EditorLeft]?: number
|
||||||
|
[WebPrefKey.EditorMonospaceEnabled]?: boolean
|
||||||
|
[WebPrefKey.EditorSpellcheck]?: boolean
|
||||||
|
[WebPrefKey.EditorResizersEnabled]?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type NoteFlag = {
|
type NoteFlag = {
|
||||||
@@ -53,7 +61,7 @@ const DEFAULT_LIST_NUM_NOTES = 20;
|
|||||||
const ELEMENT_ID_SEARCH_BAR = 'search-bar';
|
const ELEMENT_ID_SEARCH_BAR = 'search-bar';
|
||||||
const ELEMENT_ID_SCROLL_CONTAINER = 'notes-scrollable';
|
const ELEMENT_ID_SCROLL_CONTAINER = 'notes-scrollable';
|
||||||
|
|
||||||
class NotesViewCtrl extends PureViewCtrl {
|
class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
|
||||||
|
|
||||||
private panelPuppet?: PanelPuppet
|
private panelPuppet?: PanelPuppet
|
||||||
private reloadNotesPromise?: any
|
private reloadNotesPromise?: any
|
||||||
@@ -116,13 +124,15 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
return this.setState(state);
|
return this.setState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState(): NotesState {
|
||||||
return {
|
return {
|
||||||
notes: [],
|
notes: [],
|
||||||
renderedNotes: [],
|
renderedNotes: [],
|
||||||
mutable: { showMenu: false },
|
mutable: { showMenu: false },
|
||||||
noteFilter: { text: '' },
|
noteFilter: { text: '' },
|
||||||
} as Partial<NotesState>;
|
panelTitle: '',
|
||||||
|
localDataLoaded: false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async onAppLaunch() {
|
async onAppLaunch() {
|
||||||
@@ -157,15 +167,23 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
async onAppEvent(eventName: ApplicationEvent) {
|
async onAppEvent(eventName: ApplicationEvent) {
|
||||||
if (eventName === ApplicationEvent.SignedIn) {
|
switch (eventName) {
|
||||||
this.appState.closeAllEditors();
|
case ApplicationEvent.SignedIn:
|
||||||
this.selectFirstNote();
|
this.appState.closeAllEditors();
|
||||||
} else if (eventName === ApplicationEvent.CompletedFullSync) {
|
this.selectFirstNote();
|
||||||
this.getMostValidNotes().then((notes) => {
|
break;
|
||||||
if (notes.length === 0) {
|
case ApplicationEvent.CompletedFullSync:
|
||||||
this.createPlaceholderNote();
|
this.getMostValidNotes().then((notes) => {
|
||||||
}
|
if (notes.length === 0) {
|
||||||
});
|
this.createPlaceholderNote();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case ApplicationEvent.LocalDataLoaded:
|
||||||
|
this.setState({
|
||||||
|
localDataLoaded: true,
|
||||||
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user