From ac25c9cd7f324166c9eb12bf80146c5aad4cccef Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Mon, 30 Jan 2023 13:55:38 +0000 Subject: [PATCH] accounts: Show "contact through" cog when only email is given" one portion of #233: When adding an email address to an account, the admin (for now) will manually have to enable its use by clicking the cog icon and enabling "contact through email". Only for now, currently some other unfinished work is stopping me from committing the other portion of code for this issue. --- router.go | 2 ++ ts/modules/accounts.ts | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/router.go b/router.go index 52ccf64..e84cc2e 100644 --- a/router.go +++ b/router.go @@ -192,6 +192,8 @@ func (app *appContext) loadRoutes(router *gin.Engine) { api.GET(p+"/telegram/pin", app.TelegramGetPin) api.GET(p+"/telegram/verified/:pin", app.TelegramVerified) api.POST(p+"/users/telegram", app.TelegramAddUser) + } + if emailEnabled { api.POST(p+"/users/contact", app.SetContactMethods) } if discordEnabled { diff --git a/ts/modules/accounts.ts b/ts/modules/accounts.ts index c4ce256..beb3dd5 100644 --- a/ts/modules/accounts.ts +++ b/ts/modules/accounts.ts @@ -74,9 +74,11 @@ class user implements User { const telegram = window.telegramEnabled && this._telegramUsername && this._telegramUsername != ""; const discord = window.discordEnabled && this._discordUsername && this._discordUsername != ""; const matrix = window.matrixEnabled && this._matrixID && this._matrixID != ""; + const email = window.emailEnabled && this.email != ""; if (discord) return "discord"; if (matrix) return "matrix"; if (telegram) return "telegram"; + if (email) return "email"; } get selected(): boolean { return this._selected; } @@ -132,6 +134,15 @@ class user implements User { } else { this._email.textContent = value; } + const lastNotifyMethod = this.lastNotifyMethod() == "email"; + if (!value) { + this._notifyDropdown.querySelector(".accounts-area-email").classList.add("unfocused"); + } else { + this._notifyDropdown.querySelector(".accounts-area-email").classList.remove("unfocused"); + if (lastNotifyMethod) { + (this._email.parentElement as HTMLDivElement).appendChild(this._notifyDropdown); + } + } } get notify_email(): boolean { return this._notifyEmail; } @@ -146,17 +157,20 @@ class user implements User { const telegram = this._telegramUsername != ""; const discord = this._discordUsername != ""; const matrix = this._matrixID != ""; - if (!telegram && !discord && !matrix) return; + const email = this._emailAddress != ""; + if (!telegram && !discord && !matrix && !email) return; let innerHTML = `