screenshot.js 816 B

1234567891011121314151617181920212223242526272829303132
  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. TAKE_SCREENSHOT_END,
  7. TAKE_SCREENSHOT_START,
  8. } = require("../actions/index");
  9. const INITIAL_SCREENSHOT = { isCapturing: false };
  10. let reducers = {
  11. [TAKE_SCREENSHOT_END](screenshot, action) {
  12. return Object.assign({}, screenshot, { isCapturing: false });
  13. },
  14. [TAKE_SCREENSHOT_START](screenshot, action) {
  15. return Object.assign({}, screenshot, { isCapturing: true });
  16. },
  17. };
  18. module.exports = function (screenshot = INITIAL_SCREENSHOT, action) {
  19. let reducer = reducers[action.type];
  20. if (!reducer) {
  21. return screenshot;
  22. }
  23. return reducer(screenshot, action);
  24. };