Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
got rid of .isDeleted on froca entities (the property is not available there)
zadam5c393f959d70
diff --git a/src/public/app/components/note_context.js b/src/public/app/components/note_context.jsindex de39313e42..9116304b25 100644--- a/src/public/app/components/note_context.js+++ b/src/public/app/components/note_context.js@@ -241,9 +241,9 @@ class NoteContext extends Component {async entitiesReloadedEvent({loadResults}) {if (loadResults.isNoteReloaded(this.noteId)) {- const note = loadResults.getEntityRow('notes', this.noteId);+ const noteRow = loadResults.getEntityRow('notes', this.noteId);- if (note.isDeleted) {+ if (noteRow.isDeleted) {this.noteId = null;this.notePath = null;diff --git a/src/public/app/components/shortcut_component.js b/src/public/app/components/shortcut_component.jsindex dfe0dde368..f19a718853 100644--- a/src/public/app/components/shortcut_component.js+++ b/src/public/app/components/shortcut_component.js@@ -15,14 +15,14 @@ export default class ShortcutComponent extends Component {});}- bindNoteShortcutHandler(label) {- const handler = () => appContext.tabManager.getActiveContext().setNote(label.noteId);- const namespace = label.attributeId;+ bindNoteShortcutHandler(labelOrRow) {+ const handler = () => appContext.tabManager.getActiveContext().setNote(labelOrRow.noteId);+ const namespace = labelOrRow.attributeId;- if (label.isDeleted) {+ if (labelOrRow.isDeleted) { // only applicable if rowshortcutService.removeGlobalShortcut(namespace);} else {- shortcutService.bindGlobalShortcut(label.value, handler, namespace);+ shortcutService.bindGlobalShortcut(labelOrRow.value, handler, namespace);}}diff --git a/src/public/app/services/load_results.js b/src/public/app/services/load_results.jsindex af36f7d8ef..0b1bb7625e 100644--- a/src/public/app/services/load_results.js+++ b/src/public/app/services/load_results.js@@ -67,7 +67,6 @@ export default class LoadResults {this.attributeRows.push({attributeId, componentId});}- /** @returns {FAttribute[]} */getAttributeRows(componentId = 'none') {return this.attributeRows.filter(row => row.componentId !== componentId)diff --git a/src/public/app/services/note_tooltip.js b/src/public/app/services/note_tooltip.jsindex df6530ed93..e8708f273a 100644--- a/src/public/app/services/note_tooltip.js+++ b/src/public/app/services/note_tooltip.js@@ -75,7 +75,7 @@ function mouseLeaveHandler() {}async function renderTooltip(note) {- if (note.isDeleted) {+ if (!note) {return '<div>Note has been deleted.</div>';}diff --git a/src/public/app/widgets/attachment_detail.js b/src/public/app/widgets/attachment_detail.jsindex 8b8c60d28a..7d1c564a01 100644--- a/src/public/app/widgets/attachment_detail.js+++ b/src/public/app/widgets/attachment_detail.js@@ -191,10 +191,10 @@ export default class AttachmentDetailWidget extends BasicWidget {}async entitiesReloadedEvent({loadResults}) {- const attachmentChange = loadResults.getAttachmentRows().find(att => att.attachmentId === this.attachment.attachmentId);+ const attachmentRow = loadResults.getAttachmentRows().find(att => att.attachmentId === this.attachment.attachmentId);- if (attachmentChange) {- if (attachmentChange.isDeleted) {+ if (attachmentRow) {+ if (attachmentRow.isDeleted) {this.toggleInt(false);} else {this.refresh();diff --git a/src/public/app/widgets/attribute_widgets/attribute_editor.js b/src/public/app/widgets/attribute_widgets/attribute_editor.jsindex cef05b895c..e8f55523f1 100644--- a/src/public/app/widgets/attribute_widgets/attribute_editor.js+++ b/src/public/app/widgets/attribute_widgets/attribute_editor.js@@ -460,14 +460,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {const {noteId} = linkService.parseNavigationStateFromUrl($el.find("a").attr("href"));const note = await froca.getNote(noteId, true);- let title;-- if (!note) {- title = '[missing]';- }- else {- title = note.isDeleted ? `${note.title} (deleted)` : note.title;- }+ const title = note ? note.title : '[missing]';$el.text(title);}@@ -477,7 +470,6 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {}async renderOwnedAttributes(ownedAttributes, saved) {- ownedAttributes = ownedAttributes.filter(oa => !oa.isDeleted);// attrs are not resorted if position changes after initial loadownedAttributes.sort((a, b) => a.position < b.position ? -1 : 1);diff --git a/src/public/app/widgets/buttons/launcher/abstract_launcher.js b/src/public/app/widgets/buttons/launcher/abstract_launcher.jsindex 87bfbd6d01..3e9cd1f6dc 100644--- a/src/public/app/widgets/buttons/launcher/abstract_launcher.js+++ b/src/public/app/widgets/buttons/launcher/abstract_launcher.js@@ -20,13 +20,13 @@ export default class AbstractLauncher extends OnClickButtonWidget {throw new Error("Abstract implementation");}- bindNoteShortcutHandler(label) {- const namespace = label.attributeId;+ bindNoteShortcutHandler(labelOrRow) {+ const namespace = labelOrRow.attributeId;- if (label.isDeleted) {+ if (labelOrRow.isDeleted) { // only applicable if rowshortcutService.removeGlobalShortcut(namespace);} else {- shortcutService.bindGlobalShortcut(label.value, () => this.launch(), namespace);+ shortcutService.bindGlobalShortcut(labelOrRow.value, () => this.launch(), namespace);}}diff --git a/src/public/app/widgets/dialogs/bulk_actions.js b/src/public/app/widgets/dialogs/bulk_actions.jsindex 6e635b0504..5c74ce62d5 100644--- a/src/public/app/widgets/dialogs/bulk_actions.js+++ b/src/public/app/widgets/dialogs/bulk_actions.js@@ -147,11 +147,11 @@ export default class BulkActionsDialog extends BasicWidget {entitiesReloadedEvent({loadResults}) {// only refreshing deleted attrs, otherwise components update themselves- if (loadResults.getAttributeRows().find(attr =>- attr.type === 'label'- && attr.name === 'action'- && attr.noteId === '_bulkAction'- && attr.isDeleted)) {+ if (loadResults.getAttributeRows().find(row =>+ row.type === 'label'+ && row.name === 'action'+ && row.noteId === '_bulkAction'+ && row.isDeleted)) {// this may be triggered from e.g. sync without open widget, then no need to refresh the widgetif (this.selectedOrActiveNoteIds && this.$widget.is(":visible")) {diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.jsindex 433393330a..4bbffa0736 100644--- a/src/public/app/widgets/note_detail.js+++ b/src/public/app/widgets/note_detail.js@@ -19,7 +19,6 @@ import RelationMapTypeWidget from "./type_widgets/relation_map.js";import CanvasTypeWidget from "./type_widgets/canvas.js";import ProtectedSessionTypeWidget from "./type_widgets/protected_session.js";import BookTypeWidget from "./type_widgets/book.js";-import DeletedTypeWidget from "./type_widgets/deleted.js";import ReadOnlyTextTypeWidget from "./type_widgets/read_only_text.js";import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js";import NoneTypeWidget from "./type_widgets/none.js";@@ -47,7 +46,6 @@ const TPL = `const typeWidgetClasses = {'empty': EmptyTypeWidget,- 'deleted': DeletedTypeWidget,'editableText': EditableTextTypeWidget,'readOnlyText': ReadOnlyTextTypeWidget,'editableCode': EditableCodeTypeWidget,@@ -189,8 +187,6 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {if (!note) {return "empty";- } else if (note.isDeleted) {- return "deleted";}let type = note.type;diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.jsindex 5d3c6ede89..e2e3c157fd 100644--- a/src/public/app/widgets/note_tree.js+++ b/src/public/app/widgets/note_tree.js@@ -526,7 +526,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {const note = await froca.getNote(node.data.noteId, true);- if (!note || note.isDeleted) {+ if (!note) {return;}@@ -984,10 +984,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {oldActiveNode.setFocus(false);}- if (this.noteContext- && this.noteContext.notePath- && !this.noteContext.note?.isDeleted- && (!treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) || await hoistedNoteService.isHoistedInHiddenSubtree())+ if (this.noteContext?.notePath+ && (+ !treeService.isNotePathInHiddenSubtree(this.noteContext.notePath)+ || await hoistedNoteService.isHoistedInHiddenSubtree()+ )) {const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);@@ -1125,20 +1126,20 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {let parentsOfAddedNodes = [];const allBranchRows = loadResults.getBranchRows();- const allBranchesDeleted = allBranchRows.every(branch => !!branch.isDeleted);+ const allBranchesDeleted = allBranchRows.every(branchRow => !!branchRow.isDeleted);- for (const ecBranch of allBranchRows) {- if (ecBranch.parentNoteId === '_share') {+ for (const branchRow of allBranchRows) {+ if (branchRow.parentNoteId === '_share') {// all shared notes have a sign in the tree, even the descendants of shared notes- noteIdsToReload.add(ecBranch.noteId);+ noteIdsToReload.add(branchRow.noteId);}else {// adding noteId itself to update all potential clones- noteIdsToUpdate.add(ecBranch.noteId);+ noteIdsToUpdate.add(branchRow.noteId);}- for (const node of this.getNodesByBranch(ecBranch)) {- if (ecBranch.isDeleted) {+ for (const node of this.getNodesByBranch(branchRow)) {+ if (branchRow.isDeleted) {if (node.isActive()) {if (allBranchesDeleted) {const newActiveNode = node.getNextSibling()@@ -1157,23 +1158,23 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {node.remove();}- noteIdsToUpdate.add(ecBranch.parentNoteId);+ noteIdsToUpdate.add(branchRow.parentNoteId);}}- if (!ecBranch.isDeleted) {- for (const parentNode of this.getNodesByNoteId(ecBranch.parentNoteId)) {+ if (!branchRow.isDeleted) {+ for (const parentNode of this.getNodesByNoteId(branchRow.parentNoteId)) {parentsOfAddedNodes.push(parentNode)if (parentNode.isFolder() && !parentNode.isLoaded()) {continue;}- const found = (parentNode.getChildren() || []).find(child => child.data.noteId === ecBranch.noteId);+ const found = (parentNode.getChildren() || []).find(child => child.data.noteId === branchRow.noteId);if (!found) {// make sure it's loaded- await froca.getNote(ecBranch.noteId);- const frocaBranch = froca.getBranch(ecBranch.branchId);+ await froca.getNote(branchRow.noteId);+ const frocaBranch = froca.getBranch(branchRow.branchId);// we're forcing lazy since it's not clear if the whole required subtree is in frocaparentNode.addChildren([this.prepareNode(frocaBranch, true)]);@@ -1181,7 +1182,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {this.sortChildren(parentNode);// this might be a first child which would force an icon change- noteIdsToUpdate.add(ecBranch.parentNoteId);+ noteIdsToUpdate.add(branchRow.parentNoteId);}}}diff --git a/src/public/app/widgets/ribbon_widgets/search_definition.js b/src/public/app/widgets/ribbon_widgets/search_definition.jsindex d30484bc65..5d2afec4b5 100644--- a/src/public/app/widgets/ribbon_widgets/search_definition.js+++ b/src/public/app/widgets/ribbon_widgets/search_definition.js@@ -312,7 +312,9 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {entitiesReloadedEvent({loadResults}) {// only refreshing deleted attrs, otherwise components update themselves- if (loadResults.getAttributeRows().find(attr => attr.type === 'label' && attr.name === 'action' && attr.isDeleted)) {+ if (loadResults.getAttributeRows().find(attrRow =>+ attrRow.type === 'label' && attrRow.name === 'action' && attrRow.isDeleted)) {+this.refresh();}}diff --git a/src/public/app/widgets/type_widgets/attachment_detail.js b/src/public/app/widgets/type_widgets/attachment_detail.jsindex 95efd5fdd2..f3636176b3 100644--- a/src/public/app/widgets/type_widgets/attachment_detail.js+++ b/src/public/app/widgets/type_widgets/attachment_detail.js@@ -72,9 +72,9 @@ export default class AttachmentDetailTypeWidget extends TypeWidget {}async entitiesReloadedEvent({loadResults}) {- const attachmentChange = loadResults.getAttachmentRows().find(att => att.attachmentId === this.attachmentId);+ const attachmentRow = loadResults.getAttachmentRows().find(att => att.attachmentId === this.attachmentId);- if (attachmentChange?.isDeleted) {+ if (attachmentRow?.isDeleted) {this.refresh(); // all other updates are handled within AttachmentDetailWidget}}diff --git a/src/public/app/widgets/type_widgets/deleted.js b/src/public/app/widgets/type_widgets/deleted.jsdeleted file mode 100644index 955fd28938..0000000000--- a/src/public/app/widgets/type_widgets/deleted.js+++ /dev/null@@ -1,20 +0,0 @@-import TypeWidget from "./type_widget.js";--const TPL = `-<div class="note-detail-deleted note-detail-printable">- <div style="padding: 100px;">- <div class="alert alert-warning" style="padding: 20px;">- This note has been deleted.- </div>- </div>-</div>`;--export default class DeletedTypeWidget extends TypeWidget {- static getType() { return "deleted"; }-- doRender() {- this.$widget = $(TPL);-- super.doRender();- }-}