mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
treecache now manages reloading when starting protected session
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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}) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -59,4 +59,8 @@ export default class TabAwareWidget extends BasicWidget {
|
||||
|
||||
this.activeTabChanged();
|
||||
}
|
||||
|
||||
treeCacheReloadedListener() {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,9 @@ export default class CodeTypeWidget extends TypeWidget {
|
||||
|
||||
cleanup() {
|
||||
if (this.codeEditor) {
|
||||
this.codeEditor.setValue('');
|
||||
this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||
this.codeEditor.setValue('');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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+\)/;
|
||||
|
||||
|
||||
@@ -174,7 +174,9 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
|
||||
cleanup() {
|
||||
if (this.textEditor) {
|
||||
this.textEditor.setData('');
|
||||
this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||
this.textEditor.setData('');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user