@@ -43,7 +43,6 @@ type SpeakerNotesModel struct {
43
43
syncClient * SyncClient
44
44
slideChangeChan chan int
45
45
connectionStatus ConnectionStatus
46
- reconnecting bool
47
46
}
48
47
49
48
type SlideChangeMsg struct {
@@ -67,28 +66,26 @@ func NewSpeakerNotes(rootSlide *Slide) SpeakerNotesModel {
67
66
slide = slide .Next
68
67
}
69
68
70
- // Create sync client to connect to the main presentation
69
+ // Attempt to create a sync client to connect to the main presentation
71
70
syncClient , err := NewSyncClient ()
71
+
72
+ var status ConnectionStatus
72
73
if err != nil {
73
74
slog .Warn ("Failed to connect to sync server - run the main presentation first" , "error" , err )
74
- syncClient = nil
75
+ status = StatusDisconnectedWaiting
76
+ } else {
77
+ status = StatusConnected
75
78
}
76
79
77
80
// Create buffered channel for slide changes
78
81
slideChangeChan := make (chan int , 10 )
79
82
80
- status := StatusConnected
81
- if syncClient == nil {
82
- status = StatusDisconnectedWaiting
83
- }
84
-
85
83
return SpeakerNotesModel {
86
84
currentSlide : 0 ,
87
85
slides : slides ,
88
86
syncClient : syncClient ,
89
87
slideChangeChan : slideChangeChan ,
90
88
connectionStatus : status ,
91
- reconnecting : false ,
92
89
}
93
90
}
94
91
@@ -167,15 +164,13 @@ func (m SpeakerNotesModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
167
164
return m , m .waitForSlideChange ()
168
165
case ReconnectAttemptMsg :
169
166
m .connectionStatus = StatusReconnecting
170
- m .reconnecting = true
171
167
// Wait a bit before trying again
172
168
return m , tea .Tick (time .Millisecond * 200 , func (time.Time ) tea.Msg {
173
169
return m .attemptReconnect ()()
174
170
})
175
171
case ReconnectedMsg :
176
172
m .syncClient = msg .Client
177
173
m .connectionStatus = StatusConnected
178
- m .reconnecting = false
179
174
// Start listening for slide changes again
180
175
go m .listenForSlideChangesWithReconnect ()
181
176
return m , m .waitForSlideChange ()
0 commit comments