Skip to content

Commit

Permalink
Merge branch 'single-server' into 4.55.0-single-server
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Dec 2, 2024
2 parents f152b9d + 4661f6f commit e9b62b9
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 207 deletions.
83 changes: 0 additions & 83 deletions android/app/google-services.json

This file was deleted.

4 changes: 0 additions & 4 deletions android/app/src/debug/res/values/strings.xml

This file was deleted.

16 changes: 9 additions & 7 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# are providing them.
newArchEnabled=false

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

# Application ID
APPLICATION_ID=chat.rocket.reactnative

# App properties
VERSIONCODE=999999999
VERSIONCODE=1
BugsnagAPIKey=""

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
KEYSTORE=my-upload-key.keystore
KEY_ALIAS=my-key-alias
KEYSTORE_PASSWORD=
KEY_PASSWORD=
3 changes: 2 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"name": "RocketChatRN"
"name": "RocketChatRN",
"server": "https://open.rocket.chat"
}
47 changes: 28 additions & 19 deletions app/sagas/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';

import { CURRENT_SERVER, TOKEN_KEY } from '../lib/constants';
import UserPreferences from '../lib/methods/userPreferences';
import { selectServerRequest } from '../actions/server';
import { selectServerRequest, serverRequest } from '../actions/server';
import { setAllPreferences } from '../actions/sortPreferences';
import { APP } from '../actions/actionsTypes';
import log from '../lib/methods/helpers/log';
Expand All @@ -16,6 +16,8 @@ import { getSortPreferences } from '../lib/methods';
import { deepLinkingClickCallPush } from '../actions/deepLinking';
import { getServerById } from '../lib/database/services/Server';

import appConfig from '../../app.json';

export const initLocalSettings = function* initLocalSettings() {
const sortPreferences = getSortPreferences();
yield put(setAllPreferences(sortPreferences));
Expand All @@ -24,26 +26,33 @@ export const initLocalSettings = function* initLocalSettings() {
const restore = function* restore() {
console.log('RESTORE');
try {
const server = UserPreferences.getString(CURRENT_SERVER);
let userId = UserPreferences.getString(`${TOKEN_KEY}-${server}`);
// const server = UserPreferences.getString(CURRENT_SERVER);
// let userId = UserPreferences.getString(`${TOKEN_KEY}-${server}`);

if (!server) {
yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
} else if (!userId) {
const serversDB = database.servers;
const serversCollection = serversDB.get('servers');
const servers = yield serversCollection.query().fetch();
// if (!server) {
// yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
// } else if (!userId) {
// const serversDB = database.servers;
// const serversCollection = serversDB.get('servers');
// const servers = yield serversCollection.query().fetch();

// Check if there're other logged in servers and picks first one
if (servers.length > 0) {
for (let i = 0; i < servers.length; i += 1) {
const newServer = servers[i].id;
userId = UserPreferences.getString(`${TOKEN_KEY}-${newServer}`);
if (userId) {
return yield put(selectServerRequest(newServer, newServer.version));
}
}
}
// // Check if there're other logged in servers and picks first one
// if (servers.length > 0) {
// for (let i = 0; i < servers.length; i += 1) {
// const newServer = servers[i].id;
// userId = UserPreferences.getString(`${TOKEN_KEY}-${newServer}`);
// if (userId) {
// return yield put(selectServerRequest(newServer));
// }
// }
// }
const { server } = appConfig;
const userId = UserPreferences.getString(`${TOKEN_KEY}-${server}`);

if (!userId) {
UserPreferences.removeItem(TOKEN_KEY);
UserPreferences.removeItem(CURRENT_SERVER);
yield put(serverRequest(appConfig.server));
yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
} else {
yield localAuthenticate(server);
Expand Down
28 changes: 7 additions & 21 deletions app/sagas/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as Keychain from 'react-native-keychain';
import moment from 'moment';
import * as types from '../actions/actionsTypes';
import { appStart } from '../actions/app';
import { selectServerRequest, serverFinishAdd } from '../actions/server';
import { selectServerRequest, serverFinishAdd, serverRequest } from '../actions/server';
import { loginFailure, loginSuccess, logout as logoutAction, setUser } from '../actions/login';
import { roomsRequest } from '../actions/rooms';
import log, { events, logEvent } from '../lib/methods/helpers/log';
Expand Down Expand Up @@ -48,6 +48,8 @@ import { showActionSheetRef } from '../containers/ActionSheet';
import { SupportedVersionsWarning } from '../containers/SupportedVersions';
import { isIOS } from '../lib/methods/helpers';

import appConfig from '../../app.json';

const getServer = state => state.server.server;
const loginWithPasswordCall = args => Services.loginWithPassword(args);
const loginCall = (credentials, isFromWebView) => Services.login(credentials, isFromWebView);
Expand Down Expand Up @@ -307,33 +309,17 @@ const handleLogout = function* handleLogout({ forcedByServer, message }) {
try {
yield call(logoutCall, { server });

yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
yield put(serverRequest(appConfig.server));

// if the user was logged out by the server
if (forcedByServer) {
yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
// yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
if (message) {
showErrorAlert(I18n.t(message), I18n.t('Oops'));
}
yield delay(300);
EventEmitter.emit('NewServer', { server });
} else {
const serversDB = database.servers;
// all servers
const serversCollection = serversDB.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 = UserPreferences.getString(`${TOKEN_KEY}-${newServer}`);
if (token) {
yield put(selectServerRequest(newServer, newServer.version));
return;
}
}
}
// if there's no servers, go outside
yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
}
} catch (e) {
yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
Expand Down
4 changes: 2 additions & 2 deletions app/stacks/OutsideStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import { ThemeContext } from '../theme';
import { defaultHeader, themedHeader } from '../lib/methods/helpers/navigation';
// Outside Stack
import NewServerView from '../views/NewServerView';
// import NewServerView from '../views/NewServerView';
import WorkspaceView from '../views/WorkspaceView';
import LoginView from '../views/LoginView';
import ForgotPasswordView from '../views/ForgotPasswordView';
Expand All @@ -23,7 +23,7 @@ const _OutsideStack = () => {
return (
<Outside.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme) }}>
{/* @ts-ignore */}
<Outside.Screen name='NewServerView' component={NewServerView} options={NewServerView.navigationOptions} />
{/* <Outside.Screen name='NewServerView' component={NewServerView} options={NewServerView.navigationOptions} /> */}
<Outside.Screen name='WorkspaceView' component={WorkspaceView} />

<Outside.Screen name='LoginView' component={LoginView} />
Expand Down
43 changes: 15 additions & 28 deletions app/views/RoomsListView/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import React from 'react';
import {
StyleSheet,
Text,
TextInputProps,
TouchableOpacity,
TouchableOpacityProps,
View,
useWindowDimensions
} from 'react-native';
import { StyleSheet, Text, TextInputProps, View, useWindowDimensions } from 'react-native';

import I18n from '../../../i18n';
import sharedStyles from '../../Styles';
Expand Down Expand Up @@ -44,7 +36,6 @@ interface IRoomHeader {
showSearchHeader: boolean;
width?: number;
onSearchChangeText: TextInputProps['onChangeText'];
onPress: TouchableOpacityProps['onPress'];
}

const Header = React.memo(
Expand All @@ -56,8 +47,7 @@ const Header = React.memo(
server,
showSearchHeader,
width,
onSearchChangeText,
onPress
onSearchChangeText
}: IRoomHeader) => {
const { status: supportedVersionsStatus } = useAppSelector(state => state.supportedVersions);
const { colors } = useTheme();
Expand All @@ -78,28 +68,25 @@ const Header = React.memo(
} else {
subtitle = server?.replace(/(^\w+:|^)\/\//, '');
}
// improve copy
return (
<View
style={[styles.container, { width: width || (isTablet ? undefined : windowWidth) }]}
accessibilityLabel={`${serverName} ${subtitle}`}
accessibilityRole='header'
accessible>
<TouchableOpacity onPress={onPress} testID='rooms-list-header-servers-list-button'>
<View style={styles.button}>
<Text style={[styles.title, { color: colors.fontTitlesLabels }]} numberOfLines={1}>
{serverName}
</Text>
</View>
{subtitle ? (
<Text
testID='rooms-list-header-server-subtitle'
style={[styles.subtitle, { color: colors.fontSecondaryInfo }]}
numberOfLines={1}>
{subtitle}
</Text>
) : null}
</TouchableOpacity>
<View style={styles.button}>
<Text style={[styles.title, { color: colors.fontTitlesLabels }]} numberOfLines={1}>
{serverName}
</Text>
</View>
{subtitle ? (
<Text
testID='rooms-list-header-server-subtitle'
style={[styles.subtitle, { color: colors.fontSecondaryInfo }]}
numberOfLines={1}>
{subtitle}
</Text>
) : null}
</View>
);
}
Expand Down
36 changes: 0 additions & 36 deletions ios/GoogleService-Info.plist

This file was deleted.

Loading

0 comments on commit e9b62b9

Please sign in to comment.