Skip to content

Commit bbfb3a7

Browse files
committed
lint cleanup
1 parent 5f3c067 commit bbfb3a7

File tree

3 files changed

+41
-45
lines changed

3 files changed

+41
-45
lines changed

github.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,9 @@ func (*App) githubToken(ctx context.Context) (string, error) {
119119
return token, nil
120120
}
121121

122-
// fetchPRs retrieves all PRs involving the current user.
123-
// It returns GitHub data immediately and starts Turn API queries in the background.
124-
func (app *App) fetchPRs(ctx context.Context) (incoming []PR, outgoing []PR, err error) {
125-
return app.fetchPRsInternal(ctx, false)
126-
}
127-
128-
// fetchPRsWithWait fetches PRs and waits for Turn data to complete.
129-
func (app *App) fetchPRsWithWait(ctx context.Context) (incoming []PR, outgoing []PR, err error) {
130-
return app.fetchPRsInternal(ctx, true)
131-
}
132-
133-
// fetchPRsInternal is the common implementation for PR fetching.
122+
// fetchPRsInternal is the implementation for PR fetching.
123+
// It returns GitHub data immediately and starts Turn API queries in the background (when waitForTurn=false),
124+
// or waits for Turn data to complete (when waitForTurn=true).
134125
func (app *App) fetchPRsInternal(ctx context.Context, waitForTurn bool) (incoming []PR, outgoing []PR, err error) {
135126
// Use targetUser if specified, otherwise use authenticated user
136127
user := app.currentUser.GetLogin()

main.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (app *App) updateLoop(ctx context.Context) {
280280
}
281281

282282
func (app *App) updatePRs(ctx context.Context) {
283-
incoming, outgoing, err := app.fetchPRs(ctx)
283+
incoming, outgoing, err := app.fetchPRsInternal(ctx, false)
284284
if err != nil {
285285
log.Printf("Error fetching PRs: %v", err)
286286
app.mu.Lock()
@@ -531,7 +531,7 @@ func (app *App) updateMenuIfChanged(ctx context.Context) {
531531

532532
// updatePRsWithWait fetches PRs and waits for Turn data before building initial menu.
533533
func (app *App) updatePRsWithWait(ctx context.Context) {
534-
incoming, outgoing, err := app.fetchPRsWithWait(ctx)
534+
incoming, outgoing, err := app.fetchPRsInternal(ctx, true)
535535
if err != nil {
536536
log.Printf("Error fetching PRs: %v", err)
537537
app.mu.Lock()
@@ -566,7 +566,10 @@ func (app *App) updatePRsWithWait(ctx context.Context) {
566566
// Still create initial menu even on error
567567
if !app.menuInitialized {
568568
log.Println("Creating initial menu despite error")
569-
app.initializeMenu(ctx)
569+
log.Print("[MENU] Initializing menu structure")
570+
app.rebuildMenu(ctx)
571+
app.menuInitialized = true
572+
log.Print("[MENU] Menu initialization complete")
570573
}
571574
return
572575
}
@@ -645,7 +648,10 @@ func (app *App) updatePRsWithWait(ctx context.Context) {
645648
// Create initial menu after first successful data load
646649
if !app.menuInitialized {
647650
log.Println("Creating initial menu with Turn data")
648-
app.initializeMenu(ctx)
651+
log.Print("[MENU] Initializing menu structure")
652+
app.rebuildMenu(ctx)
653+
app.menuInitialized = true
654+
log.Print("[MENU] Menu initialization complete")
649655
} else {
650656
app.updateMenuIfChanged(ctx)
651657
}

ui.go

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
129139
func (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.
228227
func (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

Comments
 (0)