feat: disconnect from cloud variables immediately after adding video sensing to a project
This commit is contained in:
1 parent
68b45e38a3
commit
7279c8b542
1 file changed
+12
-3
@@ -25,10 +25,12 @@ const cloudManagerHOC = function (WrappedComponent) {
|
||||
super(props);
|
||||
this.cloudProvider = null;
|
||||
bindAll(this, [
|
||||
'handleCloudDataUpdate'
|
||||
'handleCloudDataUpdate',
|
||||
'handleExtensionAdded'
|
||||
]);
|
||||
|
||||
this.props.vm.on('HAS_CLOUD_DATA_UPDATE', this.handleCloudDataUpdate);
|
||||
this.props.vm.on('EXTENSION_ADDED', this.handleExtensionAdded);
|
||||
}
|
||||
componentDidMount () {
|
||||
if (this.shouldConnect(this.props)) {
|
||||
@@ -57,7 +59,7 @@ const cloudManagerHOC = function (WrappedComponent) {
|
||||
shouldConnect (props) {
|
||||
return !this.isConnected() && this.canUseCloud(props) &&
|
||||
props.isShowingWithId && props.vm.runtime.hasCloudData() &&
|
||||
props.canModifyCloudData && !props.vm.extensionManager.isExtensionLoaded('videoSensing');
|
||||
props.canModifyCloudData;
|
||||
}
|
||||
shouldDisconnect (props, prevProps) {
|
||||
return this.isConnected() &&
|
||||
@@ -96,6 +98,11 @@ const cloudManagerHOC = function (WrappedComponent) {
|
||||
this.connectToCloud();
|
||||
}
|
||||
}
|
||||
handleExtensionAdded (categoryInfo) {
|
||||
if (categoryInfo.id === 'videoSensing' && this.isConnected()) {
|
||||
this.disconnectFromCloud();
|
||||
}
|
||||
}
|
||||
render () {
|
||||
const {
|
||||
/* eslint-disable no-unused-vars */
|
||||
@@ -144,7 +151,9 @@ const cloudManagerHOC = function (WrappedComponent) {
|
||||
isShowingWithId: getIsShowingWithId(loadingState),
|
||||
projectId: state.scratchGui.projectState.projectId,
|
||||
// if you're editing someone else's project, you can't modify cloud data
|
||||
canModifyCloudData: (!state.scratchGui.mode.hasEverEnteredEditor || ownProps.canSave)
|
||||
canModifyCloudData: (!state.scratchGui.mode.hasEverEnteredEditor || ownProps.canSave) &&
|
||||
// possible security concern if the program attempts to encode webcam data over cloud variables
|
||||
!ownProps.vm.extensionManager.isExtensionLoaded('videoSensing')
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user