mirror of
https://github.com/hoornet/vega.git
synced 2026-05-10 14:19:12 -07:00
Add subscription debug panel (Ctrl+Shift+D)
Hidden dev tool showing NDK uptime, live subscription status, per-relay connection state, per-tab last-updated timestamps, and recent feed diagnostics log. Polls every 2s while visible. Closes with Ctrl+Shift+D, Escape, or X button.
This commit is contained in:
@@ -32,6 +32,10 @@ function getLog(): DiagEntry[] {
|
||||
}
|
||||
}
|
||||
|
||||
export function getRecentDiagEntries(count = 5): DiagEntry[] {
|
||||
return getLog().slice(-count).reverse();
|
||||
}
|
||||
|
||||
function saveLog(entries: DiagEntry[]) {
|
||||
localStorage.setItem(DIAG_KEY, JSON.stringify(entries.slice(-MAX_ENTRIES)));
|
||||
}
|
||||
|
||||
@@ -57,16 +57,22 @@ export function saveRelayUrls(urls: string[]) {
|
||||
}
|
||||
|
||||
let ndk: NDK | null = null;
|
||||
let ndkCreatedAt: number | null = null;
|
||||
|
||||
export function getNDK(): NDK {
|
||||
if (!ndk) {
|
||||
ndk = new NDK({
|
||||
explicitRelayUrls: getStoredRelayUrls(),
|
||||
});
|
||||
ndkCreatedAt = Date.now();
|
||||
}
|
||||
return ndk;
|
||||
}
|
||||
|
||||
export function getNDKUptimeMs(): number | null {
|
||||
return ndkCreatedAt ? Date.now() - ndkCreatedAt : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the current NDK instance and create a fresh one.
|
||||
* Preserves the signer (login state) but resets all relay connections.
|
||||
@@ -87,6 +93,7 @@ export async function resetNDK(): Promise<void> {
|
||||
ndk = new NDK({
|
||||
explicitRelayUrls: getStoredRelayUrls(),
|
||||
});
|
||||
ndkCreatedAt = Date.now();
|
||||
|
||||
// Restore signer so user stays logged in
|
||||
if (oldSigner) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export { getNDK, connectToRelays, ensureConnected, resetNDK, getStoredRelayUrls, addRelay, removeRelay, fetchWithTimeout, withTimeout, FEED_TIMEOUT, THREAD_TIMEOUT, SINGLE_TIMEOUT } from "./core";
|
||||
export { getNDK, getNDKUptimeMs, connectToRelays, ensureConnected, resetNDK, getStoredRelayUrls, addRelay, removeRelay, fetchWithTimeout, withTimeout, FEED_TIMEOUT, THREAD_TIMEOUT, SINGLE_TIMEOUT } from "./core";
|
||||
export { fetchGlobalFeed, fetchFollowFeed, fetchUserNotes, fetchUserNotesNIP65, fetchNoteById, fetchReplies, publishNote, publishReply, publishRepost, publishQuote, fetchHashtagFeed, fetchThreadEvents, fetchAncestors } from "./notes";
|
||||
export { publishProfile, publishContactList, fetchProfile, fetchFollowSuggestions, fetchMentions, fetchNewFollowers } from "./social";
|
||||
export { publishArticle, fetchArticle, fetchAuthorArticles, fetchArticleFeed, searchArticles, fetchByAddr } from "./articles";
|
||||
|
||||
Reference in New Issue
Block a user