Skip to content

Commit

Permalink
Merge branch 'single-server' into 4.48.0-single-server
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/views/ChangeAvatarView/index.tsx
#	app/views/RoomsListView/Header/Header.tsx
#	ios/RocketChatRN.xcodeproj/project.pbxproj
  • Loading branch information
diegolmello committed Apr 30, 2024
2 parents 7cacd11 + c00d768 commit 83d433a
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 204 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.

10 changes: 6 additions & 4 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ newArchEnabled=false

# Application ID
APPLICATION_ID=chat.rocket.reactnative

# App properties
VERSIONCODE=999999999
BugsnagAPIKey=""
VERSIONCODE=1
BugsnagAPIKey=""
KEYSTORE=my-upload-key.keystore
KEY_ALIAS=my-key-alias
KEYSTORE_PASSWORD=
KEY_PASSWORD=
5 changes: 4 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "RocketChatRN",
"share": "ShareRocketChatRN",
"displayName": "RocketChatRN"
"displayName": "RocketChatRN",
"server": "https://open.rocket.chat",
"appGroup": "group.ios.chat.rocket",
"appStoreID": "1272915472"
}
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 { BIOMETRY_ENABLED_KEY, 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 @@ -15,6 +15,8 @@ import { RootEnum } from '../definitions';
import { getSortPreferences } from '../lib/methods';
import { deepLinkingClickCallPush } from '../actions/deepLinking';

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

export const initLocalSettings = function* initLocalSettings() {
const sortPreferences = getSortPreferences();
yield put(setAllPreferences(sortPreferences));
Expand All @@ -24,8 +26,8 @@ const BIOMETRY_MIGRATION_KEY = 'kBiometryMigration';

const restore = function* 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}`);

// Migration biometry setting from WatermelonDB to MMKV
// TODO: remove it after a few versions
Expand All @@ -39,23 +41,30 @@ const restore = function* restore() {
UserPreferences.setBool(BIOMETRY_MIGRATION_KEY, true);
}

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));
}
}
}
// // 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 {
const serversDB = database.servers;
Expand Down
28 changes: 7 additions & 21 deletions app/sagas/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Q } from '@nozbe/watermelondb';
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 @@ -45,6 +45,8 @@ import appNavigation from '../lib/navigation/appNavigation';
import { showActionSheetRef } from '../containers/ActionSheet';
import { SupportedVersionsWarning } from '../containers/SupportedVersions';

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 @@ -251,33 +253,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));
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 { ModalAnimation, StackAnimation, 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 @@ -22,7 +22,7 @@ const _OutsideStack = () => {

return (
<Outside.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation } as StackNavigationOptions}>
<Outside.Screen name='NewServerView' component={NewServerView} options={NewServerView.navigationOptions} />
{/* <Outside.Screen name='NewServerView' component={NewServerView} options={NewServerView.navigationOptions} /> */}
<Outside.Screen name='WorkspaceView' component={WorkspaceView} />
{/* @ts-ignore */}
<Outside.Screen name='LoginView' component={LoginView} options={LoginView.navigationOptions} />
Expand Down
3 changes: 1 addition & 2 deletions app/views/ChangeAvatarView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ const ChangeAvatarView = () => {
<ScrollView
contentContainerStyle={sharedStyles.containerScrollView}
testID='change-avatar-view-list'
{...scrollPersistTaps}
>
{...scrollPersistTaps}>
<View style={styles.avatarContainer} testID='change-avatar-view-avatar'>
{deletingRoomAvatar ? (
<AvatarPresentational
Expand Down
47 changes: 23 additions & 24 deletions app/views/RoomsListView/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { StyleSheet, Text, TextInputProps, TouchableOpacity, TouchableOpacityProps, View } from 'react-native';
import { StyleSheet, Text, TextInputProps, TouchableOpacityProps, View } from 'react-native';

import I18n from '../../../i18n';
import sharedStyles from '../../Styles';
import { CustomIcon } from '../../../containers/CustomIcon';
// import { CustomIcon } from '../../../containers/CustomIcon';
import { useTheme } from '../../../theme';
import SearchHeader from '../../../containers/SearchHeader';
import { useAppSelector } from '../../../lib/hooks';
Expand Down Expand Up @@ -50,11 +50,11 @@ const Header = React.memo(
isFetching,
serverName = 'Rocket.Chat',
server,
showServerDropdown,
// showServerDropdown,
showSearchHeader,
onSearchChangeText,
onPress
}: IRoomHeader) => {
onSearchChangeText
}: // onPress
IRoomHeader) => {
const { status: supportedVersionsStatus } = useAppSelector(state => state.supportedVersions);
const { colors } = useTheme();

Expand All @@ -75,28 +75,27 @@ const Header = React.memo(
}
return (
<View style={styles.container}>
<TouchableOpacity onPress={onPress} testID='rooms-list-header-server-dropdown-button'>
<View style={styles.button}>
<Text style={[styles.title, { color: colors.fontTitlesLabels }]} numberOfLines={1}>
{serverName}
</Text>
<CustomIcon
{/* <TouchableOpacity onPress={onPress} testID='rooms-list-header-server-dropdown-button'> */}
<View style={styles.button}>
<Text style={[styles.title, { color: colors.fontTitlesLabels }]} numberOfLines={1}>
{serverName}
</Text>
{/* <CustomIcon
name='chevron-down'
color={colors.fontSecondaryInfo}
style={[showServerDropdown && styles.upsideDown]}
size={18}
/>
</View>
{subtitle ? (
<Text
testID='rooms-list-header-server-subtitle'
style={[styles.subtitle, { color: colors.fontSecondaryInfo }]}
numberOfLines={1}
>
{subtitle}
</Text>
) : null}
</TouchableOpacity>
/> */}
</View>
{subtitle ? (
<Text
testID='rooms-list-header-server-subtitle'
style={[styles.subtitle, { color: colors.fontSecondaryInfo }]}
numberOfLines={1}>
{subtitle}
</Text>
) : null}
{/* </TouchableOpacity> */}
</View>
);
}
Expand Down
36 changes: 0 additions & 36 deletions ios/GoogleService-Info.plist

This file was deleted.

0 comments on commit 83d433a

Please sign in to comment.