diff --git a/apps/client/src/widgets/type_widgets/Image.tsx b/apps/client/src/widgets/type_widgets/Image.tsx index 956a461bd..8381127fb 100644 --- a/apps/client/src/widgets/type_widgets/Image.tsx +++ b/apps/client/src/widgets/type_widgets/Image.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from "preact/hooks"; import { createImageSrcUrl } from "../../services/utils"; -import { useTriliumEvent, useUniqueName } from "../react/hooks"; +import { useNoteBlob, useTriliumEvent, useUniqueName } from "../react/hooks"; import "./Image.css"; import { TypeWidgetProps } from "./type_widget"; import WheelZoom from 'vanilla-js-wheel-zoom'; @@ -11,6 +11,7 @@ import { copyImageReferenceToClipboard } from "../../services/image"; export default function Image({ note, ntxId }: TypeWidgetProps) { const uniqueId = useUniqueName("image"); const containerRef = useRef(null); + const [ refreshCounter, setRefreshCounter ] = useState(0); // Set up pan & zoom useEffect(() => { @@ -32,6 +33,13 @@ export default function Image({ note, ntxId }: TypeWidgetProps) { copyImageReferenceToClipboard(refToJQuerySelector(containerRef)); }); + // React to new revisions. + useTriliumEvent("entitiesReloaded", ({ loadResults }) => { + if (loadResults.isNoteReloaded(note.noteId)) { + setRefreshCounter(refreshCounter + 1); + } + }); + return (
diff --git a/apps/client/src/widgets/type_widgets_old/image.ts b/apps/client/src/widgets/type_widgets_old/image.ts deleted file mode 100644 index f5e337b7b..000000000 --- a/apps/client/src/widgets/type_widgets_old/image.ts +++ /dev/null @@ -1,27 +0,0 @@ -import utils from "../../services/utils.js"; -import TypeWidget from "./type_widget.js"; -import imageContextMenuService from "../../menus/image_context_menu.js"; -import imageService from "../../services/image.js"; -import type FNote from "../../entities/fnote.js"; -import type { EventData } from "../../components/app_context.js"; - -class ImageTypeWidget extends TypeWidget { - - private $imageWrapper!: JQuery; - private $imageView!: JQuery; - - static getType() { - return "image"; - } - - copyImageReferenceToClipboardEvent({ ntxId }: EventData<"copyImageReferenceToClipboard">) { - } - - async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { - if (loadResults.isNoteReloaded(this.noteId)) { - this.refresh(); - } - } -} - -export default ImageTypeWidget;