import './main.sass'
import 'babel-polyfill'
import 'isomorphic-fetch'

import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { Router } from 'react-router'
import { updateStrings as updateTimeAgoStrings } from './vendor/time_ago_in_words'
import { persistStore } from 'redux-persist'
import localforage from 'localforage'
import store from './store'
import { browserHistory } from 'react-router'
import routes from './routes'

import './vendor/embetter'
import './vendor/embetter_initializer'

updateTimeAgoStrings({ about: '' })

const element = (
  <Provider store={store}>
    <Router history={browserHistory} routes={routes} />
  </Provider>
)

const storage = localforage.createInstance({ name: 'ello-webapp' })
const whitelist = ['authentication', 'editor', 'gui', 'json', 'profile']
const persistor = persistStore(store, { storage, whitelist }, () => {
  ReactDOM.render(element, document.getElementById('root'))
})

// check and update current version and
// only kill off the persisted reducers
if (ENV.APP_VERSION) {
  storage.getItem('APP_VERSION')
    .then((curVersion) => {
      if (curVersion && curVersion !== ENV.APP_VERSION) {
        persistor.purge(['json', 'profile'])
      }
      storage.setItem('APP_VERSION', ENV.APP_VERSION)
    })
}



@@ -576,16 +576,45 @@
  '' %7D)%0A%0A
+const APP_VERSION = '1.0.5'%0A%0A
 const el
@@ -1082,33 +1082,8 @@
 ers%0A
-if (ENV.APP_VERSION) %7B%0A  
 stor
@@ -1109,18 +1109,16 @@
 RSION')%0A
-  
   .then(
@@ -1139,18 +1139,16 @@
 %3E %7B%0A    
-  
 if (curV
@@ -1172,20 +1172,16 @@
 ion !== 
-ENV.
 APP_VERS
@@ -1187,18 +1187,16 @@
 SION) %7B%0A
-  
       pe
@@ -1212,40 +1212,20 @@
 urge
-(%5B'json', 'profile'%5D)%0A      %7D%0A  
+All()%0A    %7D%0A
     
@@ -1259,12 +1259,8 @@
 N', 
-ENV.
 APP_
@@ -1274,13 +1274,8 @@
 )%0A  
-  %7D)%0A%7D%0A
+%7D)
 %0A%0A

Move the APP_VERSION into app instead of config.