mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-27 23:13:03 +00:00
Protect bounded remote activity across app lifecycle
This commit is contained in:
@@ -31,6 +31,7 @@ import { LogPaneView, VIEW_TYPE_LOG } from "./Log/LogPaneView.ts";
|
||||
import { serialized } from "octagonal-wheels/concurrency/lock";
|
||||
import { $msg } from "@lib/common/i18n.ts";
|
||||
import { P2PLogCollector } from "@lib/replication/trystero/P2PLogCollector.ts";
|
||||
import { hasRemoteActivity } from "./RemoteActivityStatus.ts";
|
||||
import type { LiveSyncCore } from "@/main.ts";
|
||||
import { LiveSyncError } from "@lib/common/LSError.ts";
|
||||
import { isValidPath } from "@/common/utils.ts";
|
||||
@@ -152,8 +153,13 @@ export class ModuleLog extends AbstractObsidianModule {
|
||||
const queueCountLabel = () => queueCountLabelX.value;
|
||||
|
||||
const requestingStatLabel = computed(() => {
|
||||
const diff = this.services.API.requestCount.value - this.services.API.responseCount.value;
|
||||
return diff != 0 ? "📲 " : "";
|
||||
return hasRemoteActivity(
|
||||
this.services.API.requestCount.value,
|
||||
this.services.API.responseCount.value,
|
||||
this.services.replicator.boundedRemoteActivityCount.value
|
||||
)
|
||||
? "📲 "
|
||||
: "";
|
||||
});
|
||||
|
||||
const replicationStatLabel = computed(() => {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { hasRemoteActivity } from "./RemoteActivityStatus.ts";
|
||||
|
||||
describe("hasRemoteActivity", () => {
|
||||
it("preserves the existing HTTP request balance signal", () => {
|
||||
expect(hasRemoteActivity(2, 1, 0)).toBe(true);
|
||||
expect(hasRemoteActivity(2, 2, 0)).toBe(false);
|
||||
});
|
||||
|
||||
it("reports bounded remote activity without an HTTP request imbalance", () => {
|
||||
expect(hasRemoteActivity(2, 2, 1)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
/** Returns whether the status UI should report HTTP traffic or a finite remote operation in progress. */
|
||||
export function hasRemoteActivity(requestCount: number, responseCount: number, boundedRemoteActivityCount: number) {
|
||||
return requestCount - responseCount !== 0 || boundedRemoteActivityCount !== 0;
|
||||
}
|
||||
Reference in New Issue
Block a user