Skip to content

Commit

Permalink
Use initState
Browse files Browse the repository at this point in the history
  • Loading branch information
akameco committed Nov 30, 2016
1 parent d6c83ad commit 8be7f6f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 40 deletions.
45 changes: 45 additions & 0 deletions app/default-state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// @flow
import type {ColumnType as Column} from './types'

const hour = 1000 * 60 * 60

const initState: Array<Column> = [
{
id: 1,
endpoint: 'illustRanking',
timer: hour,
title: 'デイリーランキング',
query: {
opts: {
mode: 'day',
offset: 0,
},
},
},
{
id: 2,
endpoint: 'illustRanking',
timer: hour,
title: 'ウィークリーランキング',
query: {
opts: {
mode: 'week',
offset: 0,
},
},
},
{
id: 3,
endpoint: 'illustRanking',
timer: hour,
title: 'マンスリーランキング',
query: {
opts: {
mode: 'month',
offset: 0,
},
},
},
]

export default initState
37 changes: 0 additions & 37 deletions app/default-state.json

This file was deleted.

3 changes: 1 addition & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import type {State} from './types'
import configureStore from './store'
import App from './components'
import Pixiv from './repo/pixiv'
import defaultState from './default-state'
import './app.global.css'; // eslint-disable-line

async function init() {
const storage: State = localStorage.getItem('store')
let initialState: State = storage ? JSON.parse(storage) : defaultState
let initialState: State = storage ? JSON.parse(storage) : {}

const {auth, manage, columns} = initialState

Expand Down
3 changes: 2 additions & 1 deletion app/reducers/columns.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import type {Action, ColumnType as Column, Query, Params} from '../types'
import initState from '../default-state'

type State = Array<Column>;

Expand Down Expand Up @@ -37,7 +38,7 @@ function column(state: Column, action: Action): Column {
}
}

export default function columns(state: State = [], action: Action): State {
export default function columns(state: State = initState, action: Action): State {
switch (action.type) {
case 'ADD_COLUMN': {
const {id, title, endpoint, timer} = action
Expand Down

0 comments on commit 8be7f6f

Please sign in to comment.