on main help sign in
refactor: move domain-specific type out of generic pubsub package
4261dfbChristian Rocha
internal/app/app.go+8−1
@@ -40,6 +40,13 @@ import (
40 "github.com/charmbracelet/x/term"
40 "github.com/charmbracelet/x/term"
41)
41)
42
42
43+// UpdateAvailableMsg is sent when a new version is available.
44+type UpdateAvailableMsg struct {
45+ CurrentVersion string
46+ LatestVersion string
47+ IsDevelopment bool
48+}
49+
43type App struct {
50type App struct {
44 Sessions session.Service
51 Sessions session.Service
45 Messages message.Service
52 Messages message.Service
@@ -452,7 +459,7 @@ func (app *App) checkForUpdates(ctx context.Context) {
452 if err != nil || !info.Available() {
459 if err != nil || !info.Available() {
453 return
460 return
454 }
461 }
455− app.events <- pubsub.UpdateAvailableMsg{
462+ app.events <- UpdateAvailableMsg{
456 CurrentVersion: info.Current,
463 CurrentVersion: info.Current,
457 LatestVersion: info.Latest,
464 LatestVersion: info.Latest,
458 IsDevelopment: info.IsDevelopment(),
465 IsDevelopment: info.IsDevelopment(),
internal/pubsub/events.go−7
@@ -26,10 +26,3 @@ type (
26 Publish(EventType, T)
26 Publish(EventType, T)
27 }
27 }
28)
28)
29−
30−// UpdateAvailableMsg is sent when a new version is available.
31−type UpdateAvailableMsg struct {
32− CurrentVersion string
33− LatestVersion string
34− IsDevelopment bool
35−}
internal/tui/tui.go+1−1
@@ -385,7 +385,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
385 }
385 }
386 return a, tea.Batch(cmds...)
386 return a, tea.Batch(cmds...)
387 // Update Available
387 // Update Available
388− case pubsub.UpdateAvailableMsg:
388+ case app.UpdateAvailableMsg:
389 // Show update notification in status bar
389 // Show update notification in status bar
390 statusMsg := fmt.Sprintf("Crush update available: v%s → v%s.", msg.CurrentVersion, msg.LatestVersion)
390 statusMsg := fmt.Sprintf("Crush update available: v%s → v%s.", msg.CurrentVersion, msg.LatestVersion)
391 if msg.IsDevelopment {
391 if msg.IsDevelopment {