Fixes note db state issue

This commit is contained in:
Mo Bitar
2020-03-20 23:40:23 -05:00
parent 0ef1ce8ef1
commit d76e03c70f
6 changed files with 125 additions and 85 deletions

View File

@@ -16,6 +16,7 @@ export class PureCtrl extends ApplicationService {
this.$timeout = $timeout; this.$timeout = $timeout;
this.appState = appState; this.appState = appState;
this.props = {}; this.props = {};
this.state = {};
/* Allow caller constructor to finish setting instance variables */ /* Allow caller constructor to finish setting instance variables */
setImmediate(() => { setImmediate(() => {
this.state = this.getInitialState(); this.state = this.getInitialState();

View File

@@ -31,10 +31,6 @@ class FooterCtrl extends PureCtrl {
this.nativeExtManager = nativeExtManager; this.nativeExtManager = nativeExtManager;
this.statusManager = statusManager; this.statusManager = statusManager;
this.godService = godService; this.godService = godService;
this.state = {
hasPasscode: false
};
this.rooms = []; this.rooms = [];
this.themesWithIcons = []; this.themesWithIcons = [];
this.showSyncResolution = false; this.showSyncResolution = false;
@@ -46,6 +42,12 @@ class FooterCtrl extends PureCtrl {
}); });
} }
getInitialState() {
return {
hasPasscode: false
};
}
reloadUpgradeStatus() { reloadUpgradeStatus() {
this.godService.checkForSecurityUpdate().then((available) => { this.godService.checkForSecurityUpdate().then((available) => {
this.setState({ this.setState({

View File

@@ -48,8 +48,27 @@ class NotesCtrl extends PureCtrl {
this.desktopManager = desktopManager; this.desktopManager = desktopManager;
this.keyboardManager = keyboardManager; this.keyboardManager = keyboardManager;
this.preferencesManager = preferencesManager; this.preferencesManager = preferencesManager;
this.resetPagination();
this.registerKeyboardShortcuts();
}
this.state = { $onInit() {
super.$onInit();
angular.element(document).ready(() => {
this.reloadPreferences();
});
this.panelPuppet = {
onReady: () => this.reloadPreferences()
};
window.onresize = (event) => {
this.resetPagination({
keepCurrentIfLarger: true
});
};
}
getInitialState() {
return {
notes: [], notes: [],
renderedNotes: [], renderedNotes: [],
selectedNote: null, selectedNote: null,
@@ -62,22 +81,8 @@ class NotesCtrl extends PureCtrl {
mutable: { showMenu: false }, mutable: { showMenu: false },
noteFilter: { text: '' }, noteFilter: { text: '' },
}; };
this.panelPuppet = {
onReady: () => this.reloadPreferences()
};
window.onresize = (event) => {
this.resetPagination({
keepCurrentIfLarger: true
});
};
this.resetPagination();
this.registerKeyboardShortcuts();
angular.element(document).ready(() => {
this.reloadPreferences();
});
} }
onAppLaunch() { onAppLaunch() {
super.onAppLaunch(); super.onAppLaunch();
this.streamNotesAndTags(); this.streamNotesAndTags();
@@ -155,24 +160,27 @@ class NotesCtrl extends PureCtrl {
if (this.state.selectedNote && this.state.selectedNote.dummy) { if (this.state.selectedNote && this.state.selectedNote.dummy) {
this.application.deleteItemLocally({ item: this.state.selectedNote }); this.application.deleteItemLocally({ item: this.state.selectedNote });
if (previousTag) { if (previousTag) {
_.remove(previousTag.notes, this.state.selectedNote); _.pull(previousTag.notes, this.state.selectedNote);
} }
await this.selectNote(null); await this.selectNote(null);
} }
await this.setState({ await this.setState({
tag: tag tag: tag
}); });
this.resetScrollPosition(); this.resetScrollPosition();
this.setShowMenuFalse(); this.setShowMenuFalse();
await this.setNoteFilterText(''); await this.setNoteFilterText('');
this.desktopManager.searchText(); this.desktopManager.searchText();
this.resetPagination(); this.resetPagination();
/* Capture db load state before beginning reloadNotes, since this status may change during reload */
const dbLoaded = this.application.isDatabaseLoaded();
await this.reloadNotes(); await this.reloadNotes();
if (this.state.notes.length > 0) { if (this.state.notes.length > 0) {
this.selectFirstNote(); this.selectFirstNote();
} else if (this.application.isDatabaseLoaded()) { } else if (dbLoaded) {
if (!tag.isSmartTag() || tag.content.isAllTag) { if (!tag.isSmartTag() || tag.content.isAllTag) {
this.createNewNote(); this.createNewNote();
} else if ( } else if (
@@ -431,7 +439,7 @@ class NotesCtrl extends PureCtrl {
}); });
} }
if (note.errorDecrypting) { if (note.errorDecrypting) {
if(note.waitingForKeys) { if (note.waitingForKeys) {
flags.push({ flags.push({
text: "Waiting For Keys", text: "Waiting For Keys",
class: 'info' class: 'info'

View File

@@ -22,12 +22,16 @@ class TagsPanelCtrl extends PureCtrl {
this.panelPuppet = { this.panelPuppet = {
onReady: () => this.loadPreferences() onReady: () => this.loadPreferences()
}; };
this.state = { }
getInitialState() {
return {
tags: [], tags: [],
smartTags: [], smartTags: [],
noteCounts: {}, noteCounts: {},
}; };
} }
onAppStart() { onAppStart() {
super.onAppStart(); super.onAppStart();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long