mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	feat(react): set up hook for reacting to events
This commit is contained in:
		| @@ -15,6 +15,7 @@ import RenameNoteBulkAction from "../bulk_actions/note/rename_note"; | ||||
| import { RawHtmlBlock } from "../react/RawHtml"; | ||||
| import FNote from "../../entities/fnote"; | ||||
| import froca from "../../services/froca"; | ||||
| import useTriliumEvent from "../react/hooks"; | ||||
|  | ||||
| interface BulkActionProps { | ||||
|     bulkActionNote?: FNote | null; | ||||
| @@ -42,6 +43,10 @@ function BulkActionComponent({ selectedOrActiveNoteIds, bulkActionNote }: BulkAc | ||||
|         setExistingActions(bulk_action.parseActions(bulkActionNote)); | ||||
|     }, []); | ||||
|  | ||||
|     useTriliumEvent("entitiesReloaded", () => { | ||||
|         console.log("Got entities reloaded."); | ||||
|     }); | ||||
|  | ||||
|     return ( selectedOrActiveNoteIds && | ||||
|         <Modal | ||||
|             className="bulk-actions-dialog" | ||||
| @@ -130,14 +135,4 @@ export default class BulkActionsDialog extends ReactBasicWidget { | ||||
|         openDialog(this.$widget); | ||||
|     } | ||||
|  | ||||
|     entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { | ||||
|         // only refreshing deleted attrs, otherwise components update themselves | ||||
|         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.props.selectedOrActiveNoteIds && this.$widget.is(":visible")) { | ||||
|                 this.doRender(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user