mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Merge pull request #1201 from PR0M3TH3AN/fix-slow-loading-video-grid-7505675586453320961
Unblock video grid loading by backgrounding access control checks
This commit is contained in:
3 files changed
+24
-13
No files matched your search
@@ -494,7 +494,7 @@ class Application {
|
||||
})
|
||||
: Promise.resolve(null);
|
||||
|
||||
await Promise.all([accessControlPromise, adminPanePromise]);
|
||||
// await Promise.all([accessControlPromise, adminPanePromise]);
|
||||
|
||||
const syncSessionActorBlacklist = async (trigger) => {
|
||||
if (this.pubkey) {
|
||||
@@ -2698,17 +2698,15 @@ class Application {
|
||||
typeof reason === "string" && reason.trim() ? reason.trim() : undefined;
|
||||
|
||||
if (typeof moderationService?.awaitUserBlockRefresh === "function") {
|
||||
try {
|
||||
await moderationService.awaitUserBlockRefresh();
|
||||
} catch (error) {
|
||||
moderationService.awaitUserBlockRefresh().catch((error) => {
|
||||
const contextMessage = normalizedReason
|
||||
? ` before ${normalizedReason}`
|
||||
: "";
|
||||
? ` in background during ${normalizedReason}`
|
||||
: " in background";
|
||||
devLogger.warn(
|
||||
`Failed to sync moderation summaries${contextMessage}:`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -5359,10 +5357,17 @@ class Application {
|
||||
devLogger.log("Starting loadVideos... (forceFetch =", forceFetch, ")");
|
||||
|
||||
const container = this.mountVideoListView();
|
||||
if (this.videoListView && container) {
|
||||
this.videoListView.showLoading("Fetching recent videos…");
|
||||
} else if (container) {
|
||||
container.innerHTML = getSidebarLoadingMarkup("Fetching recent videos…");
|
||||
const hasCachedVideos =
|
||||
this.nostrService &&
|
||||
Array.isArray(this.nostrService.getFilteredActiveVideos()) &&
|
||||
this.nostrService.getFilteredActiveVideos().length > 0;
|
||||
|
||||
if (!hasCachedVideos) {
|
||||
if (this.videoListView && container) {
|
||||
this.videoListView.showLoading("Fetching recent videos…");
|
||||
} else if (container) {
|
||||
container.innerHTML = getSidebarLoadingMarkup("Fetching recent videos…");
|
||||
}
|
||||
}
|
||||
|
||||
let initialRefreshPromise = null;
|
||||
|
||||
+2
-1
@@ -5629,12 +5629,13 @@ export class NostrClient {
|
||||
|
||||
getLatestCachedCreatedAt() {
|
||||
let latest = 0;
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
|
||||
for (const video of this.allEvents.values()) {
|
||||
const createdAt = Number.isFinite(video?.created_at)
|
||||
? Math.floor(video.created_at)
|
||||
: 0;
|
||||
if (createdAt > latest) {
|
||||
if (createdAt > latest && createdAt <= now) {
|
||||
latest = createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1104,7 +1104,12 @@ export class NostrService {
|
||||
this.ensureInitialLoadDeferred();
|
||||
|
||||
try {
|
||||
await this.ensureAccessControlReady();
|
||||
this.ensureAccessControlReady().catch((error) => {
|
||||
userLogger.warn(
|
||||
"[nostrService] Background access control ready check failed:",
|
||||
error
|
||||
);
|
||||
});
|
||||
|
||||
if (forceFetch) {
|
||||
this.clearVideoSubscription();
|
||||
|
||||
Reference in new issue
Block a user