From bc9fcf9e9d864c21faf2d73b0fc17ef1780ae58d Mon Sep 17 00:00:00 2001 From: Yannis Petitot <46972108+yadPe@users.noreply.github.com> Date: Sun, 13 Mar 2022 18:39:55 +0100 Subject: [PATCH] perf(memory): Reduce usage when switching sections (#466) --- src/App/app.actions.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/App/app.actions.js b/src/App/app.actions.js index 795a0fb3..280cca18 100644 --- a/src/App/app.actions.js +++ b/src/App/app.actions.js @@ -1,7 +1,19 @@ -export const changeCurrentSection = (sectionName, params = {}) => ({ - type: 'UPDATEACTIVESECTION', - payload: { sectionName, params }, -}); +import { webFrame } from 'electron'; + +/** + * Action creator will call clearCache as a side effect + * @param {string} sectionName + * @param {Record} params + * @returns + */ +export const changeCurrentSection = (sectionName, params = {}) => { + // Used to clear web frame cache especially images when changing section since there is no real navigation in the app for chromium to to it by itself + webFrame.clearCache(); + return { + type: 'UPDATEACTIVESECTION', + payload: { sectionName, params }, + }; +}; export const clearSectionParams = () => ({ type: 'CLEAR_ACTIVE_SECTION_PARAMS',