Add blocked count into status bar
This commit is contained in:
parent
0d2b0e6de0
commit
07d6a75c96
1 changed files with 18 additions and 4 deletions
|
|
@ -1,17 +1,31 @@
|
|||
import type { Plugin } from "obsidian";
|
||||
import { Syncer } from "src/sync-operations/syncer";
|
||||
import type { HistoryStats, SyncHistory } from "src/tracing/sync-history";
|
||||
|
||||
export class StatusBar {
|
||||
private readonly statusBarItem: HTMLElement;
|
||||
|
||||
public constructor(plugin: Plugin, history: SyncHistory) {
|
||||
private lastHistoryStats: HistoryStats | undefined;
|
||||
private lastRemaining: number | undefined;
|
||||
|
||||
public constructor(plugin: Plugin, history: SyncHistory, syncer: Syncer) {
|
||||
this.statusBarItem = plugin.addStatusBarItem();
|
||||
history.addSyncHistoryUpdateListener((status) => {
|
||||
this.updateStatus(status);
|
||||
this.lastHistoryStats = status;
|
||||
this.updateStatus();
|
||||
});
|
||||
|
||||
syncer.addRemainingOperationsListener((remainingOperations) => {
|
||||
this.lastRemaining = remainingOperations;
|
||||
this.updateStatus();
|
||||
});
|
||||
}
|
||||
|
||||
private updateStatus({ success, error }: HistoryStats): void {
|
||||
this.statusBarItem.setText(`${success} ✅ ${error} ❌`);
|
||||
private updateStatus(): void {
|
||||
this.statusBarItem.setText(
|
||||
`${this.lastRemaining ?? 0} ⏳ | ${
|
||||
this.lastHistoryStats?.success ?? 0
|
||||
} ✅ | ${this.lastHistoryStats?.error ?? 0} ❌`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue