Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(share): avoid disconnect when transitioning to full remote #548

Merged
merged 2 commits into from Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 1 addition & 13 deletions spot-client/src/spot-remote/ui/loaders/withRemoteControl.js
Expand Up @@ -28,21 +28,9 @@ export class RemoteControlLoader extends AbstractLoader {
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
* @param {boolean} disconnectOnUnmount - Whether or not the RCS should be disconnected when this loader component
* is being unmounted.
*/
constructor(props, disconnectOnUnmount) {
constructor(props) {
super(props, 'SpotRemote');
this._disconnectOnUnmount = disconnectOnUnmount;
}

/**
* Clean up connection related state.
*
* @inheritdoc
*/
componentWillUnmount() {
this._disconnectOnUnmount && this.props.onDisconnect();
}

/**
Expand Down
37 changes: 36 additions & 1 deletion spot-client/src/spot-remote/ui/views/remote-control.js
Expand Up @@ -11,6 +11,7 @@ import { LoadingIcon, View } from 'common/ui';

import './../../analytics';

import { disconnectFromSpotTV } from './../../app-state';
import {
ElectronDesktopPickerModal,
WaitingForSpotTVOverlay
Expand All @@ -30,6 +31,7 @@ export class RemoteControl extends React.PureComponent {
events: PropTypes.array,
history: PropTypes.object,
isConnectedToSpot: PropTypes.bool,
onDisconnect: PropTypes.func,
view: PropTypes.string
};

Expand All @@ -43,6 +45,15 @@ export class RemoteControl extends React.PureComponent {
super(props, true);
}

/**
* Clean up connection related state.
*
* @inheritdoc
*/
componentWillUnmount() {
this.props.onDisconnect();
}

/**
* Implements React's {@link Component#render()}.
*
Expand Down Expand Up @@ -104,4 +115,28 @@ function mapStateToProps(state) {
};
}

export default withUltrasound(withRemoteControl(connect(mapStateToProps)(RemoteControl)));
/**
* Creates actions which can update Redux state.
*
* @param {Function} dispatch - The Redux dispatch function to update state.
* @private
* @returns {Object}
*/
function mapDispatchToProps(dispatch) {
return {
/**
* Stop any existing connection to a Spot-TV.
*
* @returns {void}
*/
onDisconnect() {
dispatch(disconnectFromSpotTV());
}
};
}

export default withUltrasound(
withRemoteControl(
connect(mapStateToProps, mapDispatchToProps)(RemoteControl)
)
);
Expand Up @@ -86,7 +86,9 @@ class WaitingForCallView extends React.Component {
const { activeTab } = this.state;

return (
<div className = 'waiting-view'>
<div
className = 'waiting-view'
data-qa-id = 'waiting-for-call-view'>
{ this.props._enableAutoUpdate
&& <AutoUpdateChecker
onUpdateAvailable = { this.props._onUpdateAvailable } /> }
Expand Down
11 changes: 11 additions & 0 deletions spot-webdriver/page-objects/remote-control-page.js
Expand Up @@ -5,6 +5,7 @@ const ScreensharePicker = require('./screenshare-picker');
const MEET_NOW_BUTTON = '[data-qa-id=meet-now]';
const REMOTE_CONTROL = '[data-qa-id=remoteControl-view]';
const SHARE_CONTENT_BUTTON = '[data-qa-id=share-content]';
const WAITING_FOR_CALL_SUBVIEW = '[data-qa-id=waiting-for-call-view]';
const WAITING_FOR_SPOT_TV_LABEL = '[data-qa-id=waiting-for-spot-tv]';

/**
Expand Down Expand Up @@ -45,6 +46,16 @@ class RemoteControlPage extends PageObject {
return new PageObject(this.driver, WAITING_FOR_SPOT_TV_LABEL);
}

/**
* Wait specifically for the subview of the remote control page which shows
* when Spot-TV is not in a call.
*
* @returns {void}
*/
waitWaitingForCallViewToDisplay() {
this.waitForElementDisplayed(WAITING_FOR_CALL_SUBVIEW);
}

/**
* Begins the wireless screensharing flow for when there is both wireless
* and wired screensharing enabled.
Expand Down
2 changes: 2 additions & 0 deletions spot-webdriver/specs/share-mode.spec.js
Expand Up @@ -45,5 +45,7 @@ describe('In share mode', () => {
const remoteControlPage = spotRemote.getRemoteControlPage();

remoteControlPage.waitForVisible();

remoteControlPage.waitWaitingForCallViewToDisplay();
});
});