Skip to content

Commit

Permalink
Implement dynamic maxAge and fix getting it from options page
Browse files Browse the repository at this point in the history
Related to #480 and #316
  • Loading branch information
zalmoxisus committed Nov 26, 2018
1 parent 3299e2a commit 2922a54
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-devtools": "^3.4.1",
"redux-devtools-instrument": "^1.9.0",
"remotedev-app": "^0.10.9",
"redux-devtools-instrument": "^1.9.2",
"remotedev-app": "^0.10.10",
"remotedev-monitor-components": "^0.0.5",
"remotedev-serialize": "0.1.4",
"remotedev-slider": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/app/stores/enhancerStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function configureStore(next, monitorReducer, config) {
instrument(
monitorReducer,
{
maxAge: config.maxAge || window.devToolsOptions.maxAge || 50,
maxAge: config.maxAge,
shouldCatchErrors: config.shouldCatchErrors || window.shouldCatchErrors,
shouldHotReload: config.shouldHotReload,
shouldRecordChanges: config.shouldRecordChanges,
Expand Down
3 changes: 2 additions & 1 deletion src/browser/extension/inject/contentScript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { injectOptions, isAllowed } from '../options/syncOptions';
import { injectOptions, getOptionsFromBg, isAllowed } from '../options/syncOptions';
const source = '@devtools-extension';
let connected = false;
let bg;
Expand Down Expand Up @@ -58,6 +58,7 @@ function tryCatch(fn, args) {
function send(message) {
if (!connected) connect();
if (message.type === 'INIT_INSTANCE') {
getOptionsFromBg();
bg.postMessage({ name: 'INIT_INSTANCE', instanceId: message.instanceId });
} else {
bg.postMessage({ name: 'RELAY', message });
Expand Down
12 changes: 6 additions & 6 deletions src/browser/extension/inject/pageScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function(reducer, preloadedState, config) {

let store;
let errorOccurred = false;
let maxAge;
let maxAge = config.maxAge;
let actionCreators;
let sendingActionId = 1;
const instanceId = generateId(config.instanceId);
Expand Down Expand Up @@ -91,7 +91,7 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function(reducer, preloadedState, config) {

if (type === 'ACTION') {
message.action = !actionSanitizer ? action : actionSanitizer(action.action, nextActionId - 1);
message.maxAge = maxAge;
message.maxAge = getMaxAge();
message.nextActionId = nextActionId;
} else if (libConfig) {
message.libConfig = libConfig;
Expand Down Expand Up @@ -144,7 +144,7 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function(reducer, preloadedState, config) {
payload,
source,
instanceId,
maxAge
maxAge: getMaxAge()
}, serializeState, serializeAction);
}, latency);

Expand Down Expand Up @@ -233,9 +233,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function(reducer, preloadedState, config) {
}
}

function init() {
maxAge = config.maxAge || window.devToolsOptions.maxAge || 50;
const getMaxAge = () => maxAge || window.devToolsOptions.maxAge || 50;

function init() {
setListener(onMessage, instanceId);
notifyErrors(() => {
errorOccurred = true;
Expand Down Expand Up @@ -274,7 +274,7 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function(reducer, preloadedState, config) {
if (!isAllowed(window.devToolsOptions)) return next(reducer_, initialState_, enhancer_);

store = stores[instanceId] =
configureStore(next, monitor.reducer, config)(reducer_, initialState_, enhancer_);
configureStore(next, monitor.reducer, { ...config, maxAge: getMaxAge })(reducer_, initialState_, enhancer_);

if (isInIframe()) setTimeout(init, 3000);
else init();
Expand Down
18 changes: 13 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7341,14 +7341,22 @@ redux-devtools-chart-monitor@^1.6.1:
react-pure-render "^1.0.2"
redux-devtools-themes "^1.0.0"

redux-devtools-instrument@^1.0.1, redux-devtools-instrument@^1.9.0:
redux-devtools-instrument@^1.0.1:
version "1.9.0"
resolved "https://registry.yarnpkg.com/redux-devtools-instrument/-/redux-devtools-instrument-1.9.0.tgz#2faed9ac3292c783284b21843edfaa0567764a0c"
integrity sha512-pLFQoja1ojpsSRTWbC9yyc/a+z8uwOD7FPKLp+Abs7qjsah6khA5o8HBE2wa0VipE5vniYINdkNyxV/2iWADKg==
dependencies:
lodash "^4.2.0"
symbol-observable "^1.0.2"

redux-devtools-instrument@^1.9.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/redux-devtools-instrument/-/redux-devtools-instrument-1.9.2.tgz#c8bb81f295c60f1629164391c9c8552346d551c0"
integrity sha512-6ydVkHuAWPDRmEoVjPyJNF60y5pT6nIVyDXpTz2klGHu7oR+j3QJRMvRyyPYZMThePd8JIkh8/6L4zDXKED6aA==
dependencies:
lodash "^4.2.0"
symbol-observable "^1.0.2"

redux-devtools-log-monitor@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/redux-devtools-log-monitor/-/redux-devtools-log-monitor-1.2.0.tgz#136a202f999c659a13fbb5c50793106e80722311"
Expand Down Expand Up @@ -7462,10 +7470,10 @@ regjsparser@^0.1.4:
dependencies:
jsesc "~0.5.0"

remotedev-app@^0.10.9:
version "0.10.9"
resolved "https://registry.yarnpkg.com/remotedev-app/-/remotedev-app-0.10.9.tgz#415e0bfa7328a9e8f47a2a9fc86595738fbb4484"
integrity sha512-m/NfJ3t50XgIwFO2Z0+Wv2xzZ1jyH7U0eUBe/k/wtwJTU6UHdARwKeZPJ43wotqWFB1QOPBe/8k9V/uAOI4bKw==
remotedev-app@^0.10.10:
version "0.10.10"
resolved "https://registry.yarnpkg.com/remotedev-app/-/remotedev-app-0.10.10.tgz#846572cc08bcaaa80d53390dfba97eb7a020ef63"
integrity sha512-ChmS1Z+TWX+HNIuO5GPi+Gdd2JKVvUeEyB2rIxUliOx8Y127T9vqBqbASBc8S+t43S7QdWCHt1nbI/0iPyErZA==
dependencies:
chrome-storage-local "^0.1.6"
d3-state-visualizer "^1.3.1"
Expand Down

0 comments on commit 2922a54

Please sign in to comment.