@@ -33,6 +33,7 @@ type Model struct {
3333 allClusterNamespaces []model.ClusterNamespaces
3434 width , height int
3535 initialized bool
36+ stylesLoaded bool
3637 gotFirstContainers bool
3738 seenFirstContainer bool
3839 toast toast.Model
@@ -69,6 +70,7 @@ func InitialModel(c Config) Model {
6970func (m Model ) Init () (tea.Model , tea.Cmd ) {
7071 return m , tea .Batch (
7172 tea .Tick (constants .BatchUpdateLogsInterval , func (t time.Time ) tea.Msg { return message.BatchUpdateLogsMsg {} }),
73+ tea .Tick (constants .CheckStylesLoadedDuration , func (t time.Time ) tea.Msg { return message.CheckStylesLoadedMsg {} }),
7274 tea .RequestForegroundColor ,
7375 tea .RequestBackgroundColor ,
7476 )
@@ -83,11 +85,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8385
8486 // handle these regardless of m.err
8587 switch msg := msg .(type ) {
88+ case tea.KeyMsg :
89+ if key .Matches (msg , m .keyMap .Quit ) {
90+ return m , m .cleanupCmd ()
91+ }
92+
8693 case message.CleanupCompleteMsg :
8794 return m , tea .Quit
88-
89- case tea.KeyMsg :
90- return m .handleKeyMsg (msg )
9195 }
9296
9397 if m .err != nil {
@@ -98,6 +102,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
98102 switch msg := msg .(type ) {
99103 case message.ErrMsg :
100104 m .err = msg .Err
105+ return m , nil
101106
102107 case tea.BackgroundColorMsg :
103108 m .termStyleData .SetBackground (msg )
@@ -113,6 +118,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
113118 }
114119 return m , nil
115120
121+ case message.CheckStylesLoadedMsg :
122+ if ! m .stylesLoaded {
123+ m .setStyles (style .DefaultStyles )
124+ }
125+ return m , nil
126+
116127 // WindowSizeMsg arrives once on startup, then again every time the window is resized
117128 case tea.WindowSizeMsg :
118129 m .width , m .height = msg .Width , msg .Height
@@ -128,6 +139,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
128139 m .syncDimensions ()
129140 return m , tea .Batch (cmds ... )
130141
142+ case tea.KeyMsg :
143+ return m .handleKeyMsg (msg )
144+
131145 case message.AttemptUpdateSinceTimeMsg :
132146 m , cmd = m .attemptUpdateSinceTime ()
133147 cmds = append (cmds , cmd )
@@ -397,10 +411,6 @@ func (m Model) handleKeyMsg(msg tea.KeyMsg) (Model, tea.Cmd) {
397411 var cmd tea.Cmd
398412 var cmds []tea.Cmd
399413
400- if key .Matches (msg , m .keyMap .Quit ) {
401- return m , m .cleanupCmd ()
402- }
403-
404414 if ! m .initialized {
405415 return m , nil
406416 }
@@ -1086,6 +1096,7 @@ func (m *Model) setFullscreen(fullscreen bool) {
10861096
10871097func (m * Model ) setStyles (styles style.Styles ) {
10881098 m .styles = styles
1099+ m .stylesLoaded = true
10891100 m .pages [page .EntitiesPageType ] = m .pages [page .EntitiesPageType ].WithStyles (styles )
10901101 m .pages [page .LogsPageType ] = m .pages [page .LogsPageType ].WithStyles (styles )
10911102 m .pages [page .SingleLogPageType ] = m .pages [page .SingleLogPageType ].WithStyles (styles )
0 commit comments