@@ -33,6 +33,7 @@ type Model struct {
33
33
allClusterNamespaces []model.ClusterNamespaces
34
34
width , height int
35
35
initialized bool
36
+ stylesLoaded bool
36
37
gotFirstContainers bool
37
38
seenFirstContainer bool
38
39
toast toast.Model
@@ -69,6 +70,7 @@ func InitialModel(c Config) Model {
69
70
func (m Model ) Init () (tea.Model , tea.Cmd ) {
70
71
return m , tea .Batch (
71
72
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 {} }),
72
74
tea .RequestForegroundColor ,
73
75
tea .RequestBackgroundColor ,
74
76
)
@@ -83,11 +85,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
83
85
84
86
// handle these regardless of m.err
85
87
switch msg := msg .(type ) {
88
+ case tea.KeyMsg :
89
+ if key .Matches (msg , m .keyMap .Quit ) {
90
+ return m , m .cleanupCmd ()
91
+ }
92
+
86
93
case message.CleanupCompleteMsg :
87
94
return m , tea .Quit
88
-
89
- case tea.KeyMsg :
90
- return m .handleKeyMsg (msg )
91
95
}
92
96
93
97
if m .err != nil {
@@ -98,6 +102,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
98
102
switch msg := msg .(type ) {
99
103
case message.ErrMsg :
100
104
m .err = msg .Err
105
+ return m , nil
101
106
102
107
case tea.BackgroundColorMsg :
103
108
m .termStyleData .SetBackground (msg )
@@ -113,6 +118,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
113
118
}
114
119
return m , nil
115
120
121
+ case message.CheckStylesLoadedMsg :
122
+ if ! m .stylesLoaded {
123
+ m .setStyles (style .DefaultStyles )
124
+ }
125
+ return m , nil
126
+
116
127
// WindowSizeMsg arrives once on startup, then again every time the window is resized
117
128
case tea.WindowSizeMsg :
118
129
m .width , m .height = msg .Width , msg .Height
@@ -128,6 +139,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
128
139
m .syncDimensions ()
129
140
return m , tea .Batch (cmds ... )
130
141
142
+ case tea.KeyMsg :
143
+ return m .handleKeyMsg (msg )
144
+
131
145
case message.AttemptUpdateSinceTimeMsg :
132
146
m , cmd = m .attemptUpdateSinceTime ()
133
147
cmds = append (cmds , cmd )
@@ -397,10 +411,6 @@ func (m Model) handleKeyMsg(msg tea.KeyMsg) (Model, tea.Cmd) {
397
411
var cmd tea.Cmd
398
412
var cmds []tea.Cmd
399
413
400
- if key .Matches (msg , m .keyMap .Quit ) {
401
- return m , m .cleanupCmd ()
402
- }
403
-
404
414
if ! m .initialized {
405
415
return m , nil
406
416
}
@@ -1086,6 +1096,7 @@ func (m *Model) setFullscreen(fullscreen bool) {
1086
1096
1087
1097
func (m * Model ) setStyles (styles style.Styles ) {
1088
1098
m .styles = styles
1099
+ m .stylesLoaded = true
1089
1100
m .pages [page .EntitiesPageType ] = m .pages [page .EntitiesPageType ].WithStyles (styles )
1090
1101
m .pages [page .LogsPageType ] = m .pages [page .LogsPageType ].WithStyles (styles )
1091
1102
m .pages [page .SingleLogPageType ] = m .pages [page .SingleLogPageType ].WithStyles (styles )
0 commit comments