Merge pull request #1907 from PR0M3TH3AN/codex/handle-no-pubkey-case-in-profilemodalcontroller

profileModal: show signer-required empty state for blocked list when signed out
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-28 16:50:27 -05:00
commit 2a5fa3ef90
1 file changed
+50 -32
+50 -32
View File
@@ -1592,6 +1592,10 @@ export class ProfileModalController {
this.blockList = document.getElementById("blockedList") || null;
this.blockListEmpty = document.getElementById("blockedEmpty") || null;
this.blockListEmptyDefaultText =
this.blockListEmpty instanceof HTMLElement
? this.blockListEmpty.textContent.trim()
: "";
this.blockInput = document.getElementById("blockedInput") || null;
this.addBlockedButton = document.getElementById("addBlockedBtn") || null;
@@ -8035,10 +8039,10 @@ export class ProfileModalController {
return;
}
const sourceEntries =
Array.isArray(blocked) && blocked.length
? blocked
: this.services.userBlocks.getBlockedPubkeys();
const hasExplicitList = Array.isArray(blocked);
const sourceEntries = hasExplicitList
? blocked
: this.services.userBlocks.getBlockedPubkeys();
const normalizedEntries = [];
const pushEntry = (hex, label) => {
@@ -12710,40 +12714,54 @@ export class ProfileModalController {
if (hasBlockHydrator) {
const activeHex = this.normalizeHexPubkey(this.getActivePubkey());
backgroundTasks.push(
Promise.resolve()
.then(() => this.services.userBlocks.ensureLoaded(activeHex))
.then(() => {
try {
this.populateBlockedList();
} catch (error) {
if (!activeHex) {
this.setBlockListLoadingState("idle");
if (this.blockListEmpty instanceof HTMLElement) {
this.blockListEmpty.textContent =
"Connect a Nostr signer to load your mute list.";
}
this.populateBlockedList([]);
} else {
if (this.blockListEmpty instanceof HTMLElement) {
this.blockListEmpty.textContent =
this.blockListEmptyDefaultText ||
"You haven’t blocked any creators yet.";
}
backgroundTasks.push(
Promise.resolve()
.then(() => this.services.userBlocks.ensureLoaded(activeHex))
.then(() => {
try {
this.populateBlockedList();
} catch (error) {
userLogger.warn(
"Failed to render blocked creators after hydration:",
error,
);
this.setBlockListLoadingState("error", {
message: "Blocked creators may be out of date. Try again later.",
});
}
})
.catch((error) => {
userLogger.warn(
"Failed to render blocked creators after hydration:",
"Failed to refresh user block list while opening profile modal:",
error,
);
this.setBlockListLoadingState("error", {
message: "Blocked creators may be out of date. Try again later.",
});
}
})
.catch((error) => {
userLogger.warn(
"Failed to refresh user block list while opening profile modal:",
error,
);
this.setBlockListLoadingState("error", {
message: "Blocked creators may be out of date. Try again later.",
});
try {
this.populateBlockedList();
} catch (populateError) {
userLogger.warn(
"Failed to render blocked creators after hydration failure:",
populateError,
);
}
}),
);
try {
this.populateBlockedList();
} catch (populateError) {
userLogger.warn(
"Failed to render blocked creators after hydration failure:",
populateError,
);
}
}),
);
}
}
if (backgroundTasks.length) {