Merge pull request #1123 from PR0M3TH3AN/fix-profile-lists-sync-9443704948998622735

Fix profile menu list syncing and population issues
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-07 14:40:44 -05:00
commit 375b96bfa9
3 files changed
+75 -25

No files matched your search

+28 -21
View File
@@ -51,12 +51,13 @@ function escapeSelector(value) {
return value.replace(/([^a-zA-Z0-9_-])/g, "\\$1");
}
function resolveElement(selector) {
function resolveElement(selector, root = document) {
if (!selector || typeof selector !== "string") {
return null;
}
const scope = root && typeof root.querySelector === "function" ? root : document;
try {
return document.querySelector(selector);
return scope.querySelector(selector);
} catch (error) {
userLogger.warn("[historyView] Failed to query selector:", selector, error);
return null;
@@ -1373,6 +1374,7 @@ export function buildHistoryCard({ item, video, profile }) {
export function createWatchHistoryRenderer(config = {}) {
const {
container = typeof document !== "undefined" ? document : null,
fetchHistory = async (
actorInput,
{ cursor = 0, forceRefresh = false } = {}
@@ -1500,26 +1502,27 @@ export function createWatchHistoryRenderer(config = {}) {
const subscriptions = new Set();
function refreshElements() {
const scope = container || document;
elements = {
view: resolveElement(viewSelector),
grid: resolveElement(gridSelector),
loading: resolveElement(loadingSelector),
status: resolveElement(statusSelector),
empty: resolveElement(emptySelector),
sentinel: resolveElement(sentinelSelector),
loadMore: resolveElement(loadMoreSelector),
clearButton: resolveElement(clearButtonSelector),
republishButton: resolveElement(republishButtonSelector),
refreshButton: resolveElement(refreshButtonSelector),
privacyBanner: resolveElement(privacyBannerSelector),
privacyMessage: resolveElement(privacyMessageSelector),
privacyToggle: resolveElement(privacyToggleSelector),
privacyDismiss: resolveElement(privacyDismissSelector),
info: resolveElement(infoSelector),
errorBanner: resolveElement(errorBannerSelector),
scrollContainer: resolveElement(scrollContainerSelector),
featureBanner: resolveElement(featureBannerSelector),
sessionWarning: resolveElement(sessionWarningSelector)
view: resolveElement(viewSelector, scope),
grid: resolveElement(gridSelector, scope),
loading: resolveElement(loadingSelector, scope),
status: resolveElement(statusSelector, scope),
empty: resolveElement(emptySelector, scope),
sentinel: resolveElement(sentinelSelector, scope),
loadMore: resolveElement(loadMoreSelector, scope),
clearButton: resolveElement(clearButtonSelector, scope),
republishButton: resolveElement(republishButtonSelector, scope),
refreshButton: resolveElement(refreshButtonSelector, scope),
privacyBanner: resolveElement(privacyBannerSelector, scope),
privacyMessage: resolveElement(privacyMessageSelector, scope),
privacyToggle: resolveElement(privacyToggleSelector, scope),
privacyDismiss: resolveElement(privacyDismissSelector, scope),
info: resolveElement(infoSelector, scope),
errorBanner: resolveElement(errorBannerSelector, scope),
scrollContainer: resolveElement(scrollContainerSelector, scope),
featureBanner: resolveElement(featureBannerSelector, scope),
sessionWarning: resolveElement(sessionWarningSelector, scope)
};
}
@@ -2409,6 +2412,10 @@ export function createWatchHistoryRenderer(config = {}) {
await this.init(options);
return;
}
if (options.actor !== state.actor) {
await this.refresh(options);
return;
}
refreshElements();
updateFeatureBanner();
if (!state.featureEnabled) {
+15 -3
View File
@@ -224,6 +224,7 @@ class SubscriptionsManager {
constructor() {
this.subscribedPubkeys = new Set();
this.subsEventId = null;
this.currentUserPubkey = null;
this.loaded = false;
this.loadingPromise = null;
this.subscriptionListView = null;
@@ -379,19 +380,30 @@ class SubscriptionsManager {
const normalized = parseSubscriptionPlaintext(decryptedStr);
this.subscribedPubkeys = new Set(normalized);
this.currentUserPubkey = normalizedUserPubkey;
this.loaded = true;
} catch (err) {
userLogger.error("[SubscriptionsManager] Failed to load subs:", err);
}
}
reset() {
this.subscribedPubkeys.clear();
this.subsEventId = null;
this.currentUserPubkey = null;
this.loaded = false;
this.lastRunOptions = null;
this.lastResult = null;
this.hasRenderedOnce = false;
}
async ensureLoaded(actorHex) {
if (this.loaded) {
const normalizedActor = normalizeHexPubkey(actorHex) || actorHex;
if (!normalizedActor) {
return;
}
const normalizedActor = normalizeHexPubkey(actorHex) || actorHex;
if (!normalizedActor) {
if (this.loaded && this.currentUserPubkey === normalizedActor) {
return;
}
+32 -1
View File
@@ -1156,6 +1156,20 @@ export class ProfileModalController {
throw new Error("profile modal container missing");
}
// Invalidate any stale renderer reference so it is recreated
// with the freshly loaded DOM elements.
if (this.profileHistoryRenderer) {
try {
if (typeof this.profileHistoryRenderer.destroy === "function") {
this.profileHistoryRenderer.destroy();
}
} catch (err) {
devLogger.warn("[profileModal] Failed to destroy stale history renderer:", err);
}
this.profileHistoryRenderer = null;
this.profileHistoryRendererConfig = null;
}
const response = await fetch("components/profile-modal.html");
if (!response.ok) {
throw new Error(`Failed to load profile modal HTML (${response.status})`);
@@ -1460,7 +1474,10 @@ export class ProfileModalController {
const config = this.getProfileHistoryRendererConfig();
try {
this.profileHistoryRenderer = this.createWatchHistoryRenderer(config);
this.profileHistoryRenderer = this.createWatchHistoryRenderer({
...config,
container: this.profileModalPanel || this.profileModalRoot,
});
} catch (error) {
userLogger.error(
"[profileModal] Failed to create watch history renderer:",
@@ -8828,6 +8845,20 @@ export class ProfileModalController {
userLogger.warn("Failed to refresh admin pane after logout:", error);
}
if (
this.subscriptionsService &&
typeof this.subscriptionsService.reset === "function"
) {
try {
this.subscriptionsService.reset();
} catch (error) {
devLogger.warn(
"[profileModal] Failed to reset subscriptions service on logout:",
error,
);
}
}
this.populateBlockedList();
this.clearSubscriptionsList();
this.clearFriendsList();