mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-29 04:23:20 +00:00
Show initial and retrying Chunk fetches separately
Display disjoint pending counts in the status bar and cover atomic updates and disposal. Add a real Obsidian and CouchDB scenario for delayed arrival, terminal absence, and finite-replication completion. Document retry scheduling and pending-count semantics. This uses the new Commonlib chunkFetchCounts export; the exact package dependency will be updated after its publication.
This commit is contained in:
1 parent
b3208f2aaf
commit
a8b9a901e4
12 files changed
+541
-22
No files matched your search
@@ -131,3 +131,50 @@ export function createPaddedCounterLabel(
|
||||
source.offChanged(update);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the disjoint initial and retry chunk-fetch counts with the same
|
||||
* padding and inactive linger behaviour as the other status counters.
|
||||
*/
|
||||
export function createChunkFetchCounterLabel(
|
||||
source: ReactiveValue<{ initial: number; retrying: number }>
|
||||
): DisposableReactiveValue<string> {
|
||||
const initialCount = reactiveSource(0);
|
||||
const retryingCount = reactiveSource(0);
|
||||
const initialLabel = createPaddedCounterLabel(initialCount, "🛄");
|
||||
const retryingLabel = createPaddedCounterLabel(retryingCount, "🔁");
|
||||
const formatted = reactiveSource(`${initialLabel.value}${retryingLabel.value}`);
|
||||
let updatingCounts = false;
|
||||
let disposed = false;
|
||||
|
||||
const updateLabel = () => {
|
||||
if (updatingCounts || disposed) return;
|
||||
formatted.value = `${initialLabel.value}${retryingLabel.value}`;
|
||||
};
|
||||
initialLabel.onChanged(updateLabel);
|
||||
retryingLabel.onChanged(updateLabel);
|
||||
|
||||
const updateCounts = () => {
|
||||
if (disposed) return;
|
||||
updatingCounts = true;
|
||||
try {
|
||||
initialCount.value = source.value.initial;
|
||||
retryingCount.value = source.value.retrying;
|
||||
} finally {
|
||||
updatingCounts = false;
|
||||
updateLabel();
|
||||
}
|
||||
};
|
||||
source.onChanged(updateCounts);
|
||||
updateCounts();
|
||||
|
||||
return asDisposableReactiveValue(formatted, () => {
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
source.offChanged(updateCounts);
|
||||
initialLabel.offChanged(updateLabel);
|
||||
retryingLabel.offChanged(updateLabel);
|
||||
initialLabel.dispose();
|
||||
retryingLabel.dispose();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user