Improve history view

This commit is contained in:
Andras Schmelczer 2025-03-22 18:41:30 +00:00
parent abe074202b
commit 30ecf52dde
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
7 changed files with 165 additions and 129 deletions

View file

@ -6,7 +6,6 @@ export interface CommonHistoryEntry {
relativePath: RelativePath;
message: string;
type?: SyncType;
source?: SyncSource;
}
export enum SyncType {
@ -15,11 +14,6 @@ export enum SyncType {
DELETE = "DELETE"
}
export enum SyncSource {
PUSH = "PUSH",
PULL = "PULL"
}
export enum SyncStatus {
SUCCESS = "SUCCESS",
ERROR = "ERROR"
@ -35,7 +29,7 @@ export interface HistoryStats {
export class SyncHistory {
private static readonly MAX_ENTRIES = 500;
private readonly entries: HistoryEntry[] = [];
private entries: HistoryEntry[] = [];
private readonly syncHistoryUpdateListeners: ((
status: HistoryStats
@ -75,6 +69,18 @@ export class SyncHistory {
...entry,
timestamp: new Date()
};
const candidate = this.entries.find(
(e) => e.relativePath === historyEntry.relativePath
);
if (
candidate !== undefined &&
(this.entries.slice(-1)[0] === candidate ||
candidate.timestamp.getTime() + 10 * 1000 >
historyEntry.timestamp.getTime())
) {
this.entries = this.entries.filter((e) => e !== candidate);
}
this.entries.push(historyEntry);
if (entry.status === SyncStatus.SUCCESS) {