network-throttling.js 713 B

12345678910111213141516171819202122232425262728293031323334
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const {
  6. CHANGE_NETWORK_THROTTLING,
  7. } = require("../actions/index");
  8. const INITIAL_NETWORK_THROTTLING = {
  9. enabled: false,
  10. profile: "",
  11. };
  12. let reducers = {
  13. [CHANGE_NETWORK_THROTTLING](throttling, { enabled, profile }) {
  14. return {
  15. enabled,
  16. profile,
  17. };
  18. },
  19. };
  20. module.exports = function (throttling = INITIAL_NETWORK_THROTTLING, action) {
  21. let reducer = reducers[action.type];
  22. if (!reducer) {
  23. return throttling;
  24. }
  25. return reducer(throttling, action);
  26. };