Add sync history backend
This commit is contained in:
parent
4a4d8c6d1a
commit
f552ac4abc
3 changed files with 179 additions and 12 deletions
|
|
@ -1,21 +1,17 @@
|
|||
import { Plugin } from "obsidian";
|
||||
import { RequestCountStatus, SyncService } from "src/services/sync-service";
|
||||
import type { Plugin } from "obsidian";
|
||||
import type { HistoryStats, SyncHistory } from "src/tracing/sync-history";
|
||||
|
||||
export class StatusBar {
|
||||
private statusBarItem: HTMLElement;
|
||||
private readonly statusBarItem: HTMLElement;
|
||||
|
||||
public constructor(plugin: Plugin, service: SyncService) {
|
||||
public constructor(plugin: Plugin, history: SyncHistory) {
|
||||
this.statusBarItem = plugin.addStatusBarItem();
|
||||
service.addRequestCountChangeListener((status) =>
|
||||
this.updateStatus(status)
|
||||
history.addSyncHistoryStatsChangeListener((status) =>
|
||||
{ this.updateStatus(status); }
|
||||
);
|
||||
}
|
||||
|
||||
private updateStatus({
|
||||
waiting,
|
||||
success,
|
||||
failure,
|
||||
}: RequestCountStatus): void {
|
||||
this.statusBarItem.setText(`${waiting} 🔄 ${success} ✅ ${failure} ❌`);
|
||||
private updateStatus({ success, error }: HistoryStats): void {
|
||||
this.statusBarItem.setText(`${success} ✅ ${error} ❌`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue