diff options
| author | Kamran Ahmed <kamranahmed.se@gmail.com> | 2018-10-15 18:21:36 +0400 |
|---|---|---|
| committer | Kamran Ahmed <kamranahmed.se@gmail.com> | 2018-10-15 18:21:36 +0400 |
| commit | fb142d6bab22a39d19f2c41b24f899b59371c407 (patch) | |
| tree | 95e0d6b12dcfbd94cb3270497dae549dde84e871 /src/redux | |
| parent | Add gh-pages deployment (diff) | |
| download | githunt-fb142d6bab22a39d19f2c41b24f899b59371c407.tar.gz | |
Add redux persist expire and update dependencies
Diffstat (limited to 'src/redux')
| -rw-r--r-- | src/redux/github/transform.js | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/src/redux/github/transform.js b/src/redux/github/transform.js index ffae7f8..9a4f747 100644 --- a/src/redux/github/transform.js +++ b/src/redux/github/transform.js @@ -1,20 +1,10 @@ import { createTransform } from 'redux-persist'; -import moment from 'moment'; -import { initialState } from './reducer'; const GithubTransform = createTransform( // transform state on its way to being serialized and persisted. (inboundState, key) => { inboundState = inboundState || {}; - // If given data does not have persistence configuration before - if (!inboundState.__persisted_at) { - inboundState = { - ...inboundState, - __persisted_at: moment() - }; - } - // Keep the first group only to avoid overflowing the storage if (inboundState.repositories && inboundState.repositories.length > 1) { inboundState = { @@ -37,25 +27,7 @@ const GithubTransform = createTransform( }, // transform state being rehydrated (outboundState, key) => { - outboundState = outboundState || {}; - - if (outboundState.__persisted_at) { - const startTime = moment(outboundState.__persisted_at); - const endTime = moment(); - - const duration = moment.duration(endTime.diff(startTime)); - const seconds = duration.asSeconds(); - - // If the state is more than one hour old - // reset it to initial state - if (seconds > 3600) { - return { - ...initialState - }; - } - } - - return outboundState; + return { ...outboundState }; }, // define which reducers this transform gets called for. { |
