treecache now manages reloading when starting protected session

This commit is contained in:
zadam
2020-02-01 22:29:32 +01:00
parent 513ce1a183
commit 0054a32dc7
17 changed files with 76 additions and 75 deletions

View File

@@ -214,10 +214,6 @@ export default class NoteDetailWidget extends TabAwareWidget {
this.refresh();
}
protectedSessionStartedListener() {
this.refresh();
}
async entitiesReloadedListener({loadResults}) {
// we should test what happens when the loaded note is deleted

View File

@@ -4,7 +4,6 @@ import protectedSessionHolder from "../services/protected_session_holder.js";
import treeCache from "../services/tree_cache.js";
import server from "../services/server.js";
import SpacedUpdate from "../services/spaced_update.js";
import appContext from "../services/app_context.js";
const TPL = `
<div class="note-title-container">
@@ -75,9 +74,7 @@ export default class NoteTitleWidget extends TabAwareWidget {
async refreshWithNote(note) {
this.$noteTitle.val(note.title);
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
this.$noteTitle.prop("readonly", true);
}
this.$noteTitle.prop("readonly", note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable());
}
async beforeNoteSwitchListener({tabId}) {

View File

@@ -61,7 +61,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
});
treeService.loadTreeData().then(treeData => this.initFancyTree($tree, treeData));
treeBuilder.prepareTree().then(treeData => this.initFancyTree($tree, treeData));
return $widget;
}
@@ -577,8 +577,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
await server.put('branches/' + branchId + '/expanded/' + expandedNum);
}
async reloadTreeListener() {
const notes = await treeService.loadTreeData();
async reloadTreeFromCache() {
const notes = await treeBuilder.prepareTree();
const activeNode = this.getActiveNode();
@@ -594,10 +594,10 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
hoistedNoteChangedListener() {
this.reloadTreeListener();
this.reloadTreeFromCache();
}
protectedSessionStartedListener() {
this.reloadTreeListener();
treeCacheReloadedListener() {
this.reloadTreeFromCache();
}
}

View File

@@ -59,4 +59,8 @@ export default class TabAwareWidget extends BasicWidget {
this.activeTabChanged();
}
treeCacheReloadedListener() {
this.refresh();
}
}

View File

@@ -582,8 +582,8 @@ export default class TabRowWidget extends BasicWidget {
if (currentIndex !== destinationIndex) {
this.animateTabMove(tabEl, currentIndex, destinationIndex);
}
})
})
});
});
}
animateTabMove(tabEl, originIndex, destinationIndex) {
@@ -619,7 +619,7 @@ export default class TabRowWidget extends BasicWidget {
array.forEach((v, i) => {
if (Math.abs(value - v) < closest) {
closest = Math.abs(value - v);
closestIndex = i
closestIndex = i;
}
});
@@ -662,7 +662,11 @@ export default class TabRowWidget extends BasicWidget {
}
}
protectedSessionStartedListener() {
// FIXME
treeCacheReloadedListener() {
for (const tabContext of this.appContext.getTabContexts()) {
const $tab = this.getTabById(tabContext.tabId);
this.updateTab($tab, tabContext.note);
}
}
}

View File

@@ -129,7 +129,9 @@ export default class CodeTypeWidget extends TypeWidget {
cleanup() {
if (this.codeEditor) {
this.codeEditor.setValue('');
this.spacedUpdate.allowUpdateWithoutChange(() => {
this.codeEditor.setValue('');
});
}
}

View File

@@ -576,10 +576,6 @@ export default class RelationMapTypeWidget extends TypeWidget {
});
}
async refresh() {
await this.loadNotesAndRelations();
}
getZoom() {
const matrixRegex = /matrix\((-?\d*\.?\d+),\s*0,\s*0,\s*-?\d*\.?\d+,\s*-?\d*\.?\d+,\s*-?\d*\.?\d+\)/;

View File

@@ -174,7 +174,9 @@ export default class TextTypeWidget extends TypeWidget {
cleanup() {
if (this.textEditor) {
this.textEditor.setData('');
this.spacedUpdate.allowUpdateWithoutChange(() => {
this.textEditor.setData('');
});
}
}