mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 12:22:28 +00:00
Add DM controls to profile modal
This commit is contained in:
1 parent
96f727ac54
commit
c70e17b9d0
2 files changed
+110
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user