From 1a0aaf4a30f2e72910c26839a3f30c09014ab9ad Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 22 May 2021 12:42:34 +0200 Subject: [PATCH] refactored TabContext => NoteContext --- .../app/widgets/attribute_widgets/attribute_editor.js | 4 ++-- src/public/app/widgets/note_context_aware_widget.js | 6 +----- src/public/app/widgets/note_context_caching_widget.js | 2 +- src/public/app/widgets/note_detail.js | 10 +++++----- src/public/app/widgets/note_list.js | 2 +- src/public/app/widgets/note_title.js | 4 ++-- src/public/app/widgets/note_tree.js | 2 +- src/public/app/widgets/search_result.js | 2 +- src/public/app/widgets/sql_result.js | 2 +- src/public/app/widgets/type_widgets/image.js | 2 +- src/public/app/widgets/type_widgets/type_widget.js | 4 ++-- 11 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/public/app/widgets/attribute_widgets/attribute_editor.js b/src/public/app/widgets/attribute_widgets/attribute_editor.js index 4c1ac360d..8f0c69a20 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_editor.js +++ b/src/public/app/widgets/attribute_widgets/attribute_editor.js @@ -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'); } } diff --git a/src/public/app/widgets/note_context_aware_widget.js b/src/public/app/widgets/note_context_aware_widget.js index 9f9dce144..a11e581ac 100644 --- a/src/public/app/widgets/note_context_aware_widget.js +++ b/src/public/app/widgets/note_context_aware_widget.js @@ -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; } diff --git a/src/public/app/widgets/note_context_caching_widget.js b/src/public/app/widgets/note_context_caching_widget.js index 1dd1f479d..d91a77614 100644 --- a/src/public/app/widgets/note_context_caching_widget.js +++ b/src/public/app/widgets/note_context_caching_widget.js @@ -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)); } } diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 7837ce1b9..f40c565ce 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -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(); } } diff --git a/src/public/app/widgets/note_list.js b/src/public/app/widgets/note_list.js index 5107a82f4..5c996bf10 100644 --- a/src/public/app/widgets/note_list.js +++ b/src/public/app/widgets/note_list.js @@ -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; } diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js index 6314a7e4f..fbb74c015 100644 --- a/src/public/app/widgets/note_title.js +++ b/src/public/app/widgets/note_title.js @@ -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(); } } diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 7d5362409..ea408d3aa 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -1233,7 +1233,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } async hoistedNoteChangedEvent({ntxId}) { - if (this.isTab(ntxId)) { + if (this.isNoteContext(ntxId)) { this.filterHoistedBranch(); } } diff --git a/src/public/app/widgets/search_result.js b/src/public/app/widgets/search_result.js index a4a9c944d..f73f9d4f7 100644 --- a/src/public/app/widgets/search_result.js +++ b/src/public/app/widgets/search_result.js @@ -57,7 +57,7 @@ export default class SearchResultWidget extends NoteContextAwareWidget { } searchRefreshedEvent({ntxId}) { - if (!this.isTab(ntxId)) { + if (!this.isNoteContext(ntxId)) { return; } diff --git a/src/public/app/widgets/sql_result.js b/src/public/app/widgets/sql_result.js index 4fed6803e..746542b04 100644 --- a/src/public/app/widgets/sql_result.js +++ b/src/public/app/widgets/sql_result.js @@ -26,7 +26,7 @@ export default class SqlResultWidget extends NoteContextAwareWidget { } async sqlQueryResultsEvent({ntxId, results}) { - if (!this.isTab(ntxId)) { + if (!this.isNoteContext(ntxId)) { return; } diff --git a/src/public/app/widgets/type_widgets/image.js b/src/public/app/widgets/type_widgets/image.js index cd65b2a07..1c8ca64f0 100644 --- a/src/public/app/widgets/type_widgets/image.js +++ b/src/public/app/widgets/type_widgets/image.js @@ -63,7 +63,7 @@ class ImageTypeWidget extends TypeWidget { } copyImageToClipboardEvent({ntxId}) { - if (!this.isTab(ntxId)) { + if (!this.isNoteContext(ntxId)) { return; } diff --git a/src/public/app/widgets/type_widgets/type_widget.js b/src/public/app/widgets/type_widgets/type_widget.js index eae9465f9..d09b50299 100644 --- a/src/public/app/widgets/type_widgets/type_widget.js +++ b/src/public/app/widgets/type_widgets/type_widget.js @@ -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(); } }