-
-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework providers and the rest root components (#1148)
- Loading branch information
1 parent
59324dd
commit 5b16724
Showing
21 changed files
with
196 additions
and
172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* @flow */ | ||
import { PureComponent } from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { Actions } from '../types'; | ||
import boundActions from '../boundActions'; | ||
|
||
class AppDataFetcher extends PureComponent { | ||
props: { | ||
needsInitialFetch: boolean, | ||
actions: Actions, | ||
children?: any, | ||
}; | ||
|
||
componentWillMount = () => this.init(this.props); | ||
|
||
componentWillReceiveProps = nextProps => this.init(nextProps); | ||
|
||
init = props => { | ||
const { actions, needsInitialFetch } = props; | ||
|
||
if (needsInitialFetch) { | ||
actions.doInitialFetch(); | ||
} | ||
}; | ||
|
||
render() { | ||
return this.props.children; | ||
} | ||
} | ||
|
||
export default connect( | ||
state => ({ | ||
needsInitialFetch: state.app.needsInitialFetch, | ||
}), | ||
boundActions, | ||
)(AppDataFetcher); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* @flow */ | ||
import React, { PureComponent } from 'react'; | ||
import { Text } from 'react-native'; | ||
import { connect } from 'react-redux'; | ||
import { IntlProvider } from 'react-intl'; | ||
|
||
import '../../vendor/intl/intl'; | ||
import messages from '../i18n/messages'; | ||
|
||
require('../i18n/locale'); | ||
|
||
class TranslationProvider extends PureComponent { | ||
props: { | ||
locale: string, | ||
children?: any, | ||
}; | ||
|
||
render() { | ||
const { locale, children } = this.props; | ||
|
||
return ( | ||
<IntlProvider key={locale} locale={locale} textComponent={Text} messages={messages[locale]}> | ||
{children} | ||
</IntlProvider> | ||
); | ||
} | ||
} | ||
|
||
export default connect(state => ({ | ||
locale: state.settings.locale, | ||
}))(TranslationProvider); |
2 changes: 1 addition & 1 deletion
2
src/__tests__/StylesProvider-test.js → src/boot/__tests/StylesProvider-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* @flow */ | ||
import { combineReducers } from 'redux'; | ||
|
||
import config from '../config'; | ||
import { enableBatching, logSlowReducers } from '../utils/redux'; | ||
|
||
import accounts from '../account/accountReducers'; | ||
import alertWords from '../alertWords/alertWordsReducer'; | ||
import app from '../app/appReducers'; | ||
import caughtUp from '../caughtup/caughtUpReducers'; | ||
import chat from '../chat/chatReducers'; | ||
import fetching from '../chat/fetchingReducers'; | ||
import flags from '../chat/flagsReducers'; | ||
import mute from '../mute/muteReducers'; | ||
import nav from '../nav/navReducers'; | ||
import realm from '../realm/realmReducers'; | ||
import outbox from '../outbox/outboxReducers'; | ||
import drafts from '../drafts/draftsReducers'; | ||
import settings from '../settings/settingsReducers'; | ||
import streams from '../streams/streamsReducers'; | ||
import subscriptions from '../subscriptions/subscriptionsReducers'; | ||
import typing from '../typing/typingReducers'; | ||
import unreadStreams from '../unread/unreadStreamsReducers'; | ||
import unreadPms from '../unread/unreadPmsReducers'; | ||
import unreadHuddles from '../unread/unreadHuddlesReducers'; | ||
import unreadMentions from '../unread/unreadMentionsReducers'; | ||
import users from '../users/usersReducers'; | ||
import presence from '../presence/presenceReducers'; | ||
|
||
const reducers = { | ||
accounts, | ||
alertWords, | ||
app, | ||
caughtUp, | ||
chat, | ||
fetching, | ||
drafts, | ||
flags, | ||
mute, | ||
nav, | ||
presence, | ||
realm, | ||
outbox, | ||
settings, | ||
streams, | ||
subscriptions, | ||
typing, | ||
unread: combineReducers({ | ||
streams: unreadStreams, | ||
pms: unreadPms, | ||
huddles: unreadHuddles, | ||
mentions: unreadMentions, | ||
}), | ||
users, | ||
}; | ||
|
||
export default enableBatching( | ||
combineReducers(config.enableReduxSlowReducerWarnings ? logSlowReducers(reducers) : reducers), | ||
); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.