mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-11 07:12:36 +00:00
fix(nostr): prevent list data loss on fetch failure and optimize login timeout
- Update `fetchListIncrementally` in `js/nostr/client.js` to throw an error if all relays fail, preventing empty returns from being interpreted as data loss. - Update `HashtagPreferencesService`, `UserBlockListManager`, and `SubscriptionsManager` to handle fetch errors gracefully without wiping local state. - Update `js/nostr/nip07Permissions.js` to use a short timeout (3s) for experimental permission requests, fixing "clunky" login issues while preserving user interaction time for standard login. - Remove `try/catch` in `adminListStore.js` fetch logic to allow error propagation to the fallback cache logic. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
fd6301ba7c
commit
9d820c27e9
5 files changed
+57
-35
No files matched your search
+16
-23
@@ -548,29 +548,22 @@ async function fetchLatestListEvent(filter, contextLabel = "admin-list") {
|
||||
}
|
||||
|
||||
let events = [];
|
||||
try {
|
||||
if (pubkey) {
|
||||
events = await nostrClient.fetchListIncrementally({
|
||||
kind,
|
||||
pubkey,
|
||||
dTag,
|
||||
relayUrls: relays
|
||||
});
|
||||
} else {
|
||||
// Fallback for non-specific queries
|
||||
const normalizedFilter = {
|
||||
kinds: [kind],
|
||||
limit: 50
|
||||
};
|
||||
if (dTag) normalizedFilter["#d"] = [dTag];
|
||||
if (filter.authors) normalizedFilter.authors = filter.authors;
|
||||
events = await nostrClient.pool.list(relays, [normalizedFilter]);
|
||||
}
|
||||
} catch (error) {
|
||||
devLogger.warn(
|
||||
`[adminListStore] Fetch failed for ${contextLabel}:`,
|
||||
error,
|
||||
);
|
||||
if (pubkey) {
|
||||
events = await nostrClient.fetchListIncrementally({
|
||||
kind,
|
||||
pubkey,
|
||||
dTag,
|
||||
relayUrls: relays
|
||||
});
|
||||
} else {
|
||||
// Fallback for non-specific queries
|
||||
const normalizedFilter = {
|
||||
kinds: [kind],
|
||||
limit: 50
|
||||
};
|
||||
if (dTag) normalizedFilter["#d"] = [dTag];
|
||||
if (filter.authors) normalizedFilter.authors = filter.authors;
|
||||
events = await nostrClient.pool.list(relays, [normalizedFilter]);
|
||||
}
|
||||
|
||||
if (!events || !events.length) {
|
||||
|
||||
Reference in new issue
Block a user