@@ -91,11 +91,16 @@ func openURL(ctx context.Context, rawURL string) error {
9191 return nil
9292}
9393
94+ // PRCounts represents PR count information.
95+ type PRCounts struct {
96+ IncomingTotal int
97+ IncomingBlocked int
98+ OutgoingTotal int
99+ OutgoingBlocked int
100+ }
101+
94102// countPRs counts the number of PRs that need review/are blocked.
95- // Returns: incomingCount, incomingBlocked, outgoingCount, outgoingBlocked
96- //
97- //nolint:revive,gocritic // 4 return values is clearer than a struct here
98- func (app * App ) countPRs () (int , int , int , int ) {
103+ func (app * App ) countPRs () PRCounts {
99104 app .mu .RLock ()
100105 defer app .mu .RUnlock ()
101106
@@ -122,23 +127,28 @@ func (app *App) countPRs() (int, int, int, int) {
122127 }
123128 }
124129 }
125- return incomingCount , incomingBlocked , outgoingCount , outgoingBlocked
130+ return PRCounts {
131+ IncomingTotal : incomingCount ,
132+ IncomingBlocked : incomingBlocked ,
133+ OutgoingTotal : outgoingCount ,
134+ OutgoingBlocked : outgoingBlocked ,
135+ }
126136}
127137
128138// setTrayTitle updates the system tray title based on PR counts.
129139func (app * App ) setTrayTitle () {
130- _ , incomingBlocked , _ , outgoingBlocked := app .countPRs ()
140+ counts := app .countPRs ()
131141
132142 // Set title based on PR state
133143 switch {
134- case incomingBlocked == 0 && outgoingBlocked == 0 :
144+ case counts . IncomingBlocked == 0 && counts . OutgoingBlocked == 0 :
135145 systray .SetTitle ("😊" )
136- case incomingBlocked > 0 && outgoingBlocked > 0 :
137- systray .SetTitle (fmt .Sprintf ("👀 %d 🎉 %d" , incomingBlocked , outgoingBlocked ))
138- case incomingBlocked > 0 :
139- systray .SetTitle (fmt .Sprintf ("👀 %d" , incomingBlocked ))
146+ case counts . IncomingBlocked > 0 && counts . OutgoingBlocked > 0 :
147+ systray .SetTitle (fmt .Sprintf ("👀 %d 🎉 %d" , counts . IncomingBlocked , counts . OutgoingBlocked ))
148+ case counts . IncomingBlocked > 0 :
149+ systray .SetTitle (fmt .Sprintf ("👀 %d" , counts . IncomingBlocked ))
140150 default :
141- systray .SetTitle (fmt .Sprintf ("🎉 %d" , outgoingBlocked ))
151+ systray .SetTitle (fmt .Sprintf ("🎉 %d" , counts . OutgoingBlocked ))
142152 }
143153}
144154
@@ -213,17 +223,6 @@ func (app *App) addPRSection(ctx context.Context, prs []PR, sectionTitle string,
213223 }
214224}
215225
216- // initializeMenu creates the initial menu structure.
217- func (app * App ) initializeMenu (ctx context.Context ) {
218- log .Print ("[MENU] Initializing menu structure" )
219-
220- // Build the entire menu
221- app .rebuildMenu (ctx )
222-
223- app .menuInitialized = true
224- log .Print ("[MENU] Menu initialization complete" )
225- }
226-
227226// rebuildMenu completely rebuilds the menu from scratch.
228227func (app * App ) rebuildMenu (ctx context.Context ) {
229228 log .Print ("[MENU] Rebuilding entire menu" )
@@ -246,30 +245,30 @@ func (app *App) rebuildMenu(ctx context.Context) {
246245 systray .AddSeparator ()
247246
248247 // Get PR counts
249- incomingCount , incomingBlocked , outgoingCount , outgoingBlocked := app .countPRs ()
248+ counts := app .countPRs ()
250249
251250 // Handle "No pull requests" case
252- if incomingCount == 0 && outgoingCount == 0 {
251+ if counts . IncomingTotal == 0 && counts . OutgoingTotal == 0 {
253252 log .Print ("[MENU] Creating 'No pull requests' item" )
254253 noPRs := systray .AddMenuItem ("No pull requests" , "" )
255254 noPRs .Disable ()
256255 } else {
257256 // Incoming section
258- if incomingCount > 0 {
257+ if counts . IncomingTotal > 0 {
259258 app .mu .RLock ()
260259 incoming := app .incoming
261260 app .mu .RUnlock ()
262- app .addPRSection (ctx , incoming , "Incoming" , incomingBlocked )
261+ app .addPRSection (ctx , incoming , "Incoming" , counts . IncomingBlocked )
263262 }
264263
265264 systray .AddSeparator ()
266265
267266 // Outgoing section
268- if outgoingCount > 0 {
267+ if counts . OutgoingTotal > 0 {
269268 app .mu .RLock ()
270269 outgoing := app .outgoing
271270 app .mu .RUnlock ()
272- app .addPRSection (ctx , outgoing , "Outgoing" , outgoingBlocked )
271+ app .addPRSection (ctx , outgoing , "Outgoing" , counts . OutgoingBlocked )
273272 }
274273 }
275274
0 commit comments