@@ -61,6 +61,7 @@ class PhaseApp extends Component {
61
61
} ) ,
62
62
user : PropTypes . instanceOf ( Map ) . isRequired ,
63
63
actionsEnabled : PropTypes . bool . isRequired ,
64
+ isSpaceSaved : PropTypes . bool ,
64
65
} ;
65
66
66
67
static defaultProps = {
@@ -70,6 +71,7 @@ class PhaseApp extends Component {
70
71
name : 'Image' ,
71
72
lang : DEFAULT_LANGUAGE ,
72
73
userId : null ,
74
+ isSpaceSaved : false ,
73
75
} ;
74
76
75
77
state = {
@@ -116,6 +118,7 @@ class PhaseApp extends Component {
116
118
appInstance,
117
119
dispatchPostAction,
118
120
user,
121
+ isSpaceSaved,
119
122
} = this . props ;
120
123
121
124
// get app instance id in message
@@ -127,18 +130,28 @@ class PhaseApp extends Component {
127
130
}
128
131
129
132
// only receive message from intended app instance
133
+ // save data if space is saved
130
134
if ( componentAppInstanceId === messageAppInstanceId ) {
131
135
switch ( type ) {
136
+ case GET_APP_INSTANCE :
137
+ return dispatchGetAppInstance ( payload , this . postMessage ) ;
132
138
case GET_APP_INSTANCE_RESOURCES :
133
139
return getAppInstanceResources ( payload , this . postMessage ) ;
134
140
case POST_APP_INSTANCE_RESOURCE :
135
- return postAppInstanceResource ( payload , this . postMessage ) ;
141
+ if ( isSpaceSaved ) {
142
+ return postAppInstanceResource ( payload , this . postMessage ) ;
143
+ }
144
+ break ;
136
145
case PATCH_APP_INSTANCE_RESOURCE :
137
- return patchAppInstanceResource ( payload , this . postMessage ) ;
138
- case GET_APP_INSTANCE :
139
- return dispatchGetAppInstance ( payload , this . postMessage ) ;
146
+ if ( isSpaceSaved ) {
147
+ return patchAppInstanceResource ( payload , this . postMessage ) ;
148
+ }
149
+ break ;
140
150
case POST_ACTION : {
141
- return dispatchPostAction ( payload , user , this . postMessage ) ;
151
+ if ( isSpaceSaved ) {
152
+ return dispatchPostAction ( payload , user , this . postMessage ) ;
153
+ }
154
+ break ;
142
155
}
143
156
default :
144
157
return false ;
@@ -305,6 +318,7 @@ const mapStateToProps = ({ authentication, Space }) => ({
305
318
userId : authentication . getIn ( [ 'user' , 'id' ] ) ,
306
319
user : authentication . getIn ( [ 'user' ] ) ,
307
320
actionsEnabled : authentication . getIn ( [ 'user' , 'settings' , 'actionsEnabled' ] ) ,
321
+ isSpaceSaved : Space . getIn ( [ 'current' , 'content' , 'saved' ] ) ,
308
322
} ) ;
309
323
310
324
const mapDispatchToProps = {
0 commit comments