diff options
Diffstat (limited to 'subprojects/frontend/src/xtext/webSocketMachine.ts')
-rw-r--r-- | subprojects/frontend/src/xtext/webSocketMachine.ts | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/subprojects/frontend/src/xtext/webSocketMachine.ts b/subprojects/frontend/src/xtext/webSocketMachine.ts index 2fb1f52f..9113286f 100644 --- a/subprojects/frontend/src/xtext/webSocketMachine.ts +++ b/subprojects/frontend/src/xtext/webSocketMachine.ts | |||
@@ -27,6 +27,8 @@ export type WebSocketEvent = | |||
27 | | { type: 'PAGE_RESUME' } | 27 | | { type: 'PAGE_RESUME' } |
28 | | { type: 'ONLINE' } | 28 | | { type: 'ONLINE' } |
29 | | { type: 'OFFLINE' } | 29 | | { type: 'OFFLINE' } |
30 | | { type: 'GENERATION_STARTED' } | ||
31 | | { type: 'GENERATION_ENDED' } | ||
30 | | { type: 'ERROR'; message: string }; | 32 | | { type: 'ERROR'; message: string }; |
31 | 33 | ||
32 | export default createMachine( | 34 | export default createMachine( |
@@ -105,7 +107,7 @@ export default createMachine( | |||
105 | initial: 'opening', | 107 | initial: 'opening', |
106 | states: { | 108 | states: { |
107 | opening: { | 109 | opening: { |
108 | always: [{ target: '#timedOut', in: '#tabHidden' }], | 110 | always: [{ target: '#timedOut', in: '#mayDisconnect' }], |
109 | after: { | 111 | after: { |
110 | OPEN_TIMEOUT: { | 112 | OPEN_TIMEOUT: { |
111 | actions: 'raiseTimeoutError', | 113 | actions: 'raiseTimeoutError', |
@@ -143,7 +145,7 @@ export default createMachine( | |||
143 | initial: 'active', | 145 | initial: 'active', |
144 | states: { | 146 | states: { |
145 | active: { | 147 | active: { |
146 | always: [{ target: 'inactive', in: '#tabHidden' }], | 148 | always: [{ target: 'inactive', in: '#mayDisconnect' }], |
147 | }, | 149 | }, |
148 | inactive: { | 150 | inactive: { |
149 | always: [{ target: 'active', in: '#tabVisible' }], | 151 | always: [{ target: 'active', in: '#tabVisible' }], |
@@ -173,14 +175,44 @@ export default createMachine( | |||
173 | visibleOrUnknown: { | 175 | visibleOrUnknown: { |
174 | id: 'tabVisible', | 176 | id: 'tabVisible', |
175 | on: { | 177 | on: { |
176 | TAB_HIDDEN: 'hidden', | 178 | TAB_HIDDEN: [ |
179 | { target: 'hidden.mayDisconnect', in: '#generationIdle' }, | ||
180 | { target: 'hidden.keepAlive', in: '#generationRunning' }, | ||
181 | ], | ||
177 | }, | 182 | }, |
178 | }, | 183 | }, |
179 | hidden: { | 184 | hidden: { |
180 | id: 'tabHidden', | ||
181 | on: { | 185 | on: { |
182 | TAB_VISIBLE: 'visibleOrUnknown', | 186 | TAB_VISIBLE: 'visibleOrUnknown', |
183 | }, | 187 | }, |
188 | initial: 'mayDisconnect', | ||
189 | states: { | ||
190 | mayDisconnect: { | ||
191 | id: 'mayDisconnect', | ||
192 | always: { target: 'keepAlive', in: '#generationRunning' }, | ||
193 | }, | ||
194 | keepAlive: { | ||
195 | id: 'keepAlive', | ||
196 | always: { target: 'mayDisconnect', in: '#generationIdle' }, | ||
197 | }, | ||
198 | }, | ||
199 | }, | ||
200 | }, | ||
201 | }, | ||
202 | generation: { | ||
203 | initial: 'idle', | ||
204 | states: { | ||
205 | idle: { | ||
206 | id: 'generationIdle', | ||
207 | on: { | ||
208 | GENERATION_STARTED: 'running', | ||
209 | }, | ||
210 | }, | ||
211 | running: { | ||
212 | id: 'generationRunning', | ||
213 | on: { | ||
214 | GENERATION_ENDED: 'idle', | ||
215 | }, | ||
184 | }, | 216 | }, |
185 | }, | 217 | }, |
186 | }, | 218 | }, |