Skip to content

Commit

Permalink
Merge branch 'single-server' into single-server-4.16.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	android/app/build.gradle
#	app/sagas/init.js
#	app/sagas/login.js
#	app/views/AuthenticationWebView.js
#	app/views/RoomActionsView/index.js
#	app/views/RoomsListView/Header/Header.js
#	ios/RocketChatRN.xcodeproj/project.pbxproj
#	ios/RocketChatRN/Info.plist
#	ios/ShareRocketChatRN/Info.plist
#	package.json
  • Loading branch information
diegolmello committed Apr 14, 2021
2 parents 14078c0 + 5c50b32 commit 4c86aaa
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 234 deletions.
4 changes: 0 additions & 4 deletions android/app/src/debug/res/values/strings.xml

This file was deleted.

2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
Expand Down
14 changes: 7 additions & 7 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ org.gradle.jvmargs=-Xmx2048M -XX\:MaxHeapSize\=32g
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
APPLICATION_ID=chat.rocket.reactnative
VERSIONCODE=1
BugsnagAPIKey=
KEYSTORE=my-upload-key.keystore
KEY_ALIAS=my-key-alias
KEYSTORE_PASSWORD=
KEY_PASSWORD=

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.51.0

# Application ID
APPLICATION_ID=chat.rocket.reactnative

# App properties
VERSIONCODE=999999999
BugsnagAPIKey=""
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"
}
32 changes: 12 additions & 20 deletions app/sagas/init.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { put, takeLatest } from 'redux-saga/effects';
import { put, takeLatest, all } from 'redux-saga/effects';
import RNBootSplash from 'react-native-bootsplash';

// import * as actions from '../actions';
import { selectServerRequest, serverRequest } from '../actions/server';
// import { selectServerRequest } from '../actions/server';
import UserPreferences from '../lib/userPreferences';
import { selectServerRequest } from '../actions/server';
import { setAllPreferences } from '../actions/sortPreferences';
import { toggleCrashReport, toggleAnalyticsEvents } from '../actions/crashReport';
import { APP } from '../actions/actionsTypes';
import RocketChat from '../lib/rocketchat';
import log from '../utils/log';
import database from '../lib/database';
import appConfig from '../../app.json';
import { localAuthenticate } from '../utils/localAuthentication';
import { appStart, ROOT_OUTSIDE, appReady } from '../actions/app';

Expand All @@ -26,25 +29,14 @@ export const initLocalSettings = function* initLocalSettings() {
const restore = function* restore() {
try {
const server = yield UserPreferences.getStringAsync(RocketChat.CURRENT_SERVER);
let userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
const userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);

if (!server) {
yield put(appStart({ root: 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 = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ newServer }`);
if (userId) {
return yield put(selectServerRequest(newServer));
}
}
}
if (!userId || !server) {
yield all([
UserPreferences.removeItem(RocketChat.TOKEN_KEY),
UserPreferences.removeItem(RocketChat.CURRENT_SERVER)
]);
yield put(serverRequest(appConfig.server));
yield put(appStart({ root: ROOT_OUTSIDE }));
} else {
const serversDB = database.servers;
Expand Down
38 changes: 12 additions & 26 deletions app/sagas/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import {
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { Q } from '@nozbe/watermelondb';
import * as types from '../actions/actionsTypes';
// import { appStart } from '../actions';
import { serverFinishAdd, serverRequest } from '../actions/server';
import {
appStart, ROOT_SET_USERNAME, ROOT_INSIDE, ROOT_LOADING, ROOT_OUTSIDE
} from '../actions/app';
import { serverFinishAdd, selectServerRequest } from '../actions/server';
// import { serverFinishAdd, selectServerRequest } from '../actions/server';
import {
loginFailure, loginSuccess, setUser, logout
} from '../actions/login';
Expand All @@ -19,14 +21,15 @@ 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';
import { localAuthenticate } from '../utils/localAuthentication';
import { setActiveUsers } from '../actions/activeUsers';
import { encryptionInit, encryptionStop } from '../actions/encryption';
import UserPreferences from '../lib/userPreferences';

import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry';
import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib';
import Navigation from '../lib/Navigation';
// import Navigation from '../lib/Navigation';

const getServer = state => state.server.server;
const loginWithPasswordCall = args => RocketChat.loginWithPassword(args);
Expand Down Expand Up @@ -203,34 +206,17 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
if (server) {
try {
yield call(logoutCall, { server });
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(serverRequest(appConfig.server));

// if the user was logged out by the server
if (forcedByServer) {
yield put(appStart({ root: ROOT_OUTSIDE }));
showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops'));
yield delay(300);
Navigation.navigate('NewServerView');
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 = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ newServer }`);
if (token) {
yield put(selectServerRequest(newServer));
return;
}
}
}
// if there's no servers, go outside
yield put(appStart({ root: ROOT_OUTSIDE }));
// yield delay(300);
// Navigation.navigate('NewServerView');
// yield delay(300);
// EventEmitter.emit('NewServer', { server });
// yield put(serverRequest(appConfig.server));
}
} catch (e) {
yield put(appStart({ root: ROOT_OUTSIDE }));
Expand Down
17 changes: 6 additions & 11 deletions app/stacks/OutsideStack.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import React from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';

import { ThemeContext } from '../theme';
import {
defaultHeader, themedHeader, StackAnimation, ModalAnimation
} from '../utils/navigation';

// Outside Stack
import OnboardingView from '../views/OnboardingView';
import NewServerView from '../views/NewServerView';
// import OnboardingView from '../views/OnboardingView';
// import NewServerView from '../views/NewServerView';
import WorkspaceView from '../views/WorkspaceView';
import LoginView from '../views/LoginView';
import ForgotPasswordView from '../views/ForgotPasswordView';
import RegisterView from '../views/RegisterView';
import LegalView from '../views/LegalView';
import AuthenticationWebView from '../views/AuthenticationWebView';
import { ROOT_OUTSIDE } from '../actions/app';
// import { ROOT_OUTSIDE } from '../actions/app';

// Outside
const Outside = createStackNavigator();
const _OutsideStack = ({ root }) => {
const _OutsideStack = () => {
const { theme } = React.useContext(ThemeContext);

return (
<Outside.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>
{root === ROOT_OUTSIDE ? (
{/* {root === ROOT_OUTSIDE ? (
<Outside.Screen
name='OnboardingView'
component={OnboardingView}
Expand All @@ -37,7 +36,7 @@ const _OutsideStack = ({ root }) => {
name='NewServerView'
component={NewServerView}
options={NewServerView.navigationOptions}
/>
/> */}
<Outside.Screen
name='WorkspaceView'
component={WorkspaceView}
Expand Down Expand Up @@ -71,10 +70,6 @@ const mapStateToProps = state => ({
root: state.app.root
});

_OutsideStack.propTypes = {
root: PropTypes.string
};

const OutsideStack = connect(mapStateToProps)(_OutsideStack);

// OutsideStackModal
Expand Down
2 changes: 1 addition & 1 deletion app/views/RoomActionsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,4 +896,4 @@ const mapDispatchToProps = dispatch => ({
setLoadingInvite: loading => dispatch(setLoadingAction(loading))
});

export default connect(mapStateToProps, mapDispatchToProps)(withTheme(withDimensions(RoomActionsView)));
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(withDimensions(RoomActionsView)));
28 changes: 6 additions & 22 deletions app/views/RoomsListView/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react';
import {
Text, View, TouchableOpacity, StyleSheet
} from 'react-native';
import { Text, View, StyleSheet } from 'react-native';
import PropTypes from 'prop-types';

import TextInput from '../../../presentation/TextInput';
import I18n from '../../../i18n';
import sharedStyles from '../../Styles';
import { themes } from '../../../constants/colors';
import { CustomIcon } from '../../../lib/Icons';
import { isTablet, isIOS } from '../../../utils/deviceInfo';
import { useOrientation } from '../../../dimensions';

Expand All @@ -34,7 +31,7 @@ const styles = StyleSheet.create({
});

const Header = React.memo(({
connecting, connected, isFetching, serverName, server, showServerDropdown, showSearchHeader, theme, onSearchChangeText, onPress
connecting, connected, isFetching, serverName, server, showSearchHeader, theme, onSearchChangeText
}) => {
const titleColorStyle = { color: themes[theme].headerTitleColor };
const isLight = theme === 'light';
Expand Down Expand Up @@ -69,29 +66,16 @@ 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, isFetching && styles.serverSmall, titleColorStyle, { fontSize: titleFontSize }]} numberOfLines={1}>{serverName}</Text>
<CustomIcon
name='chevron-down'
color={themes[theme].headerTintColor}
style={[showServerDropdown && styles.upsideDown]}
size={18}
/>
</View>
{subtitle ? <Text testID='rooms-list-header-server-subtitle' style={[styles.subtitle, { color: themes[theme].auxiliaryText, fontSize: subTitleFontSize }]} numberOfLines={1}>{subtitle}</Text> : null}
</TouchableOpacity>
<View style={styles.button}>
<Text style={[styles.title, isFetching && styles.serverSmall, titleColorStyle, { fontSize: titleFontSize }]} numberOfLines={1}>{serverName}</Text>
</View>
{subtitle ? <Text testID='rooms-list-header-server-subtitle' style={[styles.subtitle, { color: themes[theme].auxiliaryText, fontSize: subTitleFontSize }]} numberOfLines={1}>{subtitle}</Text> : null}
</View>
);
});

Header.propTypes = {
showServerDropdown: PropTypes.bool.isRequired,
showSearchHeader: PropTypes.bool.isRequired,
onPress: PropTypes.func.isRequired,
onSearchChangeText: PropTypes.func.isRequired,
connecting: PropTypes.bool,
connected: PropTypes.bool,
Expand Down
36 changes: 0 additions & 36 deletions ios/GoogleService-Info.plist

This file was deleted.

5 changes: 0 additions & 5 deletions ios/Pods/Target Support Files/yoga/yoga-dummy.m

This file was deleted.

Loading

0 comments on commit 4c86aaa

Please sign in to comment.