mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-29 04:53:54 +03:00
922985f9ea
* chore(deps): update dependency prettier to v3 * Format --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathan Bierema <nbierema@gmail.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { LIFTED_ACTION } from '@redux-devtools/app';
|
|
|
|
export function getReport(
|
|
reportId: string,
|
|
tabId: string | number,
|
|
instanceId: number,
|
|
) {
|
|
chrome.storage.local.get(['s:hostname', 's:port', 's:secure'], (options) => {
|
|
if (!options['s:hostname'] || !options['s:port']) return;
|
|
const url = `${options['s:secure'] ? 'https' : 'http'}://${
|
|
options['s:hostname']
|
|
}:${options['s:port']}`;
|
|
|
|
fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'content-type': 'application/json',
|
|
},
|
|
body: JSON.stringify({ op: 'get', id: reportId }),
|
|
})
|
|
.then((response) => {
|
|
return response.json();
|
|
})
|
|
.then((json) => {
|
|
const { payload, preloadedState } = json;
|
|
if (!payload) return;
|
|
window.store.dispatch({
|
|
type: LIFTED_ACTION,
|
|
message: 'IMPORT',
|
|
state: JSON.stringify({ payload, preloadedState }),
|
|
id: tabId,
|
|
instanceId: `${tabId}/${instanceId}`,
|
|
});
|
|
})
|
|
.catch(function (err) {
|
|
/* eslint-disable no-console */
|
|
console.warn(err);
|
|
/* eslint-enable no-console */
|
|
});
|
|
});
|
|
}
|