Bug 1519088 - Add dedicated action to update selected runtime id;r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 16 Jan 2019 17:24:25 +0000
changeset 514108 a9582642ea71edb6982f2db792cee403d58bbcea
parent 514107 7c46446409369b837a17aba20e550b4d6e23d683
child 514109 91911f0e1e35a3965514aac9729b5641698f0243
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko
bugs1519088
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1519088 - Add dedicated action to update selected runtime id;r=ladybenko If we update the selected runtime id in a single spot, we no longer have intermediary states with no selected runtime, which was breaking the service worker action component. Differential Revision: https://phabricator.services.mozilla.com/D16473
devtools/client/aboutdebugging-new/src/actions/ui.js
devtools/client/aboutdebugging-new/src/constants.js
devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
--- a/devtools/client/aboutdebugging-new/src/actions/ui.js
+++ b/devtools/client/aboutdebugging-new/src/actions/ui.js
@@ -13,16 +13,17 @@ const {
   ADB_ADDON_UNINSTALL_FAILURE,
   ADB_ADDON_STATUS_UPDATED,
   DEBUG_TARGET_COLLAPSIBILITY_UPDATED,
   NETWORK_LOCATIONS_UPDATED,
   PAGE_TYPES,
   SELECT_PAGE_FAILURE,
   SELECT_PAGE_START,
   SELECT_PAGE_SUCCESS,
+  SELECTED_RUNTIME_ID_UPDATED,
   USB_RUNTIMES_SCAN_START,
   USB_RUNTIMES_SCAN_SUCCESS,
 } = require("../constants");
 
 const NetworkLocationsModule = require("../modules/network-locations");
 const { adbAddon } = require("devtools/shared/adb/adb-addon");
 const { refreshUSBRuntimes } = require("../modules/usb-runtimes");
 
@@ -49,16 +50,24 @@ function selectPage(page, runtimeId) {
       }
 
       // Stop watching current runtime, if currently on a RUNTIME page.
       if (currentPage === PAGE_TYPES.RUNTIME) {
         const currentRuntimeId = getState().runtimes.selectedRuntimeId;
         await dispatch(Actions.unwatchRuntime(currentRuntimeId));
       }
 
+      // Always update the selected runtime id.
+      // If we are navigating to a non-runtime page, the Runtime page components are no
+      // longer rendered so it is safe to nullify the runtimeId.
+      // If we are navigating to a runtime page, the runtime corresponding to runtimeId
+      // is already connected, so components can safely get runtimeDetails on this new
+      // runtime.
+      dispatch({ type: SELECTED_RUNTIME_ID_UPDATED, runtimeId });
+
       // Start watching current runtime, if moving to a RUNTIME page.
       if (page === PAGE_TYPES.RUNTIME) {
         await dispatch(Actions.watchRuntime(runtimeId));
       }
 
       dispatch({ type: SELECT_PAGE_SUCCESS, page, runtimeId });
     } catch (e) {
       dispatch({ type: SELECT_PAGE_FAILURE, error: e });
--- a/devtools/client/aboutdebugging-new/src/constants.js
+++ b/devtools/client/aboutdebugging-new/src/constants.js
@@ -28,16 +28,17 @@ const actionTypes = {
   REQUEST_TABS_START: "REQUEST_TABS_START",
   REQUEST_TABS_SUCCESS: "REQUEST_TABS_SUCCESS",
   REQUEST_WORKERS_FAILURE: "REQUEST_WORKERS_FAILURE",
   REQUEST_WORKERS_START: "REQUEST_WORKERS_START",
   REQUEST_WORKERS_SUCCESS: "REQUEST_WORKERS_SUCCESS",
   SELECT_PAGE_FAILURE: "SELECT_PAGE_FAILURE",
   SELECT_PAGE_START: "SELECT_PAGE_START",
   SELECT_PAGE_SUCCESS: "SELECT_PAGE_SUCCESS",
+  SELECTED_RUNTIME_ID_UPDATED: "SELECTED_RUNTIME_ID_UPDATED",
   TEMPORARY_EXTENSION_INSTALL_FAILURE: "TEMPORARY_EXTENSION_INSTALL_FAILURE",
   TEMPORARY_EXTENSION_INSTALL_START: "TEMPORARY_EXTENSION_INSTALL_START",
   TEMPORARY_EXTENSION_INSTALL_SUCCESS: "TEMPORARY_EXTENSION_INSTALL_SUCCESS",
   THIS_FIREFOX_RUNTIME_CREATED: "THIS_FIREFOX_RUNTIME_CREATED",
   UNWATCH_RUNTIME_FAILURE: "UNWATCH_RUNTIME_FAILURE",
   UNWATCH_RUNTIME_START: "UNWATCH_RUNTIME_START",
   UNWATCH_RUNTIME_SUCCESS: "UNWATCH_RUNTIME_SUCCESS",
   UPDATE_CONNECTION_PROMPT_SETTING_FAILURE: "UPDATE_CONNECTION_PROMPT_SETTING_FAILURE",
--- a/devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
+++ b/devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
@@ -3,22 +3,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {
   CONNECT_RUNTIME_SUCCESS,
   DISCONNECT_RUNTIME_SUCCESS,
   RUNTIMES,
-  UNWATCH_RUNTIME_SUCCESS,
   UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS,
   UPDATE_RUNTIME_MULTIE10S_SUCCESS,
   REMOTE_RUNTIMES_UPDATED,
+  SELECTED_RUNTIME_ID_UPDATED,
   THIS_FIREFOX_RUNTIME_CREATED,
-  WATCH_RUNTIME_SUCCESS,
 } = require("../constants");
 
 const {
   findRuntimeById,
 } = require("../modules/runtimes-state-helper");
 
 const { remoteClientManager } =
   require("devtools/client/shared/remote-debugging/remote-client-manager");
@@ -79,18 +78,19 @@ function runtimesReducer(state = Runtime
     }
 
     case DISCONNECT_RUNTIME_SUCCESS: {
       const { id, type } = action.runtime;
       remoteClientManager.removeClient(id, type);
       return _updateRuntimeById(id, { runtimeDetails: null }, state);
     }
 
-    case UNWATCH_RUNTIME_SUCCESS: {
-      return Object.assign({}, state, { selectedRuntimeId: null });
+    case SELECTED_RUNTIME_ID_UPDATED: {
+      const { runtimeId } = action;
+      return Object.assign({}, state, { selectedRuntimeId: runtimeId });
     }
 
     case UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS: {
       const { connectionPromptEnabled } = action;
       const { id: runtimeId } = action.runtime;
       const runtime = findRuntimeById(runtimeId, state);
       const runtimeDetails =
         Object.assign({}, runtime.runtimeDetails, { connectionPromptEnabled });
@@ -116,21 +116,16 @@ function runtimesReducer(state = Runtime
 
     case THIS_FIREFOX_RUNTIME_CREATED: {
       const { runtime } = action;
       return Object.assign({}, state, {
         thisFirefoxRuntimes: [runtime],
       });
     }
 
-    case WATCH_RUNTIME_SUCCESS: {
-      const { id } = action.runtime;
-      return Object.assign({}, state, { selectedRuntimeId: id });
-    }
-
     default:
       return state;
   }
 }
 
 module.exports = {
   RuntimesState,
   runtimesReducer,