Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Verify dashboard version before rehydrating redux store during deploy…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
gurbirkalsi committed May 13, 2020
1 parent 379b05e commit e3599bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"precommit": "npm run lint-staged",
"start": "cross-env UMI_UI=none umi dev",
"start:no-mock": "cross-env MOCK=none umi dev",
"build": "umi build",
"build": "npm --no-git-tag-version version prerelease && umi build",
"site": "umi-api-doc static && gh-pages -d dist",
"analyze": "cross-env ANALYZE=true umi build",
"lint:style": "stylelint \"src/**/*.less\" --syntax less",
Expand Down
8 changes: 8 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';

import { version } from '../package.json';
import { getAppPath } from './utils/utils';

/*
Expand All @@ -18,8 +19,15 @@ const persistConfig = {
};

const persistEnhancer = () => createStore => (reducer, initialState, enhancer) => {
const cachedVersionId = window.localStorage.getItem('versionId');
if (cachedVersionId && cachedVersionId !== version && process.env.NODE_ENV === 'production') {
window.localStorage.clear();
}
window.localStorage.setItem('versionId', version);

const store = createStore(persistReducer(persistConfig, reducer), initialState, enhancer);
const persist = persistStore(store, null);

return {
persist,
...store,
Expand Down

0 comments on commit e3599bc

Please sign in to comment.