Add DM controls to profile modal

This commit is contained in:
thePR0M3TH3AN committed 2026-01-18 23:44:54 -05:00
1 parent 96f727ac54
commit c70e17b9d0
2 files changed
+110

No files matched your search

+53
View File
@@ -1012,6 +1012,59 @@
<p class="text-sm text-muted">
View encrypted conversations sent with NIP-04 or NIP-44. bitvid keeps message data on this device only.
</p>
<div class="card space-y-4 p-4">
<div class="flex flex-wrap items-start justify-between gap-3">
<div class="space-y-1">
<h3 class="text-sm font-semibold text-text">Direct message actions</h3>
<p class="text-xs text-muted">
Start a new DM or jump to relay preferences before you send.
</p>
</div>
<button
id="profileMessagesSendDm"
type="button"
class="btn focus-ring inline-flex items-center gap-2"
data-size="sm"
>
Send DM
</button>
</div>
<div class="flex flex-wrap items-center justify-between gap-3 border-t border-border/60 pt-3">
<div class="space-y-1">
<h4 class="text-xs font-semibold text-text">Preferred DM relay</h4>
<p class="text-xs text-muted">
Select a relay to prioritize encrypted message delivery.
</p>
</div>
<button
id="profileMessagesOpenRelays"
type="button"
class="btn-ghost focus-ring inline-flex items-center gap-2"
data-size="sm"
>
Manage relays
</button>
</div>
<div class="flex flex-wrap items-center justify-between gap-3 border-t border-border/60 pt-3">
<div class="space-y-1">
<h4 class="text-xs font-semibold text-text">Privacy mode (coming soon)</h4>
<p class="text-xs text-muted">
Pause inbound DM sync and clear cached previews on this device.
</p>
</div>
<label
for="profileMessagesPrivacyToggle"
class="inline-flex items-center gap-2 text-xs font-medium text-muted-strong"
>
<input
id="profileMessagesPrivacyToggle"
type="checkbox"
class="checkbox"
/>
Enable
</label>
</div>
</div>
<div
id="profileMessagesStatus"
class="sr-only"
+57
View File
@@ -1020,6 +1020,9 @@ export class ProfileModalController {
onAdminNotifyError: callbacks.onAdminNotifyError || noop,
onModerationSettingsChange:
callbacks.onModerationSettingsChange || noop,
onSendDm: callbacks.onSendDm || noop,
onTogglePrivacy: callbacks.onTogglePrivacy || noop,
onOpenRelays: callbacks.onOpenRelays || noop,
};
this.profileModal = null;
@@ -1103,6 +1106,9 @@ export class ProfileModalController {
this.profileMessageInput = null;
this.profileMessageSendButton = null;
this.profileMessagesComposerHelper = null;
this.profileMessagesSendDmButton = null;
this.profileMessagesOpenRelaysButton = null;
this.profileMessagesPrivacyToggle = null;
this.walletUriInput = null;
this.walletDefaultZapInput = null;
this.walletSaveButton = null;
@@ -1364,6 +1370,12 @@ export class ProfileModalController {
document.getElementById("profileMessageSendBtn") || null;
this.profileMessagesComposerHelper =
document.getElementById("profileMessagesComposerHelper") || null;
this.profileMessagesSendDmButton =
document.getElementById("profileMessagesSendDm") || null;
this.profileMessagesOpenRelaysButton =
document.getElementById("profileMessagesOpenRelays") || null;
this.profileMessagesPrivacyToggle =
document.getElementById("profileMessagesPrivacyToggle") || null;
if (this.pendingMessagesRender) {
const { messages, actorPubkey } = this.pendingMessagesRender;
@@ -2044,6 +2056,30 @@ export class ProfileModalController {
}
}
handleSendDmRequest() {
const callback = this.callbacks.onSendDm;
if (callback && callback !== noop) {
callback({
actorPubkey: this.resolveActiveDmActor(),
controller: this,
});
}
}
handleOpenDmRelaysRequest() {
const callback = this.callbacks.onOpenRelays;
if (callback && callback !== noop) {
callback({ controller: this });
}
}
handlePrivacyToggle(enabled) {
const callback = this.callbacks.onTogglePrivacy;
if (callback && callback !== noop) {
callback({ controller: this, enabled: Boolean(enabled) });
}
}
describeDirectMessageSendError(code) {
switch (code) {
case "sign-event-unavailable":
@@ -2804,6 +2840,27 @@ export class ProfileModalController {
});
}
if (this.profileMessagesSendDmButton instanceof HTMLElement) {
this.profileMessagesSendDmButton.addEventListener("click", () => {
this.handleSendDmRequest();
});
}
if (this.profileMessagesOpenRelaysButton instanceof HTMLElement) {
this.profileMessagesOpenRelaysButton.addEventListener("click", () => {
this.handleOpenDmRelaysRequest();
});
}
if (this.profileMessagesPrivacyToggle instanceof HTMLElement) {
this.profileMessagesPrivacyToggle.addEventListener("change", (event) => {
const toggle = event.currentTarget;
if (toggle instanceof HTMLInputElement) {
this.handlePrivacyToggle(toggle.checked);
}
});
}
if (this.profileMessageSendButton instanceof HTMLElement) {
this.profileMessageSendButton.addEventListener("click", () => {
void this.handleSendProfileMessage();