File tree Expand file tree Collapse file tree 5 files changed +24
-0
lines changed
Expand file tree Collapse file tree 5 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,11 @@ export default {
195195 this . send ( 'live:module_state' , { } ) ;
196196 }
197197 } ,
198+ sendExternalResourcesChanged ( externalResources : string [ ] ) {
199+ return this . send ( 'sandbox:external-resources' , {
200+ externalResources,
201+ } ) ;
202+ } ,
198203 sendUserCurrentModule ( moduleShortid : string ) {
199204 return this . send ( 'user:current-module' , {
200205 moduleShortid,
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ export const liveMessageReceived: Operator<LiveMessage> = pipe(
9797 [ LiveMessageEvent . MODULE_STATE ] : liveMessage . onModuleState ,
9898 [ LiveMessageEvent . USER_ENTERED ] : liveMessage . onUserEntered ,
9999 [ LiveMessageEvent . USER_LEFT ] : liveMessage . onUserLeft ,
100+ [ LiveMessageEvent . EXTERNAL_RESOURCES ] : liveMessage . onExternalResources ,
100101 [ LiveMessageEvent . MODULE_SAVED ] : liveMessage . onModuleSaved ,
101102 [ LiveMessageEvent . MODULE_CREATED ] : liveMessage . onModuleCreated ,
102103 [ LiveMessageEvent . MODULE_MASS_CREATED ] : liveMessage . onModuleMassCreated ,
Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ export const onModuleState: Operator<LiveMessage<{
3636 actions . live . internal . initializeModuleState ( data . module_state ) ;
3737} ) ;
3838
39+ export const onExternalResources : Operator < LiveMessage < {
40+ externalResources : string [ ] ;
41+ } > > = mutate ( ( { state, actions } , { data } ) => {
42+ state . editor . currentSandbox . externalResources = data . externalResources ;
43+ actions . editor . internal . updatePreviewCode ( ) ;
44+ } ) ;
45+
3946export const onUserEntered : Operator < LiveMessage < {
4047 users : any [ ] ;
4148 editor_ids : string [ ] ;
Original file line number Diff line number Diff line change @@ -148,6 +148,11 @@ export const externalResourceAdded: AsyncAction<string> = withOwnedSandbox(
148148 state . editor . currentSandbox . id ,
149149 resource
150150 ) ;
151+ if ( state . live . isLive ) {
152+ effects . live . sendExternalResourcesChanged (
153+ state . editor . currentSandbox . externalResources
154+ ) ;
155+ }
151156 } catch ( error ) {
152157 externalResources . splice ( externalResources . indexOf ( resource ) , 1 ) ;
153158 actions . internal . handleError ( {
@@ -172,6 +177,11 @@ export const externalResourceRemoved: AsyncAction<string> = withOwnedSandbox(
172177 state . editor . currentSandbox . id ,
173178 resource
174179 ) ;
180+ if ( state . live . isLive ) {
181+ effects . live . sendExternalResourcesChanged (
182+ state . editor . currentSandbox . externalResources
183+ ) ;
184+ }
175185 } catch ( error ) {
176186 externalResources . splice ( resourceIndex , 0 , resource ) ;
177187
Original file line number Diff line number Diff line change @@ -682,6 +682,7 @@ export enum LiveMessageEvent {
682682 MODULE_MASS_CREATED = 'module:mass-created' ,
683683 MODULE_UPDATED = 'module:updated' ,
684684 MODULE_DELETED = 'module:deleted' ,
685+ EXTERNAL_RESOURCES = 'sandbox:external-resources' ,
685686 DIRECTORY_CREATED = 'directory:created' ,
686687 DIRECTORY_UPDATED = 'directory:updated' ,
687688 DIRECTORY_DELETED = 'directory:deleted' ,
You can’t perform that action at this time.
0 commit comments