From 3b7fadcc69c86d9e8efc3c34f1b495c3c1335995 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 16 Feb 2019 19:22:25 +0000 Subject: [PATCH] Set the locale based on the settings. Partially fixes #4 --- src/SyncGate.tsx | 11 ++++++++++- src/components/Calendar.tsx | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/SyncGate.tsx b/src/SyncGate.tsx index bea2b6c..288a42e 100644 --- a/src/SyncGate.tsx +++ b/src/SyncGate.tsx @@ -3,6 +3,9 @@ import { connect } from 'react-redux'; import { Action } from 'redux-actions'; import { Route, Switch, Redirect, RouteComponentProps, withRouter } from 'react-router'; +import * as moment from 'moment'; +import 'moment/locale/en-gb'; + import { List, Map } from 'immutable'; import { createSelector } from 'reselect'; @@ -19,7 +22,7 @@ import Pim from './Pim'; import * as EteSync from './api/EteSync'; import { CURRENT_VERSION } from './api/Constants'; -import { store, JournalsType, EntriesType, StoreState, CredentialsData, UserInfoType } from './store'; +import { store, SettingsType, JournalsType, EntriesType, StoreState, CredentialsData, UserInfoType } from './store'; import { addJournal, fetchAll, fetchEntries, fetchUserInfo, createUserInfo } from './store/actions'; export interface SyncInfoJournal { @@ -36,6 +39,7 @@ interface PropsType { } type PropsTypeInner = RouteComponentProps<{}> & PropsType & { + settings: SettingsType; journals: JournalsType; entries: EntriesType; userInfo: UserInfoType; @@ -181,6 +185,10 @@ class SyncGate extends React.PureComponent { return (); } + // FIXME: Shouldn't be here + moment.locale(this.props.settings.locale); + + const journalMap = syncInfoSelector(this.props); return ( @@ -235,6 +243,7 @@ class SyncGate extends React.PureComponent { const mapStateToProps = (state: StoreState, props: PropsType) => { return { + settings: state.settings, journals: state.cache.journals, entries: state.cache.entries, userInfo: state.cache.userInfo, diff --git a/src/components/Calendar.tsx b/src/components/Calendar.tsx index 8e8e280..f58b736 100644 --- a/src/components/Calendar.tsx +++ b/src/components/Calendar.tsx @@ -2,14 +2,12 @@ import * as React from 'react'; import BigCalendar, { View } from 'react-big-calendar'; import 'react-big-calendar/lib/css/react-big-calendar.css'; import * as moment from 'moment'; -import 'moment/locale/en-gb'; import * as ICAL from 'ical.js'; import { EventType } from '../pim-types'; import './Calendar.css'; -moment.locale('en-gb'); const calendarLocalizer = BigCalendar.momentLocalizer(moment); const MAX_RECURRENCE_DATE = ICAL.Time.now();