mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 12:22:28 +00:00
update
This commit is contained in:
1 parent
281a6511f1
commit
42edebcf6d
45 files changed
+8446
-1010
No files matched your search
+45
-12
@@ -132,6 +132,7 @@ class SubscriptionsManager {
|
||||
this.subscribedPubkeys = new Set();
|
||||
this.subsEventId = null;
|
||||
this.loaded = false;
|
||||
this.loadingPromise = null;
|
||||
this.subscriptionListView = null;
|
||||
this.lastRunOptions = null;
|
||||
this.lastResult = null;
|
||||
@@ -297,6 +298,35 @@ class SubscriptionsManager {
|
||||
}
|
||||
}
|
||||
|
||||
async ensureLoaded(actorHex) {
|
||||
if (this.loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedActor = normalizeHexPubkey(actorHex) || actorHex;
|
||||
if (!normalizedActor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.loadingPromise) {
|
||||
try {
|
||||
await this.loadingPromise;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const loader = this.loadSubscriptions(normalizedActor);
|
||||
this.loadingPromise = loader;
|
||||
|
||||
try {
|
||||
await loader;
|
||||
} finally {
|
||||
this.loadingPromise = null;
|
||||
}
|
||||
}
|
||||
|
||||
isSubscribed(channelHex) {
|
||||
const normalized = normalizeHexPubkey(channelHex);
|
||||
if (!normalized) {
|
||||
@@ -409,6 +439,7 @@ class SubscriptionsManager {
|
||||
if (!userPubkey) {
|
||||
throw new Error("No user pubkey => cannot addChannel.");
|
||||
}
|
||||
await this.ensureLoaded(userPubkey);
|
||||
if (!normalizedChannel) {
|
||||
devLogger.warn("Attempted to subscribe to invalid pubkey", channelHex);
|
||||
return;
|
||||
@@ -432,6 +463,7 @@ class SubscriptionsManager {
|
||||
if (!userPubkey) {
|
||||
throw new Error("No user pubkey => cannot removeChannel.");
|
||||
}
|
||||
await this.ensureLoaded(userPubkey);
|
||||
if (!normalizedChannel) {
|
||||
devLogger.warn("Attempted to remove invalid pubkey from subscriptions", channelHex);
|
||||
return;
|
||||
@@ -627,15 +659,13 @@ class SubscriptionsManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this.loaded) {
|
||||
try {
|
||||
await this.loadSubscriptions(userPubkey);
|
||||
} catch (error) {
|
||||
userLogger.error(
|
||||
"[SubscriptionsManager] Failed to load subscriptions while rendering feed:",
|
||||
error,
|
||||
);
|
||||
}
|
||||
try {
|
||||
await this.ensureLoaded(userPubkey);
|
||||
} catch (error) {
|
||||
userLogger.error(
|
||||
"[SubscriptionsManager] Failed to load subscriptions while rendering feed:",
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
const channelHexes = this.getSubscribedAuthors();
|
||||
@@ -1222,7 +1252,8 @@ class SubscriptionsManager {
|
||||
}
|
||||
app?.handleEditVideo?.({
|
||||
eventId: video.id,
|
||||
index: Number.isFinite(index) ? index : null
|
||||
index: Number.isFinite(index) ? index : null,
|
||||
video
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1232,7 +1263,8 @@ class SubscriptionsManager {
|
||||
}
|
||||
app?.handleRevertVideo?.({
|
||||
eventId: video.id,
|
||||
index: Number.isFinite(index) ? index : null
|
||||
index: Number.isFinite(index) ? index : null,
|
||||
video
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1242,7 +1274,8 @@ class SubscriptionsManager {
|
||||
}
|
||||
app?.handleFullDeleteVideo?.({
|
||||
eventId: video.id,
|
||||
index: Number.isFinite(index) ? index : null
|
||||
index: Number.isFinite(index) ? index : null,
|
||||
video
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user