commit 1d813bcf5bf7ffde6f27bd236d9ea96e1c2f45ab
parent 2270ee918ce0ee8c3f446d60e3733789e3d03453
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 14 Dec 2023 20:55:39 -0500
enable/disable poker sounds
Diffstat:
6 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/cmd/dkf/migrations/152.sql b/cmd/dkf/migrations/152.sql
@@ -0,0 +1,4 @@
+-- +migrate Up
+ALTER TABLE users ADD COLUMN poker_sounds_enabled TINYINT(1) NOT NULL DEFAULT 0;
+
+-- +migrate Down
diff --git a/pkg/database/tableUsers.go b/pkg/database/tableUsers.go
@@ -129,6 +129,7 @@ type User struct {
SyntaxHighlightCode string
ConfirmExternalLinks bool
ChessSoundsEnabled bool
+ PokerSoundsEnabled bool
PokerXmrSubAddress string
HighlightOwnMessages bool `gorm:"-"`
}
diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go
@@ -676,6 +676,7 @@ type settingsChatData struct {
ManualMultiline bool
ConfirmExternalLinks bool
ChessSoundsEnabled bool
+ PokerSoundsEnabled bool
NotifyChessGames bool
NotifyChessMove bool
NotifyNewMessage bool
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1374,7 +1374,7 @@ func buildDevHtml() (html string) {
func buildPayloadHtml(g *PokerGame, authUser *database.User, payload any) (html string) {
switch evt := payload.(type) {
case GameStartedEvent:
- html += drawGameStartedEvent(evt)
+ html += drawGameStartedEvent(evt, authUser)
case GameIsDoneEvent:
html += drawGameIsDoneHtml(g, evt)
case PlayerBetEvent:
@@ -1392,7 +1392,7 @@ func buildPayloadHtml(g *PokerGame, authUser *database.User, payload any) (html
case PokerWaitTurnEvent:
html += drawCountDownStyle(evt)
case PokerYourTurnEvent:
- html += drawYourTurnHtml()
+ html += drawYourTurnHtml(authUser)
case PokerEvent:
html += getPokerEventHtml(evt, "1s")
case PokerMainPotUpdatedEvent:
@@ -1620,10 +1620,12 @@ func drawPlayerBetEvent(evt PlayerBetEvent) (html string) {
return
}
-func drawGameStartedEvent(evt GameStartedEvent) (html string) {
+func drawGameStartedEvent(evt GameStartedEvent, authUser *database.User) (html string) {
pos := dealerTokenPos[evt.DealerSeatIdx]
html += `<style>#dealerToken { top: ` + itoa(pos[0]) + `px; left: ` + itoa(pos[1]) + `px; }</style>`
- html += `<audio src="/public/mp3/shuffle_cards.mp3" autoplay></audio>`
+ if authUser.PokerSoundsEnabled {
+ html += `<audio src="/public/mp3/shuffle_cards.mp3" autoplay></audio>`
+ }
return
}
@@ -1661,8 +1663,10 @@ func drawResetCardsEvent() (html string) {
return
}
-func drawYourTurnHtml() (html string) {
- html += `<audio src="/public/mp3/sound7.mp3" autoplay></audio>`
+func drawYourTurnHtml(authUser *database.User) (html string) {
+ if authUser.PokerSoundsEnabled {
+ html += `<audio src="/public/mp3/sound7.mp3" autoplay></audio>`
+ }
return
}
diff --git a/pkg/web/handlers/settings.go b/pkg/web/handlers/settings.go
@@ -67,6 +67,7 @@ func SettingsChatHandler(c echo.Context) error {
data.UseStream = authUser.UseStream
data.ConfirmExternalLinks = authUser.ConfirmExternalLinks
data.ChessSoundsEnabled = authUser.ChessSoundsEnabled
+ data.PokerSoundsEnabled = authUser.PokerSoundsEnabled
data.ManualMultiline = authUser.ManualMultiline
if c.Request().Method == http.MethodGet {
@@ -115,6 +116,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error {
data.UseStream = utils.DoParseBool(c.Request().PostFormValue("use_stream"))
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"))
data.HellbanOpacity = utils.DoParseF64(c.Request().PostFormValue("hellban_opacity"))
data.CodeBlockHeight = utils.DoParseInt64(c.Request().PostFormValue("code_block_height"))
data.ManualMultiline = utils.DoParseBool(c.Request().PostFormValue("manual_multiline"))
@@ -161,6 +163,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error {
authUser.UseStream = data.UseStream
authUser.ConfirmExternalLinks = data.ConfirmExternalLinks
authUser.ChessSoundsEnabled = data.ChessSoundsEnabled
+ authUser.PokerSoundsEnabled = data.PokerSoundsEnabled
authUser.Theme = data.Theme
//authUser.NotifyNewMessageSound = data.NotifyNewMessageSound
//authUser.NotifyTaggedSound = data.NotifyTaggedSound
diff --git a/pkg/web/public/views/pages/settings/chat.gohtml b/pkg/web/public/views/pages/settings/chat.gohtml
@@ -217,6 +217,13 @@
</div>
<label class="form-check-label" for="chess_sounds_enabled">Enabled chess sounds</label>
</div>
+ <div class="form-check form-check-1">
+ <div class="checkbox-wrapper form-check-input">
+ <input class="my-cbx" type="checkbox" name="poker_sounds_enabled" id="poker_sounds_enabled" value="1"{{ if .AuthUser.PokerSoundsEnabled }} checked{{ end }} />
+ <label for="poker_sounds_enabled" class="toggle"><span></span></label>
+ </div>
+ <label class="form-check-label" for="poker_sounds_enabled">Enabled poker sounds</label>
+ </div>
{{ if $.AuthUser.IsModerator }}
<div class="form-check form-check-1">
<div class="checkbox-wrapper form-check-input">