Skip to content

Commit 0b5bb5d

Browse files
committed
fix: does not save action and resource when space is not saved
closes #296
1 parent 92fa3d8 commit 0b5bb5d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/components/phase/PhaseApp.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class PhaseApp extends Component {
6161
}),
6262
user: PropTypes.instanceOf(Map).isRequired,
6363
actionsEnabled: PropTypes.bool.isRequired,
64+
isSpaceSaved: PropTypes.bool,
6465
};
6566

6667
static defaultProps = {
@@ -70,6 +71,7 @@ class PhaseApp extends Component {
7071
name: 'Image',
7172
lang: DEFAULT_LANGUAGE,
7273
userId: null,
74+
isSpaceSaved: false,
7375
};
7476

7577
state = {
@@ -116,6 +118,7 @@ class PhaseApp extends Component {
116118
appInstance,
117119
dispatchPostAction,
118120
user,
121+
isSpaceSaved,
119122
} = this.props;
120123

121124
// get app instance id in message
@@ -127,18 +130,28 @@ class PhaseApp extends Component {
127130
}
128131

129132
// only receive message from intended app instance
133+
// save data if space is saved
130134
if (componentAppInstanceId === messageAppInstanceId) {
131135
switch (type) {
136+
case GET_APP_INSTANCE:
137+
return dispatchGetAppInstance(payload, this.postMessage);
132138
case GET_APP_INSTANCE_RESOURCES:
133139
return getAppInstanceResources(payload, this.postMessage);
134140
case POST_APP_INSTANCE_RESOURCE:
135-
return postAppInstanceResource(payload, this.postMessage);
141+
if (isSpaceSaved) {
142+
return postAppInstanceResource(payload, this.postMessage);
143+
}
144+
break;
136145
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;
140150
case POST_ACTION: {
141-
return dispatchPostAction(payload, user, this.postMessage);
151+
if (isSpaceSaved) {
152+
return dispatchPostAction(payload, user, this.postMessage);
153+
}
154+
break;
142155
}
143156
default:
144157
return false;
@@ -305,6 +318,7 @@ const mapStateToProps = ({ authentication, Space }) => ({
305318
userId: authentication.getIn(['user', 'id']),
306319
user: authentication.getIn(['user']),
307320
actionsEnabled: authentication.getIn(['user', 'settings', 'actionsEnabled']),
321+
isSpaceSaved: Space.getIn(['current', 'content', 'saved']),
308322
});
309323

310324
const mapDispatchToProps = {

0 commit comments

Comments
 (0)