Fix history view
This commit is contained in:
parent
58a61d036b
commit
468d0ac8cf
4 changed files with 77 additions and 45 deletions
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
textarea {
|
||||
resize: none;
|
||||
height: 60px;
|
||||
height: 75px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,14 @@ export class HistoryView extends ItemView {
|
|||
super(leaf);
|
||||
this.icon = HistoryView.ICON;
|
||||
|
||||
this.client.addSyncHistoryUpdateListener(() => {
|
||||
this.updateView().catch((_error: unknown) => {
|
||||
this.client.logger.error("Failed to update history view");
|
||||
});
|
||||
});
|
||||
this.client.addSyncHistoryUpdateListener(
|
||||
() =>
|
||||
void this.updateView().catch((error: unknown) => {
|
||||
this.client.logger.error(
|
||||
`Failed to update history view: ${error}`
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private static getSyncTypeIcon(type: SyncType | undefined): IconName {
|
||||
|
|
@ -58,6 +61,21 @@ export class HistoryView extends ItemView {
|
|||
});
|
||||
}
|
||||
|
||||
private static updateTimeSince(
|
||||
element: HTMLElement,
|
||||
entry: HistoryEntry
|
||||
): void {
|
||||
const timestampElement = element.querySelector(
|
||||
".history-card-timestamp"
|
||||
);
|
||||
if (timestampElement != null) {
|
||||
timestampElement.textContent = intlFormatDistance(
|
||||
entry.timestamp,
|
||||
new Date()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getViewType(): string {
|
||||
return HistoryView.TYPE;
|
||||
}
|
||||
|
|
@ -88,7 +106,7 @@ export class HistoryView extends ItemView {
|
|||
return;
|
||||
}
|
||||
|
||||
const entries = this.client.getHistoryEntries().reverse();
|
||||
const entries = this.client.getHistoryEntries();
|
||||
|
||||
if (this.historyEntryToElement.size === 0 && entries.length > 0) {
|
||||
// Clear the "No update has happened yet" message
|
||||
|
|
@ -98,15 +116,7 @@ export class HistoryView extends ItemView {
|
|||
entries.forEach((entry) => {
|
||||
const element = this.historyEntryToElement.get(entry);
|
||||
if (element !== undefined) {
|
||||
const timestampElement = element.querySelector(
|
||||
".history-card-timestamp"
|
||||
);
|
||||
if (timestampElement != null) {
|
||||
timestampElement.textContent = intlFormatDistance(
|
||||
entry.timestamp,
|
||||
new Date()
|
||||
);
|
||||
}
|
||||
HistoryView.updateTimeSince(element, entry);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue