From ec578101af28856db232f58704efdbbb5bf9bb31 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 11 Feb 2025 21:58:29 +0100 Subject: [PATCH] chore(ts): port sync_status.ts --- .../widgets/{sync_status.js => sync_status.ts} | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) rename src/public/app/widgets/{sync_status.js => sync_status.ts} (88%) diff --git a/src/public/app/widgets/sync_status.js b/src/public/app/widgets/sync_status.ts similarity index 88% rename from src/public/app/widgets/sync_status.js rename to src/public/app/widgets/sync_status.ts index df13c8716..f5dc186b6 100644 --- a/src/public/app/widgets/sync_status.js +++ b/src/public/app/widgets/sync_status.ts @@ -4,6 +4,7 @@ import ws from "../services/ws.js"; import options from "../services/options.js"; import syncService from "../services/sync.js"; import { escapeQuotes } from "../services/utils.js"; +import { Tooltip } from "bootstrap"; const TPL = `
@@ -71,6 +72,15 @@ const TPL = ` `; export default class SyncStatusWidget extends BasicWidget { + + syncState: "unknown" | "in-progress" | "connected" | "disconnected"; + allChangesPushed: boolean; + lastSyncedPush!: number; + settings: { + // TriliumNextTODO: narrow types and use TitlePlacement Type + titlePlacement: string; + } + constructor() { super(); @@ -90,13 +100,14 @@ export default class SyncStatusWidget extends BasicWidget { ws.subscribeToMessages((message) => this.processMessage(message)); } - showIcon(className) { + showIcon(className: string) { if (!options.get("syncServerHost")) { this.toggleInt(false); return; } - bootstrap.Tooltip.getOrCreateInstance(this.$widget.find(`.sync-status-${className}`), { + + Tooltip.getOrCreateInstance(this.$widget.find(`.sync-status-${className}`)[0], { html: true, placement: this.settings.titlePlacement, fallbackPlacements: [this.settings.titlePlacement] @@ -107,7 +118,8 @@ export default class SyncStatusWidget extends BasicWidget { this.$widget.find(`.sync-status-${className}`).show(); } - processMessage(message) { + // TriliumNextTODO: Use Type Message from "services/ws.ts" + processMessage(message: { type: string; lastSyncedPush: number; data: { lastSyncedPush: number } }) { if (message.type === "sync-pull-in-progress") { this.syncState = "in-progress"; this.lastSyncedPush = message.lastSyncedPush;