Create single-server
This commit is contained in:
parent
9bea72faac
commit
6e66897089
3
app.json
3
app.json
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"name": "RocketChatRN",
|
||||
"share": "ShareRocketChatRN",
|
||||
"displayName": "RocketChatRN"
|
||||
"displayName": "RocketChatRN",
|
||||
"server": "https://open.rocket.chat"
|
||||
}
|
14
app/index.js
14
app/index.js
|
@ -67,13 +67,13 @@ const parseDeepLinking = (url) => {
|
|||
|
||||
// Outside
|
||||
const OutsideStack = createStackNavigator({
|
||||
OnboardingView: {
|
||||
getScreen: () => require('./views/OnboardingView').default,
|
||||
header: null
|
||||
},
|
||||
NewServerView: {
|
||||
getScreen: () => require('./views/NewServerView').default
|
||||
},
|
||||
// OnboardingView: {
|
||||
// getScreen: () => require('./views/OnboardingView').default,
|
||||
// header: null
|
||||
// },
|
||||
// NewServerView: {
|
||||
// getScreen: () => require('./views/NewServerView').default
|
||||
// },
|
||||
LoginSignupView: {
|
||||
getScreen: () => require('./views/LoginSignupView').default
|
||||
},
|
||||
|
|
|
@ -5,7 +5,7 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
|
|||
import RNBootSplash from 'react-native-bootsplash';
|
||||
|
||||
import * as actions from '../actions';
|
||||
import { selectServerRequest } from '../actions/server';
|
||||
import { selectServerRequest, serverRequest } from '../actions/server';
|
||||
import { setAllPreferences } from '../actions/sortPreferences';
|
||||
import { toggleCrashReport } from '../actions/crashReport';
|
||||
import { APP } from '../actions/actionsTypes';
|
||||
|
@ -18,6 +18,7 @@ import {
|
|||
import { isIOS } from '../utils/deviceInfo';
|
||||
import database from '../lib/database';
|
||||
import protectedFunction from '../lib/methods/helpers/protectedFunction';
|
||||
import appConfig from '../../app.json';
|
||||
|
||||
export const initLocalSettings = function* initLocalSettings() {
|
||||
const sortPreferences = yield RocketChat.getSortPreferences();
|
||||
|
@ -95,7 +96,7 @@ const restore = function* restore() {
|
|||
RNUserDefaults.clear(RocketChat.TOKEN_KEY),
|
||||
RNUserDefaults.clear('currentServer')
|
||||
]);
|
||||
yield put(actions.appStart('outside'));
|
||||
yield put(serverRequest(appConfig.server));
|
||||
} else {
|
||||
const serversDB = database.servers;
|
||||
const serverCollections = serversDB.collections.get('servers');
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'moment/min/locales';
|
|||
|
||||
import * as types from '../actions/actionsTypes';
|
||||
import { appStart } from '../actions';
|
||||
import { serverFinishAdd, selectServerRequest } from '../actions/server';
|
||||
import { serverFinishAdd, serverRequest } from '../actions/server';
|
||||
import {
|
||||
loginFailure, loginSuccess, setUser, logout
|
||||
} from '../actions/login';
|
||||
|
@ -21,6 +21,7 @@ import database from '../lib/database';
|
|||
import EventEmitter from '../utils/events';
|
||||
import { inviteLinksRequest } from '../actions/inviteLinks';
|
||||
import { showErrorAlert } from '../utils/info';
|
||||
import appConfig from '../../app.json';
|
||||
|
||||
const getServer = state => state.server.server;
|
||||
const loginWithPasswordCall = args => RocketChat.loginWithPassword(args);
|
||||
|
@ -158,25 +159,8 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
|
|||
if (forcedByServer) {
|
||||
yield put(appStart('outside'));
|
||||
showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops'));
|
||||
EventEmitter.emit('NewServer', { server });
|
||||
} else {
|
||||
const serversDB = database.servers;
|
||||
// all servers
|
||||
const serversCollection = serversDB.collections.get('servers');
|
||||
const servers = yield serversCollection.query().fetch();
|
||||
|
||||
// see if there're other logged in servers and selects first one
|
||||
if (servers.length > 0) {
|
||||
for (let i = 0; i < servers.length; i += 1) {
|
||||
const newServer = servers[i].id;
|
||||
const token = yield RNUserDefaults.get(`${ RocketChat.TOKEN_KEY }-${ newServer }`);
|
||||
if (token) {
|
||||
return yield put(selectServerRequest(newServer));
|
||||
}
|
||||
}
|
||||
}
|
||||
// if there's no servers, go outside
|
||||
yield put(appStart('outside'));
|
||||
yield put(serverRequest(appConfig.server));
|
||||
}
|
||||
} catch (e) {
|
||||
yield put(appStart('outside'));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import {
|
||||
Text, View, TouchableOpacity, Image, StyleSheet
|
||||
Text, View, StyleSheet
|
||||
} from 'react-native';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
|
@ -49,10 +49,10 @@ const HeaderTitle = React.memo(({ connecting, isFetching, theme }) => {
|
|||
});
|
||||
|
||||
const Header = React.memo(({
|
||||
connecting, isFetching, serverName, showServerDropdown, onPress, theme
|
||||
connecting, isFetching, theme
|
||||
}) => (
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity
|
||||
{/* <TouchableOpacity
|
||||
onPress={onPress}
|
||||
testID='rooms-list-header-server-dropdown-button'
|
||||
style={styles.container}
|
||||
|
@ -63,22 +63,23 @@ const Header = React.memo(({
|
|||
<Text style={[styles.server, { color: themes[theme].headerTintColor }]}>{serverName}</Text>
|
||||
<Image style={[styles.disclosure, showServerDropdown && styles.upsideDown]} source={{ uri: 'disclosure_indicator_server' }} />
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</TouchableOpacity> */}
|
||||
<HeaderTitle connecting={connecting} isFetching={isFetching} theme={theme} />
|
||||
</View>
|
||||
));
|
||||
|
||||
Header.propTypes = {
|
||||
connecting: PropTypes.bool,
|
||||
isFetching: PropTypes.bool,
|
||||
serverName: PropTypes.string,
|
||||
// serverName: PropTypes.string,
|
||||
theme: PropTypes.string,
|
||||
showServerDropdown: PropTypes.bool.isRequired,
|
||||
// showServerDropdown: PropTypes.bool.isRequired,
|
||||
onPress: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
Header.defaultProps = {
|
||||
serverName: 'Rocket.Chat'
|
||||
};
|
||||
// Header.defaultProps = {
|
||||
// serverName: 'Rocket.Chat'
|
||||
// };
|
||||
|
||||
HeaderTitle.propTypes = {
|
||||
connecting: PropTypes.bool,
|
||||
|
|
Loading…
Reference in New Issue