tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

screenshot.js (846B)


      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 
      5 "use strict";
      6 
      7 const {
      8  TAKE_SCREENSHOT_END,
      9  TAKE_SCREENSHOT_START,
     10 } = require("resource://devtools/client/responsive/actions/index.js");
     11 
     12 const INITIAL_SCREENSHOT = {
     13  isCapturing: false,
     14 };
     15 
     16 const reducers = {
     17  [TAKE_SCREENSHOT_END](screenshot) {
     18    return {
     19      ...screenshot,
     20      isCapturing: false,
     21    };
     22  },
     23 
     24  [TAKE_SCREENSHOT_START](screenshot) {
     25    return {
     26      ...screenshot,
     27      isCapturing: true,
     28    };
     29  },
     30 };
     31 
     32 module.exports = function (screenshot = INITIAL_SCREENSHOT, action) {
     33  const reducer = reducers[action.type];
     34  if (!reducer) {
     35    return screenshot;
     36  }
     37  return reducer(screenshot, action);
     38 };