mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	got rid of .isDeleted on froca entities (the property is not available there)
This commit is contained in:
		| @@ -241,9 +241,9 @@ class NoteContext extends Component { | |||||||
|  |  | ||||||
|     async entitiesReloadedEvent({loadResults}) { |     async entitiesReloadedEvent({loadResults}) { | ||||||
|         if (loadResults.isNoteReloaded(this.noteId)) { |         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.noteId = null; | ||||||
|                 this.notePath = null; |                 this.notePath = null; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,14 +15,14 @@ export default class ShortcutComponent extends Component { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     bindNoteShortcutHandler(label) { |     bindNoteShortcutHandler(labelOrRow) { | ||||||
|         const handler = () => appContext.tabManager.getActiveContext().setNote(label.noteId); |         const handler = () => appContext.tabManager.getActiveContext().setNote(labelOrRow.noteId); | ||||||
|         const namespace = label.attributeId; |         const namespace = labelOrRow.attributeId; | ||||||
|  |  | ||||||
|         if (label.isDeleted) { |         if (labelOrRow.isDeleted) { // only applicable if row | ||||||
|             shortcutService.removeGlobalShortcut(namespace); |             shortcutService.removeGlobalShortcut(namespace); | ||||||
|         } else { |         } else { | ||||||
|             shortcutService.bindGlobalShortcut(label.value, handler, namespace); |             shortcutService.bindGlobalShortcut(labelOrRow.value, handler, namespace); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -67,7 +67,6 @@ export default class LoadResults { | |||||||
|         this.attributeRows.push({attributeId, componentId}); |         this.attributeRows.push({attributeId, componentId}); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** @returns {FAttribute[]} */ |  | ||||||
|     getAttributeRows(componentId = 'none') { |     getAttributeRows(componentId = 'none') { | ||||||
|         return this.attributeRows |         return this.attributeRows | ||||||
|             .filter(row => row.componentId !== componentId) |             .filter(row => row.componentId !== componentId) | ||||||
|   | |||||||
| @@ -75,7 +75,7 @@ function mouseLeaveHandler() { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function renderTooltip(note) { | async function renderTooltip(note) { | ||||||
|     if (note.isDeleted) { |     if (!note) { | ||||||
|         return '<div>Note has been deleted.</div>'; |         return '<div>Note has been deleted.</div>'; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -191,10 +191,10 @@ export default class AttachmentDetailWidget extends BasicWidget { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     async entitiesReloadedEvent({loadResults}) { |     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 (attachmentRow) { | ||||||
|             if (attachmentChange.isDeleted) { |             if (attachmentRow.isDeleted) { | ||||||
|                 this.toggleInt(false); |                 this.toggleInt(false); | ||||||
|             } else { |             } else { | ||||||
|                 this.refresh(); |                 this.refresh(); | ||||||
|   | |||||||
| @@ -460,14 +460,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget { | |||||||
|         const {noteId} = linkService.parseNavigationStateFromUrl($el.find("a").attr("href")); |         const {noteId} = linkService.parseNavigationStateFromUrl($el.find("a").attr("href")); | ||||||
|         const note = await froca.getNote(noteId, true); |         const note = await froca.getNote(noteId, true); | ||||||
|  |  | ||||||
|         let title; |         const title = note ? note.title : '[missing]'; | ||||||
|  |  | ||||||
|         if (!note) { |  | ||||||
|             title = '[missing]'; |  | ||||||
|         } |  | ||||||
|         else { |  | ||||||
|             title = note.isDeleted ? `${note.title} (deleted)` : note.title; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         $el.text(title); |         $el.text(title); | ||||||
|     } |     } | ||||||
| @@ -477,7 +470,6 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     async renderOwnedAttributes(ownedAttributes, saved) { |     async renderOwnedAttributes(ownedAttributes, saved) { | ||||||
|         ownedAttributes = ownedAttributes.filter(oa => !oa.isDeleted); |  | ||||||
|         // attrs are not resorted if position changes after initial load |         // attrs are not resorted if position changes after initial load | ||||||
|         ownedAttributes.sort((a, b) => a.position < b.position ? -1 : 1); |         ownedAttributes.sort((a, b) => a.position < b.position ? -1 : 1); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,13 +20,13 @@ export default class AbstractLauncher extends OnClickButtonWidget { | |||||||
|         throw new Error("Abstract implementation"); |         throw new Error("Abstract implementation"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     bindNoteShortcutHandler(label) { |     bindNoteShortcutHandler(labelOrRow) { | ||||||
|         const namespace = label.attributeId; |         const namespace = labelOrRow.attributeId; | ||||||
|  |  | ||||||
|         if (label.isDeleted) { |         if (labelOrRow.isDeleted) { // only applicable if row | ||||||
|             shortcutService.removeGlobalShortcut(namespace); |             shortcutService.removeGlobalShortcut(namespace); | ||||||
|         } else { |         } else { | ||||||
|             shortcutService.bindGlobalShortcut(label.value, () => this.launch(), namespace); |             shortcutService.bindGlobalShortcut(labelOrRow.value, () => this.launch(), namespace); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -147,11 +147,11 @@ export default class BulkActionsDialog extends BasicWidget { | |||||||
|  |  | ||||||
|     entitiesReloadedEvent({loadResults}) { |     entitiesReloadedEvent({loadResults}) { | ||||||
|         // only refreshing deleted attrs, otherwise components update themselves |         // only refreshing deleted attrs, otherwise components update themselves | ||||||
|         if (loadResults.getAttributeRows().find(attr => |         if (loadResults.getAttributeRows().find(row => | ||||||
|             attr.type === 'label' |             row.type === 'label' | ||||||
|             && attr.name === 'action' |             && row.name === 'action' | ||||||
|             && attr.noteId === '_bulkAction' |             && row.noteId === '_bulkAction' | ||||||
|             && attr.isDeleted)) { |             && row.isDeleted)) { | ||||||
|  |  | ||||||
|             // this may be triggered from e.g. sync without open widget, then no need to refresh the widget |             // this may be triggered from e.g. sync without open widget, then no need to refresh the widget | ||||||
|             if (this.selectedOrActiveNoteIds && this.$widget.is(":visible")) { |             if (this.selectedOrActiveNoteIds && this.$widget.is(":visible")) { | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ import RelationMapTypeWidget from "./type_widgets/relation_map.js"; | |||||||
| import CanvasTypeWidget from "./type_widgets/canvas.js"; | import CanvasTypeWidget from "./type_widgets/canvas.js"; | ||||||
| import ProtectedSessionTypeWidget from "./type_widgets/protected_session.js"; | import ProtectedSessionTypeWidget from "./type_widgets/protected_session.js"; | ||||||
| import BookTypeWidget from "./type_widgets/book.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 ReadOnlyTextTypeWidget from "./type_widgets/read_only_text.js"; | ||||||
| import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js"; | import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js"; | ||||||
| import NoneTypeWidget from "./type_widgets/none.js"; | import NoneTypeWidget from "./type_widgets/none.js"; | ||||||
| @@ -47,7 +46,6 @@ const TPL = ` | |||||||
|  |  | ||||||
| const typeWidgetClasses = { | const typeWidgetClasses = { | ||||||
|     'empty': EmptyTypeWidget, |     'empty': EmptyTypeWidget, | ||||||
|     'deleted': DeletedTypeWidget, |  | ||||||
|     'editableText': EditableTextTypeWidget, |     'editableText': EditableTextTypeWidget, | ||||||
|     'readOnlyText': ReadOnlyTextTypeWidget, |     'readOnlyText': ReadOnlyTextTypeWidget, | ||||||
|     'editableCode': EditableCodeTypeWidget, |     'editableCode': EditableCodeTypeWidget, | ||||||
| @@ -189,8 +187,6 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { | |||||||
|  |  | ||||||
|         if (!note) { |         if (!note) { | ||||||
|             return "empty"; |             return "empty"; | ||||||
|         } else if (note.isDeleted) { |  | ||||||
|             return "deleted"; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         let type = note.type; |         let type = note.type; | ||||||
|   | |||||||
| @@ -526,7 +526,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|  |  | ||||||
|                 const note = await froca.getNote(node.data.noteId, true); |                 const note = await froca.getNote(node.data.noteId, true); | ||||||
|  |  | ||||||
|                 if (!note || note.isDeleted) { |                 if (!note) { | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -984,10 +984,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|             oldActiveNode.setFocus(false); |             oldActiveNode.setFocus(false); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (this.noteContext |         if (this.noteContext?.notePath | ||||||
|             && this.noteContext.notePath |             && ( | ||||||
|             && !this.noteContext.note?.isDeleted |                 !treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) | ||||||
|             && (!treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) || await hoistedNoteService.isHoistedInHiddenSubtree()) |                 || await hoistedNoteService.isHoistedInHiddenSubtree() | ||||||
|  |             ) | ||||||
|         ) { |         ) { | ||||||
|             const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath); |             const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath); | ||||||
|  |  | ||||||
| @@ -1125,20 +1126,20 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|         let parentsOfAddedNodes = []; |         let parentsOfAddedNodes = []; | ||||||
|  |  | ||||||
|         const allBranchRows = loadResults.getBranchRows(); |         const allBranchRows = loadResults.getBranchRows(); | ||||||
|         const allBranchesDeleted = allBranchRows.every(branch => !!branch.isDeleted); |         const allBranchesDeleted = allBranchRows.every(branchRow => !!branchRow.isDeleted); | ||||||
|  |  | ||||||
|         for (const ecBranch of allBranchRows) { |         for (const branchRow of allBranchRows) { | ||||||
|             if (ecBranch.parentNoteId === '_share') { |             if (branchRow.parentNoteId === '_share') { | ||||||
|                 // all shared notes have a sign in the tree, even the descendants of shared notes |                 // all shared notes have a sign in the tree, even the descendants of shared notes | ||||||
|                 noteIdsToReload.add(ecBranch.noteId); |                 noteIdsToReload.add(branchRow.noteId); | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 // adding noteId itself to update all potential clones |                 // adding noteId itself to update all potential clones | ||||||
|                 noteIdsToUpdate.add(ecBranch.noteId); |                 noteIdsToUpdate.add(branchRow.noteId); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             for (const node of this.getNodesByBranch(ecBranch)) { |             for (const node of this.getNodesByBranch(branchRow)) { | ||||||
|                 if (ecBranch.isDeleted) { |                 if (branchRow.isDeleted) { | ||||||
|                     if (node.isActive()) { |                     if (node.isActive()) { | ||||||
|                         if (allBranchesDeleted) { |                         if (allBranchesDeleted) { | ||||||
|                             const newActiveNode = node.getNextSibling() |                             const newActiveNode = node.getNextSibling() | ||||||
| @@ -1157,23 +1158,23 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|                         node.remove(); |                         node.remove(); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     noteIdsToUpdate.add(ecBranch.parentNoteId); |                     noteIdsToUpdate.add(branchRow.parentNoteId); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (!ecBranch.isDeleted) { |             if (!branchRow.isDeleted) { | ||||||
|                 for (const parentNode of this.getNodesByNoteId(ecBranch.parentNoteId)) { |                 for (const parentNode of this.getNodesByNoteId(branchRow.parentNoteId)) { | ||||||
|                     parentsOfAddedNodes.push(parentNode) |                     parentsOfAddedNodes.push(parentNode) | ||||||
|  |  | ||||||
|                     if (parentNode.isFolder() && !parentNode.isLoaded()) { |                     if (parentNode.isFolder() && !parentNode.isLoaded()) { | ||||||
|                         continue; |                         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) { |                     if (!found) { | ||||||
|                         // make sure it's loaded |                         // make sure it's loaded | ||||||
|                         await froca.getNote(ecBranch.noteId); |                         await froca.getNote(branchRow.noteId); | ||||||
|                         const frocaBranch = froca.getBranch(ecBranch.branchId); |                         const frocaBranch = froca.getBranch(branchRow.branchId); | ||||||
|  |  | ||||||
|                         // we're forcing lazy since it's not clear if the whole required subtree is in froca |                         // we're forcing lazy since it's not clear if the whole required subtree is in froca | ||||||
|                         parentNode.addChildren([this.prepareNode(frocaBranch, true)]); |                         parentNode.addChildren([this.prepareNode(frocaBranch, true)]); | ||||||
| @@ -1181,7 +1182,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|                         this.sortChildren(parentNode); |                         this.sortChildren(parentNode); | ||||||
|  |  | ||||||
|                         // this might be a first child which would force an icon change |                         // this might be a first child which would force an icon change | ||||||
|                         noteIdsToUpdate.add(ecBranch.parentNoteId); |                         noteIdsToUpdate.add(branchRow.parentNoteId); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -312,7 +312,9 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget { | |||||||
|  |  | ||||||
|     entitiesReloadedEvent({loadResults}) { |     entitiesReloadedEvent({loadResults}) { | ||||||
|         // only refreshing deleted attrs, otherwise components update themselves |         // 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(); |             this.refresh(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -72,9 +72,9 @@ export default class AttachmentDetailTypeWidget extends TypeWidget { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     async entitiesReloadedEvent({loadResults}) { |     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 |             this.refresh(); // all other updates are handled within AttachmentDetailWidget | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -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(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
		Reference in New Issue
	
	Block a user