[FIX] Change server issue (#960)
* [FIX] Lazy fetch server info * [FIX] Multiple servers issues
This commit is contained in:
parent
109a247c8d
commit
3cd84a10f6
|
@ -174,6 +174,7 @@ const RocketChat = {
|
|||
this.getUserPresence();
|
||||
},
|
||||
connect({ server, user }) {
|
||||
return new Promise((resolve) => {
|
||||
database.setActiveDB(server);
|
||||
reduxStore.dispatch(connectRequest());
|
||||
|
||||
|
@ -239,6 +240,9 @@ const RocketChat = {
|
|||
}
|
||||
}
|
||||
}));
|
||||
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
|
||||
register(credentials) {
|
||||
|
|
|
@ -39,11 +39,11 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
|
|||
|
||||
if (userStringified) {
|
||||
const user = JSON.parse(userStringified);
|
||||
RocketChat.connect({ server, user });
|
||||
yield RocketChat.connect({ server, user });
|
||||
yield put(setUser(user));
|
||||
yield put(actions.appStart('inside'));
|
||||
} else {
|
||||
RocketChat.connect({ server });
|
||||
yield RocketChat.connect({ server });
|
||||
yield put(actions.appStart('outside'));
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,11 @@ const Header = React.memo(({
|
|||
}
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity onPress={onPress} testID='rooms-list-header-server-dropdown-button'>
|
||||
<TouchableOpacity
|
||||
onPress={onPress}
|
||||
testID='rooms-list-header-server-dropdown-button'
|
||||
disabled={connecting || isFetching}
|
||||
>
|
||||
{connecting ? <Text style={styles.updating}>{I18n.t('Connecting')}</Text> : null}
|
||||
{isFetching ? <Text style={styles.updating}>{I18n.t('Updating')}</Text> : null}
|
||||
<View style={styles.button}>
|
||||
|
|
|
@ -40,13 +40,14 @@ const styles = StyleSheet.create({
|
|||
});
|
||||
|
||||
const HeaderTitle = React.memo(({ connecting, isFetching }) => {
|
||||
let title = I18n.t('Messages');
|
||||
if (connecting) {
|
||||
return <Text style={styles.title}>{I18n.t('Connecting')}</Text>;
|
||||
title = I18n.t('Connecting');
|
||||
}
|
||||
if (isFetching) {
|
||||
return <Text style={styles.title}>{I18n.t('Updating')}</Text>;
|
||||
title = I18n.t('Updating');
|
||||
}
|
||||
return <Text style={styles.title}>{I18n.t('Messages')}</Text>;
|
||||
return <Text style={styles.title}>{title}</Text>;
|
||||
});
|
||||
|
||||
const Header = React.memo(({
|
||||
|
@ -57,6 +58,7 @@ const Header = React.memo(({
|
|||
onPress={onPress}
|
||||
testID='rooms-list-header-server-dropdown-button'
|
||||
style={styles.container}
|
||||
disabled={connecting || isFetching}
|
||||
>
|
||||
<HeaderTitle connecting={connecting} isFetching={isFetching} />
|
||||
<View style={styles.button}>
|
||||
|
|
|
@ -11,7 +11,7 @@ import Header from './Header';
|
|||
showServerDropdown: state.rooms.showServerDropdown,
|
||||
showSortDropdown: state.rooms.showSortDropdown,
|
||||
showSearchHeader: state.rooms.showSearchHeader,
|
||||
connecting: state.meteor.connecting,
|
||||
connecting: state.meteor.connecting || state.server.loading,
|
||||
isFetching: state.rooms.isFetching,
|
||||
serverName: state.settings.Site_Name
|
||||
}), dispatch => ({
|
||||
|
|
Loading…
Reference in New Issue