File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
packages/app/src/app/overmind/namespaces/editor Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import {
3232import { convertAuthorizationToPermissionType } from 'app/utils/authorization' ;
3333import { clearCorrectionsFromAction } from 'app/utils/corrections' ;
3434import history from 'app/utils/history' ;
35+ import { getSavedCode } from 'app/overmind/utils/sandbox' ;
3536import { json } from 'overmind' ;
3637
3738import eventToTransform from '../../utils/event-to-transform' ;
@@ -88,6 +89,20 @@ export const sandboxChanged: AsyncAction<{ id: string }> = withLoadApp<{
8889 state . editor . currentSandbox
8990 ) ;
9091
92+ // We now need to send all dirty files that came over from the last sandbox.
93+ // There is the scenario where you edit a file and press fork. Then the server
94+ // doesn't know about how you got to that dirty state.
95+ const changedModules = state . editor . currentSandbox . modules . filter (
96+ m => getSavedCode ( m . code , m . savedCode ) !== m . code
97+ ) ;
98+ changedModules . forEach ( m => {
99+ // Update server with latest data
100+ effects . live . sendCodeUpdate (
101+ m . shortid ,
102+ getTextOperation ( m . savedCode || '' , m . code || '' )
103+ ) ;
104+ } ) ;
105+
91106 state . editor . isForkingSandbox = false ;
92107 return ;
93108 }
Original file line number Diff line number Diff line change @@ -391,6 +391,7 @@ export const forkSandbox: AsyncAction<{
391391
392392 return {
393393 ...module ,
394+ savedCode : foundEquivalentModule . savedCode ,
394395 code : foundEquivalentModule . code ,
395396 } ;
396397 } ) ,
You can’t perform that action at this time.
0 commit comments