Improve history view
This commit is contained in:
parent
abe074202b
commit
30ecf52dde
7 changed files with 165 additions and 129 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue