mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
Merge pull request #1167 from TriliumNext/chore_ts-port_sync_status
chore(ts): port sync_status.ts
This commit is contained in:
commit
e5aed0a3fc
@ -72,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();
|
||||
|
||||
@ -91,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;
|
||||
}
|
||||
|
||||
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]
|
||||
@ -108,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;
|
Loading…
x
Reference in New Issue
Block a user