mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
synchronous events, updating title works fully
This commit is contained in:
@@ -29,6 +29,7 @@ import RunScriptButtonsWidget from "../widgets/run_script_buttons.js";
|
||||
import ProtectedNoteSwitchWidget from "../widgets/protected_note_switch.js";
|
||||
import NoteTypeWidget from "../widgets/note_type.js";
|
||||
import NoteActionsWidget from "../widgets/note_actions.js";
|
||||
import protectedSessionHolder from "./protected_session_holder.js";
|
||||
|
||||
class AppContext {
|
||||
constructor() {
|
||||
@@ -116,23 +117,23 @@ class AppContext {
|
||||
];
|
||||
}
|
||||
|
||||
trigger(name, data) {
|
||||
trigger(name, data, sync = false) {
|
||||
this.eventReceived(name, data);
|
||||
|
||||
for (const tabContext of this.tabContexts) {
|
||||
tabContext.eventReceived(name, data);
|
||||
tabContext.eventReceived(name, data, sync);
|
||||
}
|
||||
|
||||
for (const widget of this.widgets) {
|
||||
widget.eventReceived(name, data);
|
||||
widget.eventReceived(name, data, sync);
|
||||
}
|
||||
}
|
||||
|
||||
eventReceived(name, data) {
|
||||
async eventReceived(name, data, sync) {
|
||||
const fun = this[name + 'Listener'];
|
||||
|
||||
if (typeof fun === 'function') {
|
||||
fun.call(this, data);
|
||||
await fun.call(this, data, sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,6 +348,18 @@ class AppContext {
|
||||
tabReorderListener() {
|
||||
this.openTabsChanged();
|
||||
}
|
||||
|
||||
noteChangesSavedListener() {
|
||||
const activeTabContext = this.getActiveTabContext();
|
||||
|
||||
if (!activeTabContext || !activeTabContext.note) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeTabContext.note.isProtected && protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
protectedSessionHolder.touchProtectedSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const appContext = new AppContext();
|
||||
|
||||
Reference in New Issue
Block a user