refactored TabContext => NoteContext

This commit is contained in:
zadam 2021-05-22 12:42:34 +02:00
parent 79a85a0aa7
commit 1a0aaf4a30
11 changed files with 18 additions and 22 deletions

View file

@ -227,14 +227,14 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {
// triggered from keyboard shortcut
addNewLabelEvent({ntxId}) {
if (this.isTab(ntxId)) {
if (this.isNoteContext(ntxId)) {
this.handleAddNewAttributeCommand('addNewLabel');
}
}
// triggered from keyboard shortcut
addNewRelationEvent({ntxId}) {
if (this.isTab(ntxId)) {
if (this.isNoteContext(ntxId)) {
this.handleAddNewAttributeCommand('addNewRelation');
}
}

View file

@ -2,7 +2,7 @@ import BasicWidget from "./basic_widget.js";
import appContext from "../services/app_context.js";
export default class NoteContextAwareWidget extends BasicWidget {
isTab(ntxId) {
isNoteContext(ntxId) {
if (Array.isArray(ntxId)) {
return this.noteContext && ntxId.includes(this.noteContext.ntxId);
}
@ -11,10 +11,6 @@ export default class NoteContextAwareWidget extends BasicWidget {
}
}
isTabOrParent(ntxId) {
return this.noteContext && (this.noteContext.ntxId === ntxId || this.noteContext.mainNtxId === ntxId);
}
isNote(noteId) {
return this.noteId === noteId;
}

View file

@ -55,7 +55,7 @@ export default class NoteContextCachingWidget extends NoteContextAwareWidget {
toggleExt(show) {
for (const ntxId in this.widgets) {
this.widgets[ntxId].toggleExt(show && this.isTab(ntxId));
this.widgets[ntxId].toggleExt(show && this.isNoteContext(ntxId));
}
}

View file

@ -197,13 +197,13 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
}
async beforeNoteSwitchEvent({noteContext}) {
if (this.isTab(noteContext.ntxId)) {
if (this.isNoteContext(noteContext.ntxId)) {
await this.spacedUpdate.updateNowIfNecessary();
}
}
async beforeTabRemoveEvent({ntxIds}) {
if (this.isTab(ntxIds)) {
if (this.isNoteContext(ntxIds)) {
await this.spacedUpdate.updateNowIfNecessary();
}
}
@ -242,7 +242,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
}
hoistedNoteChangedEvent({ntxId}) {
if (this.isTab(ntxId)) {
if (this.isNoteContext(ntxId)) {
this.refresh();
}
}
@ -279,13 +279,13 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
}
textPreviewDisabledEvent({noteContext}) {
if (this.isTab(noteContext.ntxId)) {
if (this.isNoteContext(noteContext.ntxId)) {
this.refresh();
}
}
codePreviewDisabledEvent({noteContext}) {
if (this.isTab(noteContext.ntxId)) {
if (this.isNoteContext(noteContext.ntxId)) {
this.refresh();
}
}

View file

@ -78,7 +78,7 @@ export default class NoteListWidget extends NoteContextAwareWidget {
* it is not intersected (visible) anymore.
*/
noteDetailRefreshedEvent({ntxId}) {
if (!this.isTab(ntxId)) {
if (!this.isNoteContext(ntxId)) {
return;
}

View file

@ -67,13 +67,13 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
}
async beforeNoteSwitchEvent({noteContext}) {
if (this.isTab(noteContext.ntxId)) {
if (this.isNoteContext(noteContext.ntxId)) {
await this.spacedUpdate.updateNowIfNecessary();
}
}
async beforeTabRemoveEvent({ntxIds}) {
if (this.isTab(ntxIds)) {
if (this.isNoteContext(ntxIds)) {
await this.spacedUpdate.updateNowIfNecessary();
}
}

View file

@ -1233,7 +1233,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
async hoistedNoteChangedEvent({ntxId}) {
if (this.isTab(ntxId)) {
if (this.isNoteContext(ntxId)) {
this.filterHoistedBranch();
}
}

View file

@ -57,7 +57,7 @@ export default class SearchResultWidget extends NoteContextAwareWidget {
}
searchRefreshedEvent({ntxId}) {
if (!this.isTab(ntxId)) {
if (!this.isNoteContext(ntxId)) {
return;
}

View file

@ -26,7 +26,7 @@ export default class SqlResultWidget extends NoteContextAwareWidget {
}
async sqlQueryResultsEvent({ntxId, results}) {
if (!this.isTab(ntxId)) {
if (!this.isNoteContext(ntxId)) {
return;
}

View file

@ -63,7 +63,7 @@ class ImageTypeWidget extends TypeWidget {
}
copyImageToClipboardEvent({ntxId}) {
if (!this.isTab(ntxId)) {
if (!this.isNoteContext(ntxId)) {
return;
}

View file

@ -36,13 +36,13 @@ export default class TypeWidget extends NoteContextAwareWidget {
focus() {}
textPreviewDisabledEvent({noteContext}) {
if (this.isTab(noteContext.ntxId)) {
if (this.isNoteContext(noteContext.ntxId)) {
this.refresh();
}
}
codePreviewDisabledEvent({noteContext}) {
if (this.isTab(noteContext.ntxId)) {
if (this.isNoteContext(noteContext.ntxId)) {
this.refresh();
}
}