summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/actions/pause/skipPausing.js
blob: e5d3a9ef403b3bba44e628b9300773c784b9a1b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

// @flow

import type { ThunkArgs } from "../types";
import { getSkipPausing } from "../../selectors";

/**
 * @memberof actions/pause
 * @static
 */
export function toggleSkipPausing() {
  return async ({ dispatch, client, getState, sourceMaps }: ThunkArgs) => {
    const skipPausing = !getSkipPausing(getState());
    await client.setSkipPausing(skipPausing);
    dispatch({ type: "TOGGLE_SKIP_PAUSING", skipPausing });
  };
}

/**
 * @memberof actions/pause
 * @static
 */
export function setSkipPausing(skipPausing: boolean) {
  return async ({ dispatch, client, getState, sourceMaps }: ThunkArgs) => {
    const currentlySkipping = getSkipPausing(getState());
    if (currentlySkipping === skipPausing) {
      return;
    }

    await client.setSkipPausing(skipPausing);
    dispatch({ type: "TOGGLE_SKIP_PAUSING", skipPausing });
  };
}