diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-09-13 20:08:55 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-09-13 20:08:55 +0200 |
commit | fbd86a7cc3c791a161f150f3e2a07d7432a5b39c (patch) | |
tree | a42840026fc3f574d1b027804fcb70c7d28609de /subprojects/frontend/src/xtext/XtextClient.ts | |
parent | refactor: do not construct uneeded interpretation (diff) | |
download | refinery-fbd86a7cc3c791a161f150f3e2a07d7432a5b39c.tar.gz refinery-fbd86a7cc3c791a161f150f3e2a07d7432a5b39c.tar.zst refinery-fbd86a7cc3c791a161f150f3e2a07d7432a5b39c.zip |
fix(frontend): keep live while model generation
Do not close the connection in a background tab if the model generation is still
running, because closing the connection will immediately cancel generation.
Diffstat (limited to 'subprojects/frontend/src/xtext/XtextClient.ts')
-rw-r--r-- | subprojects/frontend/src/xtext/XtextClient.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/subprojects/frontend/src/xtext/XtextClient.ts b/subprojects/frontend/src/xtext/XtextClient.ts index 77980d35..4df4f57a 100644 --- a/subprojects/frontend/src/xtext/XtextClient.ts +++ b/subprojects/frontend/src/xtext/XtextClient.ts | |||
@@ -9,6 +9,7 @@ import type { | |||
9 | CompletionResult, | 9 | CompletionResult, |
10 | } from '@codemirror/autocomplete'; | 10 | } from '@codemirror/autocomplete'; |
11 | import type { Transaction } from '@codemirror/state'; | 11 | import type { Transaction } from '@codemirror/state'; |
12 | import { type IReactionDisposer, reaction } from 'mobx'; | ||
12 | 13 | ||
13 | import type PWAStore from '../PWAStore'; | 14 | import type PWAStore from '../PWAStore'; |
14 | import type EditorStore from '../editor/EditorStore'; | 15 | import type EditorStore from '../editor/EditorStore'; |
@@ -43,6 +44,8 @@ export default class XtextClient { | |||
43 | 44 | ||
44 | private readonly modelGenerationService: ModelGenerationService; | 45 | private readonly modelGenerationService: ModelGenerationService; |
45 | 46 | ||
47 | private readonly keepAliveDisposer: IReactionDisposer; | ||
48 | |||
46 | constructor( | 49 | constructor( |
47 | private readonly store: EditorStore, | 50 | private readonly store: EditorStore, |
48 | private readonly pwaStore: PWAStore, | 51 | private readonly pwaStore: PWAStore, |
@@ -65,6 +68,11 @@ export default class XtextClient { | |||
65 | store, | 68 | store, |
66 | this.updateService, | 69 | this.updateService, |
67 | ); | 70 | ); |
71 | this.keepAliveDisposer = reaction( | ||
72 | () => store.generating, | ||
73 | (generating) => this.webSocketClient.setKeepAlive(generating), | ||
74 | { fireImmediately: true }, | ||
75 | ); | ||
68 | } | 76 | } |
69 | 77 | ||
70 | start(): void { | 78 | start(): void { |
@@ -157,6 +165,7 @@ export default class XtextClient { | |||
157 | } | 165 | } |
158 | 166 | ||
159 | dispose(): void { | 167 | dispose(): void { |
168 | this.keepAliveDisposer(); | ||
160 | this.webSocketClient.disconnect(); | 169 | this.webSocketClient.disconnect(); |
161 | } | 170 | } |
162 | } | 171 | } |