From 77bc3bd38a2ec5f811d734bbfc69b7faecc28b91 Mon Sep 17 00:00:00 2001 From: Dmitrii Okunev Date: Sun, 15 Jun 2025 21:28:43 +0100 Subject: [PATCH] Fixes as a result of an actual test --- cmd/streampanel/FyneApp.toml | 2 +- pkg/chatmessagesstorage/get_messages_since.go | 1 + .../sort_and_deduplicate.go | 20 +++++++++---------- pkg/streampanel/chat.go | 3 +++ pkg/streampanel/color.go | 2 -- pkg/streampanel/dashboard.go | 6 ++++++ pkg/streampanel/panel.go | 1 + 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cmd/streampanel/FyneApp.toml b/cmd/streampanel/FyneApp.toml index 4cebe79..ce2270b 100755 --- a/cmd/streampanel/FyneApp.toml +++ b/cmd/streampanel/FyneApp.toml @@ -5,4 +5,4 @@ Website = "https://github.com/xaionaro/streamctl" Name = "streampanel" ID = "center.dx.streampanel" Version = "0.1.0" - Build = 374 + Build = 382 diff --git a/pkg/chatmessagesstorage/get_messages_since.go b/pkg/chatmessagesstorage/get_messages_since.go index 8cf958a..df2d6b5 100644 --- a/pkg/chatmessagesstorage/get_messages_since.go +++ b/pkg/chatmessagesstorage/get_messages_since.go @@ -30,6 +30,7 @@ func (s *ChatMessagesStorage) getMessagesSinceLocked( } if !s.IsSorted { + logger.Tracef(ctx, "not sorted, sorting") s.sortAndDeduplicateAndTruncate(ctx) } diff --git a/pkg/chatmessagesstorage/sort_and_deduplicate.go b/pkg/chatmessagesstorage/sort_and_deduplicate.go index 3dfc1fd..d937f7a 100644 --- a/pkg/chatmessagesstorage/sort_and_deduplicate.go +++ b/pkg/chatmessagesstorage/sort_and_deduplicate.go @@ -9,20 +9,20 @@ import ( ) func msgLess(ctx context.Context, a *api.ChatMessage, b *api.ChatMessage) bool { - if a.CreatedAt.Before(b.CreatedAt) { - return true + if a.CreatedAt != b.CreatedAt { + return a.CreatedAt.Before(b.CreatedAt) } - if a.Platform < b.Platform { - return true + if a.Platform != b.Platform { + return a.Platform < b.Platform } - if a.Username < b.Username { - return true + if a.Username != b.Username { + return a.Username < b.Username } - if a.MessageID < b.MessageID { - return true + if a.MessageID != b.MessageID { + return a.MessageID < b.MessageID } - if a.Message < b.Message { - return true + if a.Message != b.Message { + return a.Message < b.Message } if a != b { logger.Errorf(ctx, "msgs A and B look equal, but are not: A:%#+v B:%#+v", a, b) diff --git a/pkg/streampanel/chat.go b/pkg/streampanel/chat.go index e3f7363..1f29cfa 100644 --- a/pkg/streampanel/chat.go +++ b/pkg/streampanel/chat.go @@ -196,6 +196,9 @@ func (ui *chatUI) onReceiveMessage( defer ui.List.RefreshItem(prevLen) defer ui.MessagesHistoryLocker.ManualUnlock(ctx) ui.MessagesHistory = append(ui.MessagesHistory, msg) + if time.Since(msg.CreatedAt) > time.Hour { + return + } notificationsEnabled := xsync.DoR1(ctx, &ui.Panel.configLocker, func() bool { return ui.Panel.Config.Chat.NotificationsEnabled() }) diff --git a/pkg/streampanel/color.go b/pkg/streampanel/color.go index 570ddba..317b6d6 100644 --- a/pkg/streampanel/color.go +++ b/pkg/streampanel/color.go @@ -27,10 +27,8 @@ func colorForPlatform(platID streamcontrol.PlatformName) fyne.ThemeColorName { var brightColors = []fyne.ThemeColorName{ theme.ColorNameError, - theme.ColorNameForeground, theme.ColorNameHyperlink, theme.ColorNamePrimary, - theme.ColorNameSelection, theme.ColorNameSuccess, theme.ColorNameWarning, } diff --git a/pkg/streampanel/dashboard.go b/pkg/streampanel/dashboard.go index a4613af..d6c10c2 100644 --- a/pkg/streampanel/dashboard.go +++ b/pkg/streampanel/dashboard.go @@ -313,6 +313,10 @@ func (p *Panel) newDashboardWindow( c := w.chat.List w.chat.OnAdd = func(ctx context.Context, _ api.ChatMessage) { screenHeight := w.Canvas().Size().Height + switch runtime.GOOS { + case "android": + screenHeight -= 110 + } demandedHeight := float32(w.chat.TotalListHeight) + c.Theme().Size(theme.SizeNamePadding)*float32(c.Length()) logger.Tracef(ctx, "demanded height: %v; screen height: %v", demandedHeight, screenHeight) allowedHeight := math.Min( @@ -328,6 +332,8 @@ func (p *Panel) newDashboardWindow( c.ScrollToBottom() c.Refresh() + c.ScrollToBottom() + c.Refresh() } w.chat.OnAdd(ctx, api.ChatMessage{}) layers = append(layers, diff --git a/pkg/streampanel/panel.go b/pkg/streampanel/panel.go index c8aed44..a76429d 100644 --- a/pkg/streampanel/panel.go +++ b/pkg/streampanel/panel.go @@ -251,6 +251,7 @@ func (p *Panel) Loop(ctx context.Context, opts ...LoopOption) (_err error) { } p.app = fyneapp.New() + p.app.Settings().SetTheme(theme.DarkTheme()) p.app.Driver().SetDisableScreenBlanking(true) logger.Tracef(ctx, "SetDisableScreenBlanking(true)") p.createMainWindow(ctx)