mirror of
https://github.com/zadam/trilium.git
synced 2025-01-16 03:58:53 +08:00
refactored TabContext => NoteContext
This commit is contained in:
parent
79a85a0aa7
commit
1a0aaf4a30
11 changed files with 18 additions and 22 deletions
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1233,7 +1233,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||
}
|
||||
|
||||
async hoistedNoteChangedEvent({ntxId}) {
|
||||
if (this.isTab(ntxId)) {
|
||||
if (this.isNoteContext(ntxId)) {
|
||||
this.filterHoistedBranch();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ export default class SearchResultWidget extends NoteContextAwareWidget {
|
|||
}
|
||||
|
||||
searchRefreshedEvent({ntxId}) {
|
||||
if (!this.isTab(ntxId)) {
|
||||
if (!this.isNoteContext(ntxId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class SqlResultWidget extends NoteContextAwareWidget {
|
|||
}
|
||||
|
||||
async sqlQueryResultsEvent({ntxId, results}) {
|
||||
if (!this.isTab(ntxId)) {
|
||||
if (!this.isNoteContext(ntxId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class ImageTypeWidget extends TypeWidget {
|
|||
}
|
||||
|
||||
copyImageToClipboardEvent({ntxId}) {
|
||||
if (!this.isTab(ntxId)) {
|
||||
if (!this.isNoteContext(ntxId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue