Skip to content

Commit

Permalink
fix(store): Import empty store if a store is not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorgerhardt committed Feb 28, 2019
1 parent 5b2f6b7 commit c499aeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 7 additions & 4 deletions store.json.tmp → empty-store.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"allowChangeConfig": true,
"actionLog": [],
"grids": [],
"networks": [],
"poiUrl": null,
"start" null,
"end": null,
"geocoder": {
"types": "country,region,postcode,district,place,locality,neighborhood,address,poi"
"types": "region,postcode,district,place,locality,neighborhood,address,poi"
},
"map": {
"accessToken": "",
Expand All @@ -13,9 +16,9 @@
"zoom": 11
},
"fetches": 0,
"searchPoiOnly": false,
"showLink": true,
"showLog": true,
"timeCutoff": 60,
"title": "Taui",
"allowChangeConfig": true
"timeCutoff": 30,
"title": "Taui"
}
8 changes: 7 additions & 1 deletion pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import nextCookies from 'next-cookies'
import React from 'react'
import {Provider} from 'react-redux'

import defaultStore from '../store.json'
// import defaultStore from '../store.json'
import {getOrCreateStore} from '../src/with-redux-store'

function tryParse (v) {
Expand All @@ -18,10 +18,16 @@ function tryParse (v) {
}
}

function loadStoreJSON () {
return import('../store.json').catch(() => import('../empty-store.json'))
}

const iconLink = 'https://d2f1n6ed3ipuic.cloudfront.net/conveyal-128x128.png'

export default class TauiApp extends App {
static async getInitialProps ({ctx}) {
const defaultStore = await loadStoreJSON()

// Get the configuration from the cookies
const {tauiConfig} = nextCookies(ctx)
const cookieConfig = typeof tauiConfig === 'string'
Expand Down

0 comments on commit c499aeb

Please sign in to comment.