@@ -198,48 +198,50 @@ export const onOperationApplied: Action<{
198198 }
199199} ;
200200
201- export const codeChanged : Action < {
201+ export const codeChanged : AsyncAction < {
202202 moduleShortid : string ;
203203 code : string ;
204204 event ?: any ;
205- } > = ( { effects, state, actions } , { code, event, moduleShortid } ) => {
206- effects . analytics . trackOnce ( 'Change Code' ) ;
205+ } > = withOwnedSandbox (
206+ async ( { effects, state, actions } , { code, event, moduleShortid } ) => {
207+ effects . analytics . trackOnce ( 'Change Code' ) ;
207208
208- if ( ! state . editor . currentSandbox ) {
209- return ;
210- }
209+ if ( ! state . editor . currentSandbox ) {
210+ return ;
211+ }
211212
212- const module = state . editor . currentSandbox . modules . find (
213- m => m . shortid === moduleShortid
214- ) ;
213+ const module = state . editor . currentSandbox . modules . find (
214+ m => m . shortid === moduleShortid
215+ ) ;
215216
216- if ( ! module ) {
217- return ;
218- }
217+ if ( ! module ) {
218+ return ;
219+ }
219220
220- if ( state . live . isLive ) {
221- const operation = event
222- ? eventToTransform ( event , module . code ) . operation
223- : getTextOperation ( module . code , code ) ;
221+ if ( state . live . isLive ) {
222+ const operation = event
223+ ? eventToTransform ( event , module . code ) . operation
224+ : getTextOperation ( module . code , code ) ;
224225
225- effects . live . sendCodeUpdate ( moduleShortid , operation ) ;
226- }
226+ effects . live . sendCodeUpdate ( moduleShortid , operation ) ;
227+ }
227228
228- actions . editor . internal . setModuleCode ( {
229- module,
230- code,
231- } ) ;
229+ actions . editor . internal . setModuleCode ( {
230+ module,
231+ code,
232+ } ) ;
232233
233- const { isServer } = getTemplate ( state . editor . currentSandbox . template ) ;
234+ const { isServer } = getTemplate ( state . editor . currentSandbox . template ) ;
234235
235- if ( ! isServer && state . preferences . settings . livePreviewEnabled ) {
236- actions . editor . internal . updatePreviewCode ( ) ;
237- }
236+ if ( ! isServer && state . preferences . settings . livePreviewEnabled ) {
237+ actions . editor . internal . updatePreviewCode ( ) ;
238+ }
238239
239- if ( module . savedCode !== null && module . code === module . savedCode ) {
240- effects . vscode . revertModule ( module ) ;
240+ if ( module . savedCode !== null && module . code === module . savedCode ) {
241+ effects . vscode . revertModule ( module ) ;
242+ }
241243 }
242- } ;
244+ ) ;
243245
244246export const saveClicked : AsyncAction = withOwnedSandbox (
245247 async ( { state, effects, actions } ) => {
0 commit comments