From 6dedea9cd9d356532a59a7d2edfabf213bd30bab Mon Sep 17 00:00:00 2001 From: Huzaifa Iftikhar Date: Wed, 10 Mar 2021 00:33:52 +0530 Subject: [PATCH 1/2] fix: attachSessId placeholder not getting displayed --- app/renderer/components/Session/AttachToSession.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/renderer/components/Session/AttachToSession.js b/app/renderer/components/Session/AttachToSession.js index 7c97330fd..12280de21 100644 --- a/app/renderer/components/Session/AttachToSession.js +++ b/app/renderer/components/Session/AttachToSession.js @@ -23,7 +23,7 @@ export default class AttachToSession extends Component { render () { let {attachSessId, setAttachSessId, runningAppiumSessions, getRunningSessions, t} = this.props; - attachSessId = attachSessId || ''; + attachSessId = attachSessId || undefined; return (
From ba0b898c81fd41acb95fb31858b4d92ba0ae005f Mon Sep 17 00:00:00 2001 From: Huzaifa Iftikhar Date: Wed, 10 Mar 2021 00:38:04 +0530 Subject: [PATCH 2/2] fix: stale session ids being displayed in the attach session dropdown --- app/renderer/reducers/Session.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/renderer/reducers/Session.js b/app/renderer/reducers/Session.js index d29782517..8d68b9475 100644 --- a/app/renderer/reducers/Session.js +++ b/app/renderer/reducers/Session.js @@ -68,6 +68,19 @@ const INITIAL_STATE = { let nextState; +// returns false if the attachSessId is not present in the runningSessions list +const isAttachSessIdValid = (runningSessions, attachSessId) => { + if (!attachSessId || !runningSessions) { + return false; + } + for (const session of runningSessions) { + if (session.id === attachSessId) { + return true; + } + } + return false; +}; + export default function session (state = INITIAL_STATE, action) { switch (action.type) { case NEW_SESSION_REQUESTED: @@ -237,13 +250,15 @@ export default function session (state = INITIAL_STATE, action) { gettingSessions: true, }; - case GET_SESSIONS_DONE: + case GET_SESSIONS_DONE: { + const attachSessId = isAttachSessIdValid(action.sessions, state.attachSessId) ? state.attachSessId : null; return { ...state, gettingSessions: false, - attachSessId: (action.sessions && action.sessions.length > 0 && !state.attachSessId) ? action.sessions[0].id : state.attachSessId, + attachSessId: (action.sessions && action.sessions.length > 0 && !attachSessId) ? action.sessions[0].id : attachSessId, runningAppiumSessions: action.sessions || [], }; + } case ENABLE_DESIRED_CAPS_EDITOR: return {