mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:49:01 +01:00 
			
		
		
		
	got rid of .isDeleted on froca entities (the property is not available there)
This commit is contained in:
		
							parent
							
								
									e6bf6424e8
								
							
						
					
					
						commit
						5c393f959d
					
				| @ -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; | ||||
| 
 | ||||
|  | ||||
| @ -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 row
 | ||||
|             shortcutService.removeGlobalShortcut(namespace); | ||||
|         } 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}); | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {FAttribute[]} */ | ||||
|     getAttributeRows(componentId = 'none') { | ||||
|         return this.attributeRows | ||||
|             .filter(row => row.componentId !== componentId) | ||||
|  | ||||
| @ -75,7 +75,7 @@ function mouseLeaveHandler() { | ||||
| } | ||||
| 
 | ||||
| async function renderTooltip(note) { | ||||
|     if (note.isDeleted) { | ||||
|     if (!note) { | ||||
|         return '<div>Note has been deleted.</div>'; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -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 load
 | ||||
|         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"); | ||||
|     } | ||||
| 
 | ||||
|     bindNoteShortcutHandler(label) { | ||||
|         const namespace = label.attributeId; | ||||
|     bindNoteShortcutHandler(labelOrRow) { | ||||
|         const namespace = labelOrRow.attributeId; | ||||
| 
 | ||||
|         if (label.isDeleted) { | ||||
|         if (labelOrRow.isDeleted) { // only applicable if row
 | ||||
|             shortcutService.removeGlobalShortcut(namespace); | ||||
|         } 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}) { | ||||
|         // 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 widget
 | ||||
|             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 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; | ||||
|  | ||||
| @ -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 froca
 | ||||
|                         parentNode.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); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @ -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(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -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
 | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -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(); | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam