mirror of
https://github.com/zadam/trilium.git
synced 2026-01-10 00:24:32 +01:00
feat(save_indicator): indicate errors
This commit is contained in:
parent
62af66b5ae
commit
5f14861682
@ -1,4 +1,5 @@
|
||||
import type { SaveState } from "../components/note_context";
|
||||
import { getErrorMessage } from "./utils";
|
||||
|
||||
type Callback = () => Promise<void> | void;
|
||||
|
||||
@ -38,7 +39,8 @@ export default class SpacedUpdate {
|
||||
this.stateCallback?.("saved");
|
||||
} catch (e) {
|
||||
this.changed = true;
|
||||
|
||||
this.stateCallback?.("error");
|
||||
logError(getErrorMessage(e));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@ -68,15 +70,20 @@ export default class SpacedUpdate {
|
||||
this.updateInterval = interval;
|
||||
}
|
||||
|
||||
triggerUpdate() {
|
||||
async triggerUpdate() {
|
||||
if (!this.changed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Date.now() - this.lastUpdated > this.updateInterval) {
|
||||
this.stateCallback?.("saving");
|
||||
this.updater();
|
||||
this.stateCallback?.("saved");
|
||||
try {
|
||||
await this.updater();
|
||||
this.stateCallback?.("saved");
|
||||
} catch (e) {
|
||||
this.stateCallback?.("error");
|
||||
logError(getErrorMessage(e));
|
||||
}
|
||||
this.lastUpdated = Date.now();
|
||||
this.changed = false;
|
||||
} else {
|
||||
|
||||
@ -141,7 +141,7 @@ function SaveStatusBadge() {
|
||||
|
||||
return (
|
||||
<Badge
|
||||
className={clsx("save-status-badge", saveState)}
|
||||
className={clsx("save-status-badge", saveState.state)}
|
||||
icon={icon}
|
||||
text={title}
|
||||
tooltip={tooltip}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user