Skip to content

Build your personal knowledge base with Trilium Notes

feat(collections): allow refreshing web view widgets in dashboard

Elian Doran79330bb63158
diff --git a/apps/client/src/widgets/collections/dashboard/context_menu.ts b/apps/client/src/widgets/collections/dashboard/context_menu.ts
index 55503ec119..e019c651d6 100644
--- a/apps/client/src/widgets/collections/dashboard/context_menu.ts
+++ b/apps/client/src/widgets/collections/dashboard/context_menu.ts
@@ -5,7 +5,7 @@ import branches from "../../../services/branches";
import { t } from "../../../services/i18n";
export default function openWidgetContextMenu(notePath: string, branchId: string, e: ContextMenuEvent, { onRefresh }: {
- /** When provided (i.e. the widget is a render note), adds a "Refresh" item that re-renders it. */
+ /** When provided (i.e. the widget is a render note or web view), adds a "Refresh" item that re-renders it. */
onRefresh?: () => void;
}) {
const items: MenuItem<CommandNames>[] = [
diff --git a/apps/client/src/widgets/collections/dashboard/index.tsx b/apps/client/src/widgets/collections/dashboard/index.tsx
index 8b6b35e38d..c7fa01e41c 100644
--- a/apps/client/src/widgets/collections/dashboard/index.tsx
+++ b/apps/client/src/widgets/collections/dashboard/index.tsx
@@ -311,9 +311,10 @@ interface DashboardWidgetProps {
function DashboardWidget({ note, parentNote, highlightedTokens, includeArchived, showTextRepresentation }: DashboardWidgetProps) {
const notePath = getNotePath(parentNote, note);
- // Bumping the key remounts NoteContent, which re-runs the render — only meaningful for render notes.
+ // Bumping the key remounts NoteContent, which re-runs the render — meaningful for render notes
+ // (re-runs the script) and web views (reloads the embedded page).
const [ refreshKey, setRefreshKey ] = useState(0);
- const isRenderNote = note.type === "render";
+ const canRefresh = note.type === "render" || note.type === "webView";
/* The outer .grid-stack-item class list must stay constant across renders so that Preact never
clobbers the classes gridstack adds there; dynamic classes go on the inner content element. */
@@ -337,7 +338,7 @@ function DashboardWidget({ note, parentNote, highlightedTokens, includeArchived,
const branchId = note.parentToBranch[parentNote.noteId];
if (!branchId) return;
openWidgetContextMenu(notePath, branchId, e, {
- onRefresh: isRenderNote ? () => setRefreshKey((key) => key + 1) : undefined
+ onRefresh: canRefresh ? () => setRefreshKey((key) => key + 1) : undefined
});
}} />
</div>