moved tab related stuff to tab manager from app context

This commit is contained in:
zadam
2020-02-07 21:08:55 +01:00
parent 6d912c4897
commit 14d6372bd8
29 changed files with 331 additions and 332 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ export default class CalendarWidget extends CollapsibleWidget {
const note = await dateNoteService.getDateNote(date);
if (note) {
appContext.getActiveTabContext().setNote(note.noteId);
appContext.tabManager.getActiveTabContext().setNote(note.noteId);
}
else {
alert("Cannot find day note");
@@ -54,7 +54,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
this.$widget.on("dragleave", e => e.preventDefault());
this.$widget.on("drop", async e => {
const activeNote = this.appContext.getActiveTabNote();
const activeNote = this.appContext.tabManager.getActiveTabNote();
if (!activeNote) {
return;
+5 -5
View File
@@ -89,7 +89,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
else if (event.ctrlKey) {
const tabContext = appContext.openEmptyTab();
treeService.getNotePath(node).then(notePath => tabContext.setNote(notePath));
appContext.activateTab(tabContext.tabId);
appContext.tabManager.activateTab(tabContext.tabId);
}
else {
node.setActive();
@@ -106,7 +106,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
const notePath = await treeService.getNotePath(data.node);
const activeTabContext = this.appContext.getActiveTabContext();
const activeTabContext = this.appContext.tabManager.getActiveTabContext();
await activeTabContext.setNote(notePath);
},
expand: (event, data) => this.setExpandedToServer(data.node.data.branchId, true),
@@ -286,7 +286,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
async scrollToActiveNoteListener() {
const activeContext = appContext.getActiveTabContext();
const activeContext = appContext.tabManager.getActiveTabContext();
if (activeContext && activeContext.notePath) {
this.tree.setFocus();
@@ -466,7 +466,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
const notePath = await treeService.getNotePath(newActive);
appContext.getActiveTabContext().setNote(notePath);
appContext.tabManager.getActiveTabContext().setNote(notePath);
}
node.remove();
@@ -526,7 +526,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
}
const activateNotePath = appContext.getActiveTabNotePath();
const activateNotePath = appContext.tabManager.getActiveTabNotePath();
if (activateNotePath) {
const node = await this.getNodeFromPath(activateNotePath);
+1 -1
View File
@@ -168,7 +168,7 @@ export default class SearchBoxWidget extends BasicWidget {
}
searchInSubtreeListener({noteId}) {
noteId = noteId || appContext.getActiveTabNoteId();
noteId = noteId || appContext.tabManager.getActiveTabNoteId();
this.toggle(true);
@@ -68,7 +68,7 @@ export default class TabAwareWidget extends BasicWidget {
refreshWithNote(note, notePath) {}
activeTabChangedListener() {
this.tabContext = this.appContext.getActiveTabContext();
this.tabContext = this.appContext.tabManager.getActiveTabContext();
this.activeTabChanged();
}
@@ -79,7 +79,7 @@ export default class TabAwareWidget extends BasicWidget {
lazyLoadedListener() {
if (!this.tabContext) { // has not been loaded yet
this.tabContext = this.appContext.getActiveTabContext();
this.tabContext = this.appContext.tabManager.getActiveTabContext();
}
this.refresh();
+4 -4
View File
@@ -490,7 +490,7 @@ export default class TabRowWidget extends BasicWidget {
this.draggabillies.push(draggabilly);
draggabilly.on('pointerDown', _ => {
this.appContext.activateTab(tabEl.getAttribute('data-tab-id'));
this.appContext.tabManager.activateTab(tabEl.getAttribute('data-tab-id'));
});
draggabilly.on('dragStart', _ => {
@@ -585,7 +585,7 @@ export default class TabRowWidget extends BasicWidget {
tabNoteSwitchedListener({tabId}) {
const $tab = this.getTabById(tabId);
const {note} = this.appContext.getTabContextById(tabId);
const {note} = this.appContext.tabManager.getTabContextById(tabId);
this.updateTab($tab, note);
}
@@ -609,7 +609,7 @@ export default class TabRowWidget extends BasicWidget {
}
async entitiesReloadedListener({loadResults}) {
for (const tabContext of this.appContext.getTabContexts()) {
for (const tabContext of this.appContext.tabManager.getTabContexts()) {
if (loadResults.isNoteReloaded(tabContext.noteId)) {
const $tab = this.getTabById(tabContext.tabId);
@@ -619,7 +619,7 @@ export default class TabRowWidget extends BasicWidget {
}
treeCacheReloadedListener() {
for (const tabContext of this.appContext.getTabContexts()) {
for (const tabContext of this.appContext.tabManager.getTabContexts()) {
const $tab = this.getTabById(tabContext.tabId);
this.updateTab($tab, tabContext.note);
@@ -28,7 +28,7 @@ export default class EmptyTypeWidget extends TypeWidget {
return false;
}
appContext.getActiveTabContext().setNote(suggestion.path);
appContext.tabManager.getActiveTabContext().setNote(suggestion.path);
});
noteAutocompleteService.showRecentNotes(this.$autoComplete);
@@ -91,7 +91,7 @@ export default class TextTypeWidget extends TypeWidget {
if (match) {
const noteId = match[1];
appContext.getActiveTabContext().setNote(noteId);
appContext.tabManager.getActiveTabContext().setNote(noteId);
}
else {
window.open(src, '_blank');