diff options
Diffstat (limited to '')
| -rw-r--r-- | src/components/repository-grid/grid-item/index.js | 9 | ||||
| -rw-r--r-- | src/components/repository-list/list-item/index.js | 8 | ||||
| -rw-r--r-- | src/redux/github/transform.js | 30 | ||||
| -rw-r--r-- | src/store.js | 9 |
4 files changed, 21 insertions, 35 deletions
diff --git a/src/components/repository-grid/grid-item/index.js b/src/components/repository-grid/grid-item/index.js index ac7c9c2..582d348 100644 --- a/src/components/repository-grid/grid-item/index.js +++ b/src/components/repository-grid/grid-item/index.js @@ -13,7 +13,7 @@ class GridItem extends React.Component { <div className="col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 grid-item-container"> <div className="grid-item-body"> <div className="author-header clearfix"> - <a href={ this.props.repository.owner.html_url } target="_blank"> + <a href={ this.props.repository.owner.html_url } rel="noopener noreferrer" target="_blank"> <div className="author-img"> <img src={ this.props.repository.owner.avatar_url } onError={ (e) => { @@ -29,12 +29,12 @@ class GridItem extends React.Component { </div> <div className="repo-header"> <h5> - <a href={ this.props.repository.html_url } target="_blank"> + <a href={ this.props.repository.html_url } rel="noopener noreferrer" target="_blank"> <span className="repo-name">{ this.props.repository.name }</span> </a> </h5> <p className="repo-meta text-muted small"> - Built by · <a target="_blank" href={ this.props.repository.owner.html_url }>{ this.props.repository.owner.login }</a> · { moment(this.props.repository.created_at).format('MMMM D, YYYY') } + Built by · <a target="_blank" rel="noopener noreferrer" href={ this.props.repository.owner.html_url }>{ this.props.repository.owner.login }</a> · { moment(this.props.repository.created_at).format('MMMM D, YYYY') } </p> </div> <div className="repo-body"> @@ -53,18 +53,21 @@ class GridItem extends React.Component { } <a className="muted-link d-inline-block mr-3" href={ `${this.props.repository.html_url}/stargazers` } + rel="noopener noreferrer" target="_blank"> <Star/> { this.props.repository.stargazers_count.toLocaleString() } </a> <a className="muted-link d-inline-block mr-3" href={ `${this.props.repository.html_url}/network/members` } + rel="noopener noreferrer" target="_blank"> <Fork/> { this.props.repository.forks.toLocaleString() } </a> <a className="muted-link d-inline-block mr-3" href={ `${this.props.repository.html_url}/watchers` } + rel="noopener noreferrer" target="_blank"> <Watcher/> { this.props.repository.watchers.toLocaleString() } diff --git a/src/components/repository-list/list-item/index.js b/src/components/repository-list/list-item/index.js index 1d9bcac..0a93ae6 100644 --- a/src/components/repository-list/list-item/index.js +++ b/src/components/repository-list/list-item/index.js @@ -14,12 +14,12 @@ class ListItem extends React.Component { <div className="list-item-body"> <div className="repo-header"> <h3> - <a href={ this.props.repository.html_url } target="_blank"> + <a href={ this.props.repository.html_url } rel="noopener noreferrer" target="_blank"> <span className="text-normal">{ this.props.repository.owner.login } / </span> { this.props.repository.name } </a> </h3> - <p className="repo-meta text-muted small">Built by · <a href={ this.props.repository.owner.html_url } target="_blank">{ this.props.repository.owner.login }</a> · { moment(this.props.repository.created_at).format('MMMM D YYYY') }</p> + <p className="repo-meta text-muted small">Built by · <a href={ this.props.repository.owner.html_url } rel="noopener noreferrer" target="_blank">{ this.props.repository.owner.login }</a> · { moment(this.props.repository.created_at).format('MMMM D YYYY') }</p> </div> <div className="repo-body"> <p>{ this.props.repository.description || 'No description given.' }</p> @@ -37,18 +37,21 @@ class ListItem extends React.Component { } <a className="muted-link d-inline-block mr-3" href={ `${this.props.repository.html_url}/stargazers` } + rel="noopener noreferrer" target="_blank"> <Star/> { this.props.repository.stargazers_count.toLocaleString() } </a> <a className="muted-link d-inline-block mr-3" href={ `${this.props.repository.html_url}/network/members` } + rel="noopener noreferrer" target="_blank"> <Fork/> { this.props.repository.forks.toLocaleString() } </a> <a className="muted-link d-inline-block mr-3" href={ `${this.props.repository.html_url}/watchers` } + rel="noopener noreferrer" target="_blank"> <Watcher/> { this.props.repository.watchers.toLocaleString() } @@ -58,6 +61,7 @@ class ListItem extends React.Component { <a href={ this.props.repository.owner.html_url } target="_blank" + rel="noopener noreferrer" className="author-link d-none d-lg-block d-xl-block d-md-block"> <img className='author-img' src={ this.props.repository.owner.avatar_url } 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. { diff --git a/src/store.js b/src/store.js index c8e72b1..cab211a 100644 --- a/src/store.js +++ b/src/store.js @@ -4,8 +4,10 @@ import { persistReducer, persistStore } from 'redux-persist'; import { applyMiddleware, createStore } from 'redux'; import storage from 'redux-persist/lib/storage'; import thunk from 'redux-thunk'; +import expireReducer from 'redux-persist-expire'; import GithubTransform from './redux/github/transform'; +import githubState from './redux/github/reducer'; import rootReducer from './redux/reducers'; const persistedReducers = persistReducer( @@ -14,7 +16,12 @@ const persistedReducers = persistReducer( storage: storage, stateReconciler: autoMergeLevel2, transforms: [ - GithubTransform + GithubTransform, + expireReducer('github', { + expireSeconds: 3600, + expiredState: { ...githubState }, + autoExpire: true + }) ] }, rootReducer, |
