Skip to content

Commit

Permalink
Use maxAge option instead of auto commiting
Browse files Browse the repository at this point in the history
Fix #84
  • Loading branch information
zalmoxisus committed Apr 12, 2016
1 parent 4fc7d0b commit 249be38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/store/configureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { persistState, instrument } from 'redux-devtools';
export default function configureStore(next, subscriber = () => ({}), options = {}) {
const { deserializeState, deserializeAction } = options;
return compose(
instrument(subscriber),
instrument(subscriber, window.devToolsOptions),
persistState(
getPersistSession(),
deserializeState,
Expand Down
9 changes: 6 additions & 3 deletions src/browser/extension/inject/pageScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ window.devToolsExtension = function(config = {}) {
window.postMessage(message, '*');
}

function relay(type, state, action, nextActionId) {
function relay(type, state, action, nextActionId, isExcess) {
setTimeout(() => {
const message = {
payload: type === 'STATE' && shouldFilter() ? filterActions(state) : state,
action: action || '',
nextActionId: nextActionId || '',
type: type,
isExcess,
type,
source: 'redux-page',
name: config.name || document.title
};
Expand Down Expand Up @@ -155,7 +156,9 @@ window.devToolsExtension = function(config = {}) {
relay('INIT', state, { timestamp: Date.now() });
} else if (!errorOccurred && monitorActions.indexOf(lastAction) === -1) {
if (lastAction === 'JUMP_TO_STATE' || shouldFilter() && isFiltered(action)) return;
relay('ACTION', state, liftedAction, nextActionId);
const { maxAge } = window.devToolsOptions;
const isExcess = maxAge && liftedState.stagedActionIds.length === maxAge;
relay('ACTION', state, liftedAction, nextActionId, isExcess);
} else {
if (errorOccurred && !liftedState.computedStates[liftedState.currentStateIndex].error) errorOccurred = false;
relay('STATE', liftedState);
Expand Down
6 changes: 4 additions & 2 deletions src/browser/extension/options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ chrome.runtime.getBackgroundPage( background => {
const saveOption = e => {
let value;
if (e.target.type === 'checkbox') value = e.target.checked;
else if (e.target.type === 'input') value = Number(e.target.value);
else if (
e.target.type === 'input' || e.target.type === 'text'
) value = Number(e.target.value);
else value = e.target.value;
syncOptions.save(e.target.id, value);
};
Expand Down Expand Up @@ -48,7 +50,7 @@ chrome.runtime.getBackgroundPage( background => {
</div>
<div className="input">
<span className="caption">Maximum actions:</span>
<input id="limit" type="text" defaultValue={items.limit} onChange={saveOption}/>
<input id="maxAge" type="text" defaultValue={items.maxAge} onChange={saveOption}/>
<span className="comment">(autocommit when exceeds, 0 - no limit)</span>
</div>
<div className="input">
Expand Down
2 changes: 1 addition & 1 deletion src/browser/extension/options/syncOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const get = callback => {
leftMonitor: 'LogMonitor',
rightMonitor: 'LogMonitor',
bottomMonitor: 'SliderMonitor',
limit: 50,
maxAge: 50,
filter: false,
whitelist: '',
blacklist: '',
Expand Down

0 comments on commit 249be38

Please sign in to comment.