Merge pull request #2087 from PR0M3TH3AN/fix/dm-relay-warning-ux-11833564790445768236

Fix annoying DM relay warning and clarify settings UI
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-04 11:18:49 -05:00
commit 610146c0aa
3 files changed
+35 -5

No files matched your search

+5 -5
View File
@@ -62,16 +62,16 @@
<!-- Relay Hints -->
<section class="space-y-4">
<div class="space-y-1">
<h3 class="text-base font-semibold text-text">DM Relay Hints</h3>
<h3 class="text-base font-semibold text-text">NIP-17 Relay List</h3>
<p class="text-sm text-muted">
Publish relay hints for direct messages as <span class="font-medium">kind:10050</span> events. Use WSS-only relay URLs so encrypted DM delivery stays secure.
Publish your NIP-17 relay list for direct messages as <span class="font-medium">kind:10050</span> events. Use WSS-only relay URLs so encrypted DM delivery stays secure.
</p>
</div>
<div class="card p-5 space-y-5">
<div class="flex flex-col gap-3 sm:flex-row sm:items-end">
<label class="flex-1 text-sm text-muted-strong" for="dmSettingsRelayInput">
<span class="mb-2 block font-medium">Add a DM relay</span>
<span class="mb-2 block font-medium">Add a NIP-17 relay</span>
<input
id="dmSettingsRelayInput"
type="text"
@@ -91,13 +91,13 @@
<span class="text-xs font-medium text-muted-strong uppercase tracking-wider">Your list</span>
</div>
<ul id="dmSettingsRelayList" class="grid-stack space-y-2" data-orientation="vertical"></ul>
<p id="dmSettingsRelayEmpty" class="text-sm text-muted italic hidden">No DM relay hints configured.</p>
<p id="dmSettingsRelayEmpty" class="text-sm text-muted italic hidden">No NIP-17 relays configured.</p>
</div>
<div class="flex flex-wrap items-center justify-between gap-3 pt-2 border-t border-border/40">
<span id="dmSettingsRelayStatus" class="text-xs text-muted" role="status" aria-live="polite"></span>
<button id="dmSettingsRelayPublishBtn" type="button" class="btn-ghost focus-ring text-xs">
Publish relay hints
Publish relay list
</button>
</div>
</div>
+7
View File
@@ -1042,6 +1042,7 @@ export class ProfileModalController {
this.adminSuperNpub = resolvedAdminSuperNpub;
this.adminDmImageUrl = resolvedAdminDmImageUrl;
this.bitvidWebsiteUrl = resolvedbitvidWebsiteUrl;
this.hasShownRelayWarning = false;
this.internalState = {
savedProfiles: [],
@@ -2795,6 +2796,7 @@ export class ProfileModalController {
? this.normalizeHexPubkey(actorPubkey)
: this.resolveActiveDmActor();
this.hasShownRelayWarning = false;
this.setDirectMessageRecipient(null, { reason: "clear" });
this.resetAttachmentQueue({ clearInput: true });
this.dmReadReceiptCache.clear();
@@ -5374,6 +5376,11 @@ export class ProfileModalController {
return;
}
if (this.hasShownRelayWarning) {
return;
}
this.hasShownRelayWarning = true;
this.showStatus(
"Privacy warning: direct messages are using your default relays because no NIP-17 relay list is available.",
{ autoHideMs: 5000 },
+23
View File
@@ -1307,3 +1307,26 @@ test('history pane lazily initializes the watch history renderer', async () => {
assert.equal(controller.profileHistoryRenderer, null);
assert.equal(controller.boundProfileHistoryVisibility, null);
});
test('handleDirectMessagesRelayWarning throttles status updates', async (t) => {
const statusCalls = [];
const controller = createController({
showStatus: (message) => statusCalls.push(message),
});
await controller.load();
const detail = { warning: 'dm-relays-fallback' };
controller.handleDirectMessagesRelayWarning(detail);
assert.equal(statusCalls.length, 1);
assert.match(statusCalls[0], /Privacy warning/);
// Second call should be suppressed
controller.handleDirectMessagesRelayWarning(detail);
assert.equal(statusCalls.length, 1);
// Reset should allow it again
controller.handleActiveDmIdentityChanged('newpubkey');
controller.handleDirectMessagesRelayWarning(detail);
assert.equal(statusCalls.length, 2);
});