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:
thePR0M3TH3AN authored and GitHub committed 2026-01-13 09:50:29 -05:00
commit 778b35874d
3 files changed
+24 -13

No files matched your search

+16 -11
View File
@@ -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
View File
@@ -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;
}
}
+6 -1
View File
@@ -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();