Skip to content

Commit

Permalink
Fix: Fix connecting Wi-Fi manually blanks out software (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
jane-rose authored and parachvte committed Jan 11, 2021
1 parent 28f46c6 commit 41b635a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/app/flux/machine/action-connect.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import includes from 'lodash/includes';
import isInteger from 'lodash/isInteger';

// import { Server } from './Server';
import { CONNECTION_TYPE_SERIAL, CONNECTION_TYPE_WIFI } from '../../constants';
import { machineStore } from '../../store/local-storage';

Expand Down Expand Up @@ -36,8 +36,17 @@ const setConnectionTimeout = (connectionTimeout) => (dispatch) => {
* Set selected server.
*
* Update state only, we will save the server when connection established.
* If 'server' is not found in 'servers' list, add it and update state
*/
const setSelectedServer = (server) => (dispatch) => {
const setSelectedServer = (server) => (dispatch, getState) => {
const { servers } = getState().machine;

const find = servers.find(v => v.equals(server));
if (!find) {
const newServers = servers.slice(0);
newServers.push(server);
dispatch(baseActions.updateState({ servers: newServers }));
}
dispatch(baseActions.updateState({ server }));
};

Expand Down
2 changes: 1 addition & 1 deletion src/app/widgets/Connection/WifiConnection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class WifiConnection extends PureComponent {
} else {
find = servers.find(v => v.name === server.name && v.address === server.address);
}
if (find) {
if (find && find !== server) {
this.setState({
server: find
});
Expand Down

0 comments on commit 41b635a

Please sign in to comment.