From 68c1534da674a2f5d060238defee57c64270bda1 Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 02:34:38 +0900 Subject: [PATCH 1/9] Auto rehydrate enable --- src/containers/System/reducer.js | 3 --- src/store.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/containers/System/reducer.js b/src/containers/System/reducer.js index d35e08c..1af4848 100644 --- a/src/containers/System/reducer.js +++ b/src/containers/System/reducer.js @@ -16,9 +16,6 @@ export default function(state: State = initialState, action: Action): State { ...state, selectedTab: action.target, } - case 'persist/REHYDRATE': - return action.payload.System || state - default: return state } diff --git a/src/store.js b/src/store.js index 588feb0..21d90d9 100644 --- a/src/store.js +++ b/src/store.js @@ -12,9 +12,9 @@ export default () => { reducer, compose( applyMiddleware(...middleware), + autoRehydrate(), window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(), - autoRehydrate(), ), ) persistStore(store) From ce6c52980029d908c64c5502dbe8e46cc1d7cefc Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 03:01:29 +0900 Subject: [PATCH 2/9] Delete acton connect --- .../ScreensContainer/actionTypes.js | 14 ++++++++- src/containers/ScreensContainer/actions.js | 8 +++++ src/containers/ScreensContainer/index.js | 31 +++++++++++++++++-- src/containers/ScreensContainer/logic.js | 7 +++++ src/containers/ScreensContainer/reducer.js | 3 ++ .../ScreensContainer/reducer.test.js | 7 +++++ 6 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/containers/ScreensContainer/actionTypes.js b/src/containers/ScreensContainer/actionTypes.js index 3149189..773cdd5 100644 --- a/src/containers/ScreensContainer/actionTypes.js +++ b/src/containers/ScreensContainer/actionTypes.js @@ -7,11 +7,14 @@ export const PAGE_CHANGE: 'ScreensContainer/PAGE_CHANGE' = 'ScreensContainer/PAGE_CHANGE' export const MAKE_SCREEN_PROFILE: 'ScreensContainer/MAKE_SCREEN_PROFILE' = 'ScreensContainer/MAKE_SCREEN_PROFILE' +export const DELETE_SCREEN_PROFILE: 'ScreensContainer/DELETE_SCREEN_PROFILE' = + 'ScreensContainer/DELETE_SCREEN_PROFILE' export const Actions = { LOADED_SCREEN_STORIES, PAGE_CHANGE, MAKE_SCREEN_PROFILE, + DELETE_SCREEN_PROFILE, } export type LoadedScreenStories = { @@ -33,4 +36,13 @@ export type MakeScreenProfile = { tag: string, } -export type Action = LoadedScreenStories | PageChange | MakeScreenProfile +export type DeleteScreenProfile = { + type: typeof DELETE_SCREEN_PROFILE, + screenId: number, +} + +export type Action = + | LoadedScreenStories + | PageChange + | MakeScreenProfile + | DeleteScreenProfile diff --git a/src/containers/ScreensContainer/actions.js b/src/containers/ScreensContainer/actions.js index 2670330..d9c6945 100644 --- a/src/containers/ScreensContainer/actions.js +++ b/src/containers/ScreensContainer/actions.js @@ -5,11 +5,13 @@ import { LOADED_SCREEN_STORIES, PAGE_CHANGE, MAKE_SCREEN_PROFILE, + DELETE_SCREEN_PROFILE, } from './actionTypes' import type { LoadedScreenStories, PageChange, MakeScreenProfile, + DeleteScreenProfile, } from './actionTypes' export function loadedScreenStories( @@ -38,3 +40,9 @@ export function makeScreenProfile(q: string, tag: string): MakeScreenProfile { tag, } } +export function deleteScreenProfile(screenId: number): DeleteScreenProfile { + return { + type: DELETE_SCREEN_PROFILE, + screenId, + } +} diff --git a/src/containers/ScreensContainer/index.js b/src/containers/ScreensContainer/index.js index d9b7c8a..1de8d52 100644 --- a/src/containers/ScreensContainer/index.js +++ b/src/containers/ScreensContainer/index.js @@ -2,8 +2,11 @@ import * as React from 'react' import { connect, type Connector } from 'react-redux' import _ from 'lodash' +import FlatButton from 'material-ui/FlatButton' +import FontAwesome from 'react-fontawesome' import SearchForm from '../SearchFormContainer' +import { deleteSubmit } from './logic' import type { State, Screen, System } from '../../types' import LoadingIndicator from '../../components/LoadingIndicator' @@ -15,6 +18,7 @@ import styled from 'styled-components' type Props = { screens: Screen[], system: System, + deleteSubmit: Function, } const Fixer = styled.div` @@ -26,6 +30,17 @@ const FixerMargin = styled.div` padding: 64px 0 54px; ` +function getTitle(screen: Screen): string { + if (screen.type === 'new') { + return '新着' + } else if (screen.type === 'search') { + return '検索' + } else if (screen.type === 'profile') { + return _.compact([screen.q, screen.tag]).join(' | ') + } + return '' +} + class Container extends React.Component { render() { const { props } = this @@ -39,7 +54,6 @@ class Container extends React.Component { } renderScreen(screen: Screen, display: boolean) { - const title = screen.type === 'new' ? 'Home' : screen.q return (
{ }} > - + } + onClick={() => { + this.props.deleteSubmit(screen.id) + }} + /> + } + /> {this.renderScreenMain(screen)}
@@ -75,6 +100,6 @@ const ms = (state: State) => ({ system: state.System, }) -const conn: Connector<{}, Props> = connect(ms, {}) +const conn: Connector<{}, Props> = connect(ms, { deleteSubmit }) export default conn(Container) diff --git a/src/containers/ScreensContainer/logic.js b/src/containers/ScreensContainer/logic.js index 9365e27..3a3fa00 100644 --- a/src/containers/ScreensContainer/logic.js +++ b/src/containers/ScreensContainer/logic.js @@ -60,3 +60,10 @@ export function searchSubmit(q: string, tag: string): ThunkAction { dispatch(loadScreenStory(screen)) } } + +export function deleteSubmit(screenId: number): ThunkAction { + return async (dispatch, getState) => { + await dispatch(switchTab(screenId - 1)) + await dispatch(actions.deleteScreenProfile(screenId)) + } +} diff --git a/src/containers/ScreensContainer/reducer.js b/src/containers/ScreensContainer/reducer.js index f23246c..8274355 100644 --- a/src/containers/ScreensContainer/reducer.js +++ b/src/containers/ScreensContainer/reducer.js @@ -33,6 +33,9 @@ export const initialState: State = { export default function(state: State = initialState, action: Action): State { switch (action.type) { + case Actions.DELETE_SCREEN_PROFILE: + return _.omit(state, [`${action.screenId}`]) + case Actions.MAKE_SCREEN_PROFILE: const id = Object.keys(state).length return { diff --git a/src/containers/ScreensContainer/reducer.test.js b/src/containers/ScreensContainer/reducer.test.js index aa9fbfd..ac9e4fb 100644 --- a/src/containers/ScreensContainer/reducer.test.js +++ b/src/containers/ScreensContainer/reducer.test.js @@ -80,3 +80,10 @@ test('handle MAKE_SCREEN_PROFILE', () => { }, }) }) + +test('handle DELETE_SCREEN_PROFILE', () => { + expect(reducer(initialState, actions.deleteScreenProfile(2))).toEqual({ + '0': { id: 0, page: 1, type: 'new', loaded: false }, + '1': { id: 1, page: 1, type: 'search', tag: '', q: '', loaded: false }, + }) +}) From 091e261576895ffff5233e866d16cbd1b5b61b44 Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 03:04:19 +0900 Subject: [PATCH 3/9] Tabbar label --- src/components/BottomBar/index.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/BottomBar/index.js b/src/components/BottomBar/index.js index d4cb21b..745b65b 100644 --- a/src/components/BottomBar/index.js +++ b/src/components/BottomBar/index.js @@ -2,6 +2,7 @@ import * as React from 'react' import FontAwesome from 'react-fontawesome' import styled from 'styled-components' +import _ from 'lodash' import { BottomNavigation, @@ -23,30 +24,42 @@ const Wrapper = styled.div` width: 100%; ` +function getTitle(screen: Screen): string { + if (screen.type === 'new') { + return '新着' + } else if (screen.type === 'search') { + return '検索' + } else if (screen.type === 'profile') { + return _.compact([screen.q, screen.tag]).join(' | ') + } + return '' +} + function typeConsts(screen: Screen): { iconName: string, label: string } { + const label = getTitle(screen) switch (screen.type) { case 'new': { return { iconName: 'home', - label: '新着', + label, } } case 'search': { return { iconName: 'search', - label: '検索', + label, } } case 'profile': { return { iconName: 'tag', - label: screen.q, + label, } } default: { return { iconName: '', - label: '', + label, } } } From b300a798624d12a062fbb26955e702c19f979634 Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 03:09:52 +0900 Subject: [PATCH 4/9] Safeful timeout --- src/api/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/client.js b/src/api/client.js index a94feaf..4d44907 100644 --- a/src/api/client.js +++ b/src/api/client.js @@ -27,7 +27,7 @@ const host = ? // ? 'http://localhost:3001' 'https://ssconnect.elzup.com' : 'https://ssconnect.elzup.com' -const TIMEOUT = 1000 +const TIMEOUT = 5000 const baseHeaders = { 'Content-Type': 'application/json', From 9510c5d91e3731936a217c0b23ea0a8259c61d42 Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 03:27:30 +0900 Subject: [PATCH 5/9] Rehydrate first --- src/containers/ScreensContainer/logic.js | 16 ++++++++++++++++ src/containers/System/reducer.js | 8 ++++++++ src/containers/System/reducer.test.js | 1 + src/index.js | 6 ++---- src/types/index.js | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/containers/ScreensContainer/logic.js b/src/containers/ScreensContainer/logic.js index 3a3fa00..b826107 100644 --- a/src/containers/ScreensContainer/logic.js +++ b/src/containers/ScreensContainer/logic.js @@ -8,9 +8,25 @@ import { receiveStories } from '../StoriesContainer/actions' import { receiveBlogs } from '../BlogsContainer/actions' import { switchTab } from '../System/actions' import { receiveArticles } from '../ArticlesContainer/actions' +import { loadTags } from '../TagById/logic' import * as actions from './actions' import * as selectors from './selectors' +function sleep(ms: number) { + return new Promise(r => setTimeout(r, ms)) +} + +export function thunkWorld(): ThunkAction { + return async (dispatch, getState) => { + while (!getState().System.rehydrated) { + console.log('a') + await sleep(1000) + } + dispatch(loadScreenStoryAll()) + dispatch(loadTags()) + } +} + export function loadScreenStoryAll(): ThunkAction { return (dispatch, getState) => { _.each(getState().ScreensContainer, screen => { diff --git a/src/containers/System/reducer.js b/src/containers/System/reducer.js index 1af4848..4cd46ff 100644 --- a/src/containers/System/reducer.js +++ b/src/containers/System/reducer.js @@ -6,6 +6,7 @@ import { Actions } from './actionTypes' export type State = System export const initialState: State = { + rehydrated: false, selectedTab: 1, } @@ -16,6 +17,13 @@ export default function(state: State = initialState, action: Action): State { ...state, selectedTab: action.target, } + + case 'persist/REHYDRATE': + const s = action.payload.System || state + return { + ...s, + rehydrated: true, + } default: return state } diff --git a/src/containers/System/reducer.test.js b/src/containers/System/reducer.test.js index e47c2f0..fe38677 100644 --- a/src/containers/System/reducer.test.js +++ b/src/containers/System/reducer.test.js @@ -9,6 +9,7 @@ test('provide the initial state', () => { // TODO test('handle SWITCH_TAB', () => { expect(reducer(initialState, actions.switchTab(2))).toEqual({ + rehydrated: false, selectedTab: 2, }) }) diff --git a/src/index.js b/src/index.js index fb9e448..6385759 100644 --- a/src/index.js +++ b/src/index.js @@ -5,14 +5,12 @@ import ReactDOM from 'react-dom' import App from './containers/App' import registerServiceWorker from './registerServiceWorker' import configureStore from './store' -import { loadScreenStoryAll } from './containers/ScreensContainer/logic' -import { loadTags } from './containers/TagById/logic' +import { thunkWorld } from './containers/ScreensContainer/logic' import './injectGlobal' import './initialize' const store = configureStore() -store.dispatch(loadScreenStoryAll()) -store.dispatch(loadTags()) +store.dispatch(thunkWorld()) ReactDOM.render( diff --git a/src/types/index.js b/src/types/index.js index 37661e7..f29e91c 100644 --- a/src/types/index.js +++ b/src/types/index.js @@ -135,6 +135,7 @@ export type ScreenNoLoaded = export type Screen = ScreenLoaded | ScreenNoLoaded export type System = { + rehydrated: boolean, selectedTab: number, } From 881510940a377aa8d3215adf0a2d5fc5235b18b4 Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 03:30:25 +0900 Subject: [PATCH 6/9] Config gh-pages --- package.json | 117 +++++++++++++++++++++++++-------------------------- yarn.lock | 38 +++++++++++++++-- 2 files changed, 93 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index 1e97e14..9a2b6a4 100644 --- a/package.json +++ b/package.json @@ -1,61 +1,60 @@ { - "name": "ssconnect", - "version": "0.1.0", - "private": true, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test --env=jsdom", - "eject": "react-scripts eject", - "s2s": "s2s", - "storybook": "start-storybook -p 9009 -s public", - "build-storybook": "build-storybook -s public", - "precommit": "lint-staged" - }, - "dependencies": { - "camelcase-keys": "^4.1.0", - "lodash": "^4.17.4", - "material-ui": "^0.19.4", - "moment": "^2.19.1", - "normalizr": "^3.2.4", - "react": "^16.0.0", - "react-dom": "^16.0.0", - "react-fontawesome": "^1.6.1", - "react-redux": "^5.0.6", - "react-scripts": "1.0.14", - "redux": "^3.7.2", - "redux-persist": "^4.10.1", - "redux-thunk": "^2.2.0", - "styled-components": "^2.2.1", - "superagent": "^3.8.0" - }, - "devDependencies": { - "@storybook/addon-actions": "^3.2.12", - "@storybook/addon-links": "^3.2.12", - "@storybook/react": "^3.2.12", - "babel-eslint": "^7.2.3", - "enzyme": "^3.0.0", - "enzyme-adapter-react-16": "^1.0.0", - "enzyme-to-json": "^3.0.1", - "eslint": "^4.1.1", - "eslint-config-react-app": "^2.0.1", - "eslint-plugin-flowtype": "^2.34.1", - "eslint-plugin-import": "^2.6.0", - "eslint-plugin-jsx-a11y": "^5.1.1", - "eslint-plugin-react": "^7.1.0", - "flow-bin": "^0.56.0", - "husky": "^0.14.3", - "lint-staged": "^4.3.0", - "prettier": "^1.7.4", - "react-test-renderer": "^16.0.0", - "s2s": "^0.7.0", - "s2s-plugins-redux": "^0.1.0", - "storybook-addon-material-ui": "^0.8.2" - }, - "lint-staged": { - "*.js": [ - "prettier --config ./.prettierrc --write", - "git add" - ] - } + "name": "ssconnect", + "version": "0.1.0", + "private": true, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject", + "s2s": "s2s", + "storybook": "start-storybook -p 9009 -s public", + "build-storybook": "build-storybook -s public", + "deploy": "gh-pages -d build", + "precommit": "lint-staged" + }, + "dependencies": { + "camelcase-keys": "^4.1.0", + "lodash": "^4.17.4", + "material-ui": "^0.19.4", + "moment": "^2.19.1", + "normalizr": "^3.2.4", + "react": "^16.0.0", + "react-dom": "^16.0.0", + "react-fontawesome": "^1.6.1", + "react-redux": "^5.0.6", + "react-scripts": "1.0.14", + "redux": "^3.7.2", + "redux-persist": "^4.10.1", + "redux-thunk": "^2.2.0", + "styled-components": "^2.2.1", + "superagent": "^3.8.0" + }, + "devDependencies": { + "@storybook/addon-actions": "^3.2.12", + "@storybook/addon-links": "^3.2.12", + "@storybook/react": "^3.2.12", + "babel-eslint": "^7.2.3", + "enzyme": "^3.0.0", + "enzyme-adapter-react-16": "^1.0.0", + "enzyme-to-json": "^3.0.1", + "eslint": "^4.1.1", + "eslint-config-react-app": "^2.0.1", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.0", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.1.0", + "flow-bin": "^0.56.0", + "gh-pages": "^1.0.0", + "husky": "^0.14.3", + "lint-staged": "^4.3.0", + "prettier": "^1.7.4", + "react-test-renderer": "^16.0.0", + "s2s": "^0.7.0", + "s2s-plugins-redux": "^0.1.0", + "storybook-addon-material-ui": "^0.8.2" + }, + "lint-staged": { + "*.js": ["prettier --config ./.prettierrc --write", "git add"] + } } diff --git a/yarn.lock b/yarn.lock index 6f1e266..2de53f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -438,6 +438,12 @@ async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" +async@2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/async/-/async-2.1.4.tgz#2d2160c7788032e4dd6cbe2502f1f9a2c8f6cde4" + dependencies: + lodash "^4.14.0" + async@^1.4.0, async@^1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" @@ -1634,6 +1640,10 @@ base64-js@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886" +base64url@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/base64url/-/base64url-2.0.0.tgz#eac16e03ea1438eff9423d69baa36262ed1f70bb" + batch@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" @@ -2160,6 +2170,12 @@ commander@2.11.x, commander@^2.11.0, commander@^2.9.0, commander@~2.11.0: version "2.11.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + common-tags@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.4.0.tgz#1187be4f3d4cf0c0427d43f74eef1f73501614c0" @@ -3580,7 +3596,7 @@ fresh@0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" -fs-extra@3.0.1: +fs-extra@3.0.1, fs-extra@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291" dependencies: @@ -3681,6 +3697,18 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +gh-pages@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-1.0.0.tgz#4a46f4c25439f7a2b7e6835504d4a49e949f04ca" + dependencies: + async "2.1.4" + base64url "^2.0.0" + commander "2.9.0" + fs-extra "^3.0.1" + globby "^6.1.0" + graceful-fs "4.1.11" + rimraf "^2.5.4" + glamor@^2.20.40: version "2.20.40" resolved "https://registry.yarnpkg.com/glamor/-/glamor-2.20.40.tgz#f606660357b7cf18dface731ad1a2cfa93817f05" @@ -3797,10 +3825,14 @@ got@^5.0.0: unzip-response "^1.0.2" url-parse-lax "^1.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@4.1.11, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" @@ -7187,7 +7219,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.1: +rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: From 98c07a88907ff262ac037cc75a4c5c48900c72d7 Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 03:53:55 +0900 Subject: [PATCH 7/9] Fix Build depend --- package.json | 3 ++- yarn.lock | 19 +++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 9a2b6a4..f02d1ad 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,9 @@ "deploy": "gh-pages -d build", "precommit": "lint-staged" }, + "homepage": "https://ssconnect.github.io/ssconnect", "dependencies": { - "camelcase-keys": "^4.1.0", + "camelcase-keys": "^3.0.0", "lodash": "^4.17.4", "material-ui": "^0.19.4", "moment": "^2.19.1", diff --git a/yarn.lock b/yarn.lock index 2de53f7..12eaec3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1912,13 +1912,12 @@ camelcase-keys@^2.0.0: camelcase "^2.0.0" map-obj "^1.0.0" -camelcase-keys@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.1.0.tgz#214d348cc5457f39316a2c31cc3e37246325e73f" +camelcase-keys@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-3.0.0.tgz#fc0c6c360363f7377e3793b9a16bccf1070c1ca4" dependencies: - camelcase "^4.1.0" - map-obj "^2.0.0" - quick-lru "^1.0.0" + camelcase "^3.0.0" + map-obj "^1.0.0" camelcase@^1.0.2: version "1.2.1" @@ -5326,10 +5325,6 @@ map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" -map-obj@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" - material-ui@^0.19.4: version "0.19.4" resolved "https://registry.yarnpkg.com/material-ui/-/material-ui-0.19.4.tgz#ca9cdca8aa8bb594dfac5db38ec9ff045a323587" @@ -6541,10 +6536,6 @@ querystringify@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb" -quick-lru@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" - radium@^0.19.0: version "0.19.5" resolved "https://registry.yarnpkg.com/radium/-/radium-0.19.5.tgz#2352ffa9c2265ea7c76e07540d9841727f85dbe8" From 162dedc47d1a050d74fa784bb61c66e2f949f18e Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 03:58:47 +0900 Subject: [PATCH 8/9] Safe empty result --- src/api/client.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/client.js b/src/api/client.js index 4d44907..48578aa 100644 --- a/src/api/client.js +++ b/src/api/client.js @@ -81,7 +81,13 @@ export async function getStories( const camelizedData = camelcaseKeys(normalizedData, { deep: true }) const pageInfo = getPageInfo(res) - return { ..._.mapValues(camelizedData.entities, _.values), pageInfo } + return { + stories: [], + articles: [], + blogs: [], + ..._.mapValues(camelizedData.entities, _.values), + pageInfo, + } } function getPageInfo(res: any): PageInfo { From 9770576ccd4080ce5d8f3581fde13d151c0ac1f7 Mon Sep 17 00:00:00 2001 From: elzup Date: Mon, 30 Oct 2017 04:08:38 +0900 Subject: [PATCH 9/9] Solve Dependency --- package.json | 7 +++++-- src/api/client.js | 6 +++--- yarn.lock | 13 ++++++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index f02d1ad..9abe9f3 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ }, "homepage": "https://ssconnect.github.io/ssconnect", "dependencies": { - "camelcase-keys": "^3.0.0", + "camelcase-keys-recursive": "^0.8.2", "lodash": "^4.17.4", "material-ui": "^0.19.4", "moment": "^2.19.1", @@ -56,6 +56,9 @@ "storybook-addon-material-ui": "^0.8.2" }, "lint-staged": { - "*.js": ["prettier --config ./.prettierrc --write", "git add"] + "*.js": [ + "prettier --config ./.prettierrc --write", + "git add" + ] } } diff --git a/src/api/client.js b/src/api/client.js index 48578aa..5f1aada 100644 --- a/src/api/client.js +++ b/src/api/client.js @@ -1,6 +1,6 @@ // @flow -import camelcaseKeys from 'camelcase-keys' +import camelcaseKeysRecursive from 'camelcase-keys-recursive' import { normalizeStories } from './normalize' import request from 'superagent' import _ from 'lodash' @@ -78,7 +78,7 @@ export async function getStories( // { stories: res.data, pageInfo: FeedClient.getPageInfo(res) } const normalizedData = normalizeStories(res.body) - const camelizedData = camelcaseKeys(normalizedData, { deep: true }) + const camelizedData = camelcaseKeysRecursive(normalizedData, { deep: true }) const pageInfo = getPageInfo(res) return { @@ -107,5 +107,5 @@ export async function getTags(timeout: number = TIMEOUT): Promise { }) }) - return _.values(camelcaseKeys(res.body, { deep: true })) + return _.values(camelcaseKeysRecursive(res.body, { deep: true })) } diff --git a/yarn.lock b/yarn.lock index 12eaec3..3a2d2fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1905,6 +1905,12 @@ camel-case@3.0.x: no-case "^2.2.0" upper-case "^1.1.1" +camelcase-keys-recursive@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/camelcase-keys-recursive/-/camelcase-keys-recursive-0.8.2.tgz#06df121fbff46cd890350072cdff5657396f7d3a" + dependencies: + map-obj "^1.0.0" + camelcase-keys@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" @@ -1912,13 +1918,6 @@ camelcase-keys@^2.0.0: camelcase "^2.0.0" map-obj "^1.0.0" -camelcase-keys@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-3.0.0.tgz#fc0c6c360363f7377e3793b9a16bccf1070c1ca4" - dependencies: - camelcase "^3.0.0" - map-obj "^1.0.0" - camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39"