diff --git a/desktop/plugins/network/index.tsx b/desktop/plugins/network/index.tsx index c90f95a40..a762e9c09 100644 --- a/desktop/plugins/network/index.tsx +++ b/desktop/plugins/network/index.tsx @@ -50,6 +50,8 @@ import fs from 'fs'; import electron from 'electron'; const LOCALSTORAGE_MOCK_ROUTE_LIST_KEY = '__NETWORK_CACHED_MOCK_ROUTE_LIST'; +const LOCALSTORAGE_RESPONSE_BODY_FORMAT_KEY = + '__NETWORK_CACHED_RESPONSE_BODY_FORMAT'; export const BodyOptions = { formatted: 'formatted', @@ -162,7 +164,10 @@ export function plugin(client: PluginClient) { const nextRouteId = createState(0); const isMockResponseSupported = createState(false); const showMockResponseDialog = createState(false); - const detailBodyFormat = createState(BodyOptions.parsed); + const detailBodyFormat = createState( + localStorage.getItem(LOCALSTORAGE_RESPONSE_BODY_FORMAT_KEY) || + BodyOptions.parsed, + ); const highlightedRows = createState | null | undefined>( new Set(), ); @@ -319,7 +324,8 @@ export function plugin(client: PluginClient) { function init() { client.supportsMethod('mockResponses').then((result) => { const newRoutes = JSON.parse( - localStorage.getItem(LOCALSTORAGE_MOCK_ROUTE_LIST_KEY) || '{}', + localStorage.getItem(LOCALSTORAGE_MOCK_ROUTE_LIST_KEY + client.appId) || + '{}', ); routes.set(newRoutes); isMockResponseSupported.set(result); @@ -526,7 +532,7 @@ export function plugin(client: PluginClient) { if (isMockResponseSupported.get()) { const routesValuesArray = Object.values(filteredRoutes); localStorage.setItem( - LOCALSTORAGE_MOCK_ROUTE_LIST_KEY, + LOCALSTORAGE_MOCK_ROUTE_LIST_KEY + client.appId, JSON.stringify(routesValuesArray), ); @@ -572,6 +578,7 @@ export function plugin(client: PluginClient) { }, onSelectFormat(bodyFormat: string) { detailBodyFormat.set(bodyFormat); + localStorage.setItem(LOCALSTORAGE_RESPONSE_BODY_FORMAT_KEY, bodyFormat); }, copyRequestCurlCommand, init,