...
 
Commits (2)
......@@ -13,7 +13,7 @@ function currentSpeech(state) {
}
const now = Math.round(Date.now() / 1000),
duration = now - current.startedAt,
overtime = duration > state.limits.maxTime,
overtime = duration > state.config.limits.maxTime,
startDate = new Date(current.startedAt * 1000);
return {
timestamp: startDate.toISOString(),
......
import React, { Component } from "react";
import Button from "@material-ui/core/Button";
import Icon from "@material-ui/core/Icon";
import { defineMessages, FormattedMessage } from "react-intl";
import { defineMessages, FormattedMessage, injectIntl } from "react-intl";
const messages = defineMessages({
export: {
......@@ -87,4 +87,4 @@ class ExportButton extends Component {
}
}
export default ExportButton;
export default injectIntl(ExportButton);
......@@ -4,8 +4,8 @@ import Timer from "../components/Timer";
const mapStateToProps = (state, ownProps) => {
return {
ticker: state.current.ticker,
maxTime: state.limits.maxTime,
warnTime: state.limits.warnTime
maxTime: state.config.limits.maxTime,
warnTime: state.config.limits.warnTime
};
};
......
......@@ -4,7 +4,7 @@ import TimerLimitEdit from "../components/TimerLimitEdit";
const mapStateToProps = (state, ownProps) => {
return {
maxTime: state.limits.maxTime
maxTime: state.config.limits.maxTime
};
};
......
......@@ -12,9 +12,11 @@ import {
const MAX_TIME = 2 * 60 + 30; // 2:30
const initialState = {
limits: {
maxTime: MAX_TIME,
warnTime: MAX_TIME - MAX_TIME / 5
config: {
limits: {
maxTime: MAX_TIME,
warnTime: MAX_TIME - MAX_TIME / 5
}
},
current: {
ticker: null,
......@@ -26,7 +28,7 @@ const initialState = {
speeches: []
};
function limits(state = initialState.limits, action) {
function limits(state = initialState.config.limits, action) {
switch (action.type) {
case CHANGE_TIMER_LIMIT:
return {
......@@ -34,7 +36,7 @@ function limits(state = initialState.limits, action) {
warnTime: action.warnTime
};
case RESET:
return initialState.limits;
return initialState.config.limits;
default:
return state;
}
......@@ -94,7 +96,9 @@ function speeches(state = initialState.speeches, action) {
}
const rootReducer = combineReducers({
limits,
config: combineReducers({
limits
}),
current,
speeches
});
......
import thunkMiddleware from "redux-thunk";
import { createStore, applyMiddleware } from "redux";
import { persistStore, persistReducer } from "redux-persist";
import { createMigrate, persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage";
import rootReducer from "./reducers";
const migrations = {
0: state => state, // initial version, no-op
1: state => {
// migration to keep only device state
let newState = {
...state,
config: { limits: { ...state.limits } }
};
delete newState.limits;
return newState;
}
};
const persistConfig = {
key: "root",
storage,
blacklist: ["current"]
blacklist: ["current"],
version: 1,
migrate: createMigrate(migrations)
};
const persistedReducer = persistReducer(persistConfig, rootReducer);
export default function configureStore() {
const persistedReducer = persistReducer(persistConfig, rootReducer);
const store = createStore(
persistedReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ &&
......