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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* 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/. */
"use strict";
const {
l10n,
} = require("resource://devtools/client/application/src/modules/l10n.js");
const {
services,
ManifestDevToolsError,
} = require("resource://devtools/client/application/src/modules/application-services.js");
const {
FETCH_MANIFEST_FAILURE,
FETCH_MANIFEST_START,
FETCH_MANIFEST_SUCCESS,
RESET_MANIFEST,
} = require("resource://devtools/client/application/src/constants.js");
function fetchManifest() {
return async ({ dispatch, getState }) => {
dispatch({ type: FETCH_MANIFEST_START });
try {
const manifest = await services.fetchManifest();
dispatch({ type: FETCH_MANIFEST_SUCCESS, manifest });
} catch (error) {
let errorMessage = error.message;
// since Firefox DevTools errors may not make sense for the user, swap
// their message for a generic one.
if (error instanceof ManifestDevToolsError) {
console.error(error);
errorMessage = l10n.getString("manifest-loaded-devtools-error");
}
dispatch({ type: FETCH_MANIFEST_FAILURE, error: errorMessage });
}
};
}
function resetManifest() {
return { type: RESET_MANIFEST };
}
module.exports = {
fetchManifest,
resetManifest,
};
|