Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

diagnosticsSetting.ts

19 lines724 Bytes

1// Start off until the saved connection-traces preference loads.
2let sending = false;
3let changedSinceLoad = false;
4​
5export const connectionTracesEnabled = () => sending;
6export function setConnectionTracesEnabled(enabled: boolean): void {
7 changedSinceLoad = true;
8 sending = enabled;
9}
10​
11// Imported lazily so the persistence graph never runs ahead of the imports `index.ts` orders first.
12void import("../../persistence/imperative")
13 .then(({ loadPreferences }) => loadPreferences())
14 .then((preferences) => {
15 if (!changedSinceLoad) sending = preferences.connectionTracesEnabled !== false;
16 })
17 .catch((error: unknown) => {
18 console.warn("[tracing] could not read the connection traces setting", error);
19 });