commit a8f2842581d503249542897db4c9079160366f8d
parent c04795e599839ec2400ce3769a23174016bbec93
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 18 Feb 2024 22:22:08 -0800
toggle display alive indicator setting
Diffstat:
6 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/cmd/dkf/migrations/162.sql b/cmd/dkf/migrations/162.sql
@@ -0,0 +1,4 @@
+-- +migrate Up
+ALTER TABLE users ADD COLUMN display_alive_indicator TINYINT(1) NOT NULL DEFAULT 1;
+
+-- +migrate Down
diff --git a/pkg/database/tableUsers.go b/pkg/database/tableUsers.go
@@ -44,6 +44,7 @@ type IUserRenderMessage interface {
GetAFK() bool
GetAfkIndicatorEnabled() bool
GetDisplayIgnored() bool
+ GetDisplayAliveIndicator() bool
GetDisplayModerators() bool
GetNotifyNewMessage() bool
GetNotifyTagged() bool
@@ -98,6 +99,7 @@ type User struct {
HellbanOpacity int64
CodeBlockHeight int64
DisplayIgnored bool
+ DisplayAliveIndicator bool
HideIgnoredUsersFromList bool
Verified bool
Temp bool // Temporary account
@@ -177,6 +179,7 @@ func (u *User) GetIsHellbanned() bool { return u.IsHellbanned }
func (u *User) GetAFK() bool { return u.AFK }
func (u *User) GetAfkIndicatorEnabled() bool { return u.AfkIndicatorEnabled }
func (u *User) GetDisplayIgnored() bool { return u.DisplayIgnored }
+func (u *User) GetDisplayAliveIndicator() bool { return u.DisplayAliveIndicator }
func (u *User) GetDisplayModerators() bool { return u.DisplayModerators }
func (u *User) GetNotifyNewMessage() bool { return u.NotifyNewMessage }
func (u *User) GetNotifyTagged() bool { return u.NotifyTagged }
@@ -822,6 +825,7 @@ func (d *DkfDB) createUser(usernameStr, password, repassword, gpgPublicKey strin
newUser.RegistrationDuration = registrationDuration
newUser.UseStream = true
newUser.UseStreamMenu = true
+ newUser.DisplayAliveIndicator = true
newUser.CodeBlockHeight = 300
newUser.HellbanOpacity = 30
newUser.SignupMetadata = signupInfoEnc
diff --git a/pkg/web/handlers/api/v1/chat.go b/pkg/web/handlers/api/v1/chat.go
@@ -151,7 +151,9 @@ func ChatStreamMessagesHandler(c echo.Context) error {
data.ChatMenuData.RoomName = room.Name
data.ManualRefreshTimeout = 0
send(GenerateStyle(authUser, data))
- send(`<div id="i"></div>`) // http alive indicator; green/red dot
+ if authUser.DisplayAliveIndicator {
+ send(`<div id="i"></div>`) // http alive indicator; green/red dot
+ }
send(fmt.Sprintf(`<div style="display:flex;flex-direction:column-reverse;" id="msgs">`))
// Get initial messages for the user
@@ -260,7 +262,9 @@ Loop:
db.UpdateChatReadRecord(authUser1.GetID(), room.ID)
// Toggle the "http alive indicator" class to keep the dot green
- send(indicatorAlt.alternate())
+ if authUser1.GetDisplayAliveIndicator() {
+ send(indicatorAlt.alternate())
+ }
topic, msgTyp, err := sub.ReceiveTimeout2(5*time.Second, streamItem.Quit)
if err != nil {
diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go
@@ -678,6 +678,7 @@ type settingsChatData struct {
DisplayHellbanButton bool
UseStream bool
UseStreamMenu bool
+ DisplayAliveIndicator bool
ManualMultiline bool
ConfirmExternalLinks bool
ChessSoundsEnabled bool
diff --git a/pkg/web/handlers/settings.go b/pkg/web/handlers/settings.go
@@ -66,6 +66,7 @@ func SettingsChatHandler(c echo.Context) error {
data.NotifyChessMove = authUser.NotifyChessMove
data.UseStream = authUser.UseStream
data.UseStreamMenu = authUser.UseStreamMenu
+ data.DisplayAliveIndicator = authUser.DisplayAliveIndicator
data.ConfirmExternalLinks = authUser.ConfirmExternalLinks
data.ChessSoundsEnabled = authUser.ChessSoundsEnabled
data.PokerSoundsEnabled = authUser.PokerSoundsEnabled
@@ -116,6 +117,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error {
data.NotifyChessMove = utils.DoParseBool(c.Request().PostFormValue("notify_chess_move"))
data.UseStream = utils.DoParseBool(c.Request().PostFormValue("use_stream"))
data.UseStreamMenu = utils.DoParseBool(c.Request().PostFormValue("use_stream_menu"))
+ data.DisplayAliveIndicator = utils.DoParseBool(c.Request().PostFormValue("display_alive_indicator"))
data.ConfirmExternalLinks = utils.DoParseBool(c.Request().PostFormValue("confirm_external_links"))
data.ChessSoundsEnabled = utils.DoParseBool(c.Request().PostFormValue("chess_sounds_enabled"))
data.PokerSoundsEnabled = utils.DoParseBool(c.Request().PostFormValue("poker_sounds_enabled"))
@@ -164,6 +166,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error {
authUser.NotifyChessMove = data.NotifyChessMove
authUser.UseStream = data.UseStream
authUser.UseStreamMenu = data.UseStreamMenu
+ authUser.DisplayAliveIndicator = data.DisplayAliveIndicator
authUser.ConfirmExternalLinks = data.ConfirmExternalLinks
authUser.ChessSoundsEnabled = data.ChessSoundsEnabled
authUser.PokerSoundsEnabled = data.PokerSoundsEnabled
diff --git a/pkg/web/public/views/pages/settings/chat.gohtml b/pkg/web/public/views/pages/settings/chat.gohtml
@@ -212,6 +212,13 @@
</div>
<div class="form-check form-check-1">
<div class="checkbox-wrapper form-check-input">
+ <input class="my-cbx" type="checkbox" name="display_alive_indicator" id="display_alive_indicator" value="1"{{ if .Data.DisplayAliveIndicator }} checked{{ end }} />
+ <label for="display_alive_indicator" class="toggle"><span></span></label>
+ </div>
+ <label class="form-check-label" for="display_alive_indicator">{{ t "Display alive indicator" . }}</label>
+ </div>
+ <div class="form-check form-check-1">
+ <div class="checkbox-wrapper form-check-input">
<input class="my-cbx" type="checkbox" name="confirm_external_links" id="confirm_external_links" value="1"{{ if .AuthUser.ConfirmExternalLinks }} checked{{ end }} />
<label for="confirm_external_links" class="toggle"><span></span></label>
</div>