mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Fix infinite spinner in Subscriptions tab by correcting method context in NostrService and improving error resilience.
This commit is contained in:
1 parent
0fc78fefb8
commit
e63ca6eee3
1 file changed
+34
-19
+34
-19
@@ -157,6 +157,17 @@ function extractSnapshotPreview(message) {
|
||||
return sanitizeSnapshotPreview(selected || "");
|
||||
}
|
||||
|
||||
function getActiveKey(video) {
|
||||
if (video.videoRootId) {
|
||||
return `ROOT:${video.videoRootId}`;
|
||||
}
|
||||
const dTag = video.tags?.find((t) => Array.isArray(t) && t[0] === "d");
|
||||
if (dTag && typeof dTag[1] === "string") {
|
||||
return `${video.pubkey}:${dTag[1]}`;
|
||||
}
|
||||
return `LEGACY:${video.id}`;
|
||||
}
|
||||
|
||||
function resolveDirectMessageRemotePubkey(message, actorPubkey = "") {
|
||||
const normalizedActor = normalizeHexPubkey(actorPubkey);
|
||||
|
||||
@@ -1185,29 +1196,33 @@ export class NostrService {
|
||||
try {
|
||||
await Promise.all(
|
||||
this.nostrClient.relays.map(async (url) => {
|
||||
const events = await this.nostrClient.pool.list([url], [filter]);
|
||||
for (const evt of events) {
|
||||
if (evt && evt.id) {
|
||||
this.nostrClient.rawEvents.set(evt.id, evt);
|
||||
}
|
||||
const vid = convertEventToVideo(evt);
|
||||
if (vid.invalid) {
|
||||
invalidNotes.push({ id: vid.id, reason: vid.reason });
|
||||
} else {
|
||||
if (
|
||||
this.nostrClient &&
|
||||
typeof this.nostrClient.applyRootCreatedAt === "function"
|
||||
) {
|
||||
this.nostrClient.applyRootCreatedAt(vid);
|
||||
try {
|
||||
const events = await this.nostrClient.pool.list([url], [filter]);
|
||||
for (const evt of events) {
|
||||
if (evt && evt.id) {
|
||||
this.nostrClient.rawEvents.set(evt.id, evt);
|
||||
}
|
||||
const activeKey = getActiveKey(vid);
|
||||
if (vid.deleted) {
|
||||
this.recordTombstone(activeKey, vid.created_at);
|
||||
const vid = convertEventToVideo(evt);
|
||||
if (vid.invalid) {
|
||||
invalidNotes.push({ id: vid.id, reason: vid.reason });
|
||||
} else {
|
||||
this.applyTombstoneGuard(vid);
|
||||
if (
|
||||
this.nostrClient &&
|
||||
typeof this.nostrClient.applyRootCreatedAt === "function"
|
||||
) {
|
||||
this.nostrClient.applyRootCreatedAt(vid);
|
||||
}
|
||||
const activeKey = getActiveKey(vid);
|
||||
if (vid.deleted) {
|
||||
this.nostrClient.recordTombstone(activeKey, vid.created_at);
|
||||
} else {
|
||||
this.nostrClient.applyTombstoneGuard(vid);
|
||||
}
|
||||
localAll.set(evt.id, vid);
|
||||
}
|
||||
localAll.set(evt.id, vid);
|
||||
}
|
||||
} catch (relayErr) {
|
||||
// ignore relay failures
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user