mattermost-mobile/app/selectors/i18n.js
Harrison Healey 98abbd6dca RN-345 Additional improvements to channel switching (#926)
* RN-345 Only show refreshing indicator when channel is actually refreshing

* Added getCurrentLocale selector

* Added SwitchTeams component to channel drawer to reduce rerenders

* Reduced number of props passed from ChannelsList into children

* Removed unused prop from FilteredList

* Moved visible post calculation out of render function

* Don't set the channel to loading when not switching channels

* Added most of channel view state to blacklist
2017-09-22 11:48:30 -07:00

31 lines
862 B
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import DeviceInfo from 'react-native-device-info';
import {createSelector} from 'reselect';
import DEFAULT_LOCALE from 'app/i18n';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
export const getCurrentUserLocale = createSelector(
getCurrentUser,
(currentUser) => {
return currentUser ? currentUser.locale : '';
}
);
// Not a proper selector since the device locale isn't in the redux store
export function getCurrentLocale(state) {
const userLocale = getCurrentUserLocale(state);
if (userLocale) {
return userLocale;
}
const deviceLocale = DeviceInfo.getDeviceLocale().split('-')[0];
if (deviceLocale) {
return deviceLocale;
}
return DEFAULT_LOCALE;
}