@@ -15,11 +15,11 @@ import {
1515import { SanityActions } from './store/sanity'
1616import { CURRENT_VERSION } from './store/reducers'
1717import { isCoreEndpointDisabled } from './utils/window-utils'
18- import { openInNewTab } from './utils'
1918import Modal from 'react-modal'
2019import NotificationsSystem from 'reapop'
2120import NotificationsTheme from 'reapop-theme-wybo'
2221import { hot } from 'react-hot-loader'
22+ import { selectLastUpdatedApps } from './store/apps/selectors'
2323
2424import log4js from 'log4js'
2525
@@ -38,17 +38,19 @@ function mapStateToProps(state) {
3838 coreApiPasswordValid : state . sanity . coreApiPasswordValid ,
3939 walletPaymentAddressUrl : state . settings . api . walletPaymentAddressUrl ,
4040 coreAPIPassword : state . settings . api . coreAPIPassword ,
41- instanceIdentifier : state . apps . instanceIdentifier
41+ instanceIdentifier : state . apps . instanceIdentifier ,
42+ lastUpdatedApps : selectLastUpdatedApps ( state )
4243 }
4344}
4445
45- function mapDispatchToProps ( dispatch ) {
46+ const mapDispatchToProps = dispatch => {
4647 return bindActionCreators (
4748 {
4849 updateApi : SettingsActions . updateApi ,
4950 isCoreRunning : SanityActions . isCoreRunning ,
5051 isCoreApiPasswordValid : SanityActions . isCoreApiPasswordValid ,
51- generateInstanceIdentifier : AppsActions . generateInstanceIdentifier
52+ generateInstanceIdentifier : AppsActions . generateInstanceIdentifier ,
53+ doFetchApps : AppsActions . doFetchApps
5254 } ,
5355 dispatch
5456 )
@@ -71,12 +73,14 @@ class AppContainer extends Component {
7173 isCoreRunning : PropTypes . func . isRequired ,
7274 isCoreApiPasswordValid : PropTypes . func . isRequired ,
7375 generateInstanceIdentifier : PropTypes . func . isRequired ,
76+ doFetchApps : PropTypes . func . isRequired ,
7477 walletPaymentAddressUrl : PropTypes . string . isRequired ,
7578 coreAPIPassword : PropTypes . string ,
7679 stateVersion : PropTypes . number ,
7780 router : PropTypes . object . isRequired ,
7881 location : PropTypes . object . isRequired ,
79- instanceIdentifier : PropTypes . string
82+ instanceIdentifier : PropTypes . string ,
83+ lastUpdatedApps : PropTypes . number
8084 }
8185
8286 constructor ( props ) {
@@ -160,6 +164,14 @@ class AppContainer extends Component {
160164 search : this . props . location . search
161165 } )
162166 }
167+
168+ if (
169+ ! this . props . lastUpdatedApps ||
170+ Date . now ( ) - this . props . lastUpdatedApps > 900000 // 15 min
171+ ) {
172+ // Fetch those apps if data is state
173+ this . props . doFetchApps ( )
174+ }
163175 }
164176
165177 componentWillReceiveProps ( nextProps ) {
@@ -171,6 +183,7 @@ class AppContainer extends Component {
171183
172184 if ( ! this . props . coreApiRunning ) {
173185 // TODO connect to future notification system here
186+ // TODO is this even used anymore?
174187 logger . error ( 'Sanity check: Error! Core API is NOT running!' )
175188 }
176189
@@ -192,10 +205,6 @@ class AppContainer extends Component {
192205 }
193206 }
194207
195- onSupportClick = ( ) => {
196- openInNewTab ( 'https://forum.blockstack.org/t/frequently-ask-questions/2123' )
197- }
198-
199208 closeModal ( ) {
200209 this . setState ( { modalIsOpen : false } )
201210 }
0 commit comments