commit 1e9c468c5090e9d1b131dc1be1663d2cc9efa03c
parent 8f2c7f616e5244c37be4603aa7890bec02b153fd
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 25 Dec 2023 14:10:25 -0500
cleanup
Diffstat:
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/pkg/utils/rwmtx/rwmtx.go b/pkg/utils/rwmtx/rwmtx.go
@@ -109,6 +109,14 @@ type RWMtxSlice[T any] struct {
RWMtx[[]T]
}
+func (s *RWMtxSlice[T]) Each(clb func(T)) {
+ s.RWith(func(v []T) {
+ for _, e := range v {
+ clb(e)
+ }
+ })
+}
+
func (s *RWMtxSlice[T]) Append(els ...T) {
s.With(func(v *[]T) { *v = append(*v, els...) })
}
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1717,22 +1717,11 @@ func BuildBaseHtml(g *Game, authUser *database.User, chatRoomSlug string) (html
html += `<iframe src="/poker/` + roomID.String() + `/logs" id="eventLogs"></iframe>`
if ongoing != nil {
-
- ongoing.waitTurnEvent.RWith(func(v PokerWaitTurnEvent) {
- html += drawCountDownStyle(v)
- })
- ongoing.autoActionEvent.RWith(func(v AutoActionEvent) {
- html += drawAutoActionMsgEvent(v)
- })
-
- ongoing.events.RWith(func(v []PokerEvent) {
- for _, evt := range v {
- if evt.UserID == 0 {
- html += getPokerEventHtml(evt, "0s")
- }
- if evt.UserID == authUser.ID {
- html += getPokerEventHtml(evt, "0s")
- }
+ html += drawCountDownStyle(ongoing.waitTurnEvent.Get())
+ html += drawAutoActionMsgEvent(ongoing.autoActionEvent.Get())
+ ongoing.events.Each(func(evt PokerEvent) {
+ if evt.UserID == 0 || evt.UserID == authUser.ID {
+ html += getPokerEventHtml(evt, "0s")
}
})
}