minor tweaks

This commit is contained in:
Reinaldo Neto 2021-09-17 14:51:48 -03:00
parent 8d5137ca5b
commit 9ed35f0f1d
10 changed files with 799 additions and 798 deletions

View File

@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import Navigation from './lib/Navigation'; import Navigation from './lib/Navigation';
import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/navigation'; import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/navigation';
import { ROOT_INSIDE, ROOT_LOADING, ROOT_NEW_SERVER, ROOT_SET_USERNAME } from './actions/app'; import { ROOT_INSIDE, ROOT_LOADING, ROOT_OUTSIDE, ROOT_SET_USERNAME } from './actions/app';
// Stacks // Stacks
import AuthLoadingView from './views/AuthLoadingView'; import AuthLoadingView from './views/AuthLoadingView';
// SetUsername Stack // SetUsername Stack
@ -56,7 +56,7 @@ const App = React.memo(({ root, isMasterDetail }: { root: string; isMasterDetail
<Stack.Navigator screenOptions={{ headerShown: false, animationEnabled: false }}> <Stack.Navigator screenOptions={{ headerShown: false, animationEnabled: false }}>
<> <>
{root === ROOT_LOADING ? <Stack.Screen name='AuthLoading' component={AuthLoadingView} /> : null} {root === ROOT_LOADING ? <Stack.Screen name='AuthLoading' component={AuthLoadingView} /> : null}
{root === ROOT_NEW_SERVER ? <Stack.Screen name='OutsideStack' component={OutsideStack} /> : null} {root === ROOT_OUTSIDE ? <Stack.Screen name='OutsideStack' component={OutsideStack} /> : null}
{root === ROOT_INSIDE && isMasterDetail ? ( {root === ROOT_INSIDE && isMasterDetail ? (
<Stack.Screen name='MasterDetailStack' component={MasterDetailStack} /> <Stack.Screen name='MasterDetailStack' component={MasterDetailStack} />
) : null} ) : null}

View File

@ -1,8 +1,8 @@
import { APP } from './actionsTypes'; import { APP } from './actionsTypes';
export const ROOT_OUTSIDE = 'outside';
export const ROOT_INSIDE = 'inside'; export const ROOT_INSIDE = 'inside';
export const ROOT_LOADING = 'loading'; export const ROOT_LOADING = 'loading';
export const ROOT_NEW_SERVER = 'newServer';
export const ROOT_SET_USERNAME = 'setUsername'; export const ROOT_SET_USERNAME = 'setUsername';
export function appStart({ root, ...args }) { export function appStart({ root, ...args }) {

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ import { inviteLinksRequest, inviteLinksSetToken } from '../actions/inviteLinks'
import database from '../lib/database'; import database from '../lib/database';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
import EventEmitter from '../utils/events'; import EventEmitter from '../utils/events';
import { ROOT_INSIDE, ROOT_NEW_SERVER, appInit, appStart } from '../actions/app'; import { ROOT_INSIDE, ROOT_OUTSIDE, appInit, appStart } from '../actions/app';
import { localAuthenticate } from '../utils/localAuthentication'; import { localAuthenticate } from '../utils/localAuthentication';
import { goRoom } from '../utils/goRoom'; import { goRoom } from '../utils/goRoom';
import { loginRequest } from '../actions/login'; import { loginRequest } from '../actions/login';
@ -180,7 +180,7 @@ const handleOpen = function* handleOpen({ params }) {
yield fallbackNavigation(); yield fallbackNavigation();
return; return;
} }
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(serverInitAdd(server)); yield put(serverInitAdd(server));
yield delay(1000); yield delay(1000);
EventEmitter.emit('NewServer', { server: host }); EventEmitter.emit('NewServer', { server: host });

View File

@ -9,7 +9,7 @@ import RocketChat from '../lib/rocketchat';
import log from '../utils/log'; import log from '../utils/log';
import database from '../lib/database'; import database from '../lib/database';
import { localAuthenticate } from '../utils/localAuthentication'; import { localAuthenticate } from '../utils/localAuthentication';
import { ROOT_NEW_SERVER, appReady, appStart } from '../actions/app'; import { ROOT_OUTSIDE, appReady, appStart } from '../actions/app';
export const initLocalSettings = function* initLocalSettings() { export const initLocalSettings = function* initLocalSettings() {
const sortPreferences = yield RocketChat.getSortPreferences(); const sortPreferences = yield RocketChat.getSortPreferences();
@ -22,7 +22,7 @@ const restore = function* restore() {
let userId = yield UserPreferences.getStringAsync(`${RocketChat.TOKEN_KEY}-${server}`); let userId = yield UserPreferences.getStringAsync(`${RocketChat.TOKEN_KEY}-${server}`);
if (!server) { if (!server) {
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
} else if (!userId) { } else if (!userId) {
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.get('servers'); const serversCollection = serversDB.get('servers');
@ -38,7 +38,7 @@ const restore = function* restore() {
} }
} }
} }
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
} else { } else {
const serversDB = database.servers; const serversDB = database.servers;
const serverCollections = serversDB.get('servers'); const serverCollections = serversDB.get('servers');
@ -56,7 +56,7 @@ const restore = function* restore() {
yield put(appReady({})); yield put(appReady({}));
} catch (e) { } catch (e) {
log(e); log(e);
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
} }
}; };

View File

@ -3,7 +3,7 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { Q } from '@nozbe/watermelondb'; import { Q } from '@nozbe/watermelondb';
import * as types from '../actions/actionsTypes'; import * as types from '../actions/actionsTypes';
import { ROOT_INSIDE, ROOT_LOADING, ROOT_NEW_SERVER, ROOT_SET_USERNAME, appStart } from '../actions/app'; import { ROOT_INSIDE, ROOT_LOADING, ROOT_OUTSIDE, ROOT_SET_USERNAME, appStart } from '../actions/app';
import { selectServerRequest, serverFinishAdd } from '../actions/server'; import { selectServerRequest, serverFinishAdd } from '../actions/server';
import { loginFailure, loginSuccess, logout, setUser } from '../actions/login'; import { loginFailure, loginSuccess, logout, setUser } from '../actions/login';
import { roomsRequest } from '../actions/rooms'; import { roomsRequest } from '../actions/rooms';
@ -204,7 +204,7 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
// if the user was logged out by the server // if the user was logged out by the server
if (forcedByServer) { if (forcedByServer) {
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops')); showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops'));
yield delay(300); yield delay(300);
Navigation.navigate('NewServerView'); Navigation.navigate('NewServerView');
@ -228,10 +228,10 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
} }
} }
// if there's no servers, go outside // if there's no servers, go outside
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
} }
} catch (e) { } catch (e) {
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
log(e); log(e);
} }
} }

View File

@ -15,7 +15,7 @@ import database from '../lib/database';
import log, { logServerVersion } from '../utils/log'; import log, { logServerVersion } from '../utils/log';
import I18n from '../i18n'; import I18n from '../i18n';
import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch'; import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch';
import { ROOT_INSIDE, ROOT_NEW_SERVER, appStart } from '../actions/app'; import { ROOT_INSIDE, ROOT_OUTSIDE, appStart } from '../actions/app';
import UserPreferences from '../lib/userPreferences'; import UserPreferences from '../lib/userPreferences';
import { encryptionStop } from '../actions/encryption'; import { encryptionStop } from '../actions/encryption';
import SSLPinning from '../utils/sslPinning'; import SSLPinning from '../utils/sslPinning';
@ -114,7 +114,7 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
yield put(appStart({ root: ROOT_INSIDE })); yield put(appStart({ root: ROOT_INSIDE }));
} else { } else {
yield RocketChat.connect({ server }); yield RocketChat.connect({ server });
yield put(appStart({ root: ROOT_NEW_SERVER })); yield put(appStart({ root: ROOT_OUTSIDE }));
} }
// We can't use yield here because fetch of Settings & Custom Emojis is slower // We can't use yield here because fetch of Settings & Custom Emojis is slower

View File

@ -5,11 +5,11 @@ import { setBadgeCount } from '../notifications/push';
import log from '../utils/log'; import log from '../utils/log';
import { localAuthenticate, saveLastLocalAuthenticationSession } from '../utils/localAuthentication'; import { localAuthenticate, saveLastLocalAuthenticationSession } from '../utils/localAuthentication';
import { APP_STATE } from '../actions/actionsTypes'; import { APP_STATE } from '../actions/actionsTypes';
import { ROOT_NEW_SERVER } from '../actions/app'; import { ROOT_OUTSIDE } from '../actions/app';
const appHasComeBackToForeground = function* appHasComeBackToForeground() { const appHasComeBackToForeground = function* appHasComeBackToForeground() {
const appRoot = yield select(state => state.app.root); const appRoot = yield select(state => state.app.root);
if (appRoot === ROOT_NEW_SERVER) { if (appRoot === ROOT_OUTSIDE) {
return; return;
} }
const login = yield select(state => state.login); const login = yield select(state => state.login);
@ -29,7 +29,7 @@ const appHasComeBackToForeground = function* appHasComeBackToForeground() {
const appHasComeBackToBackground = function* appHasComeBackToBackground() { const appHasComeBackToBackground = function* appHasComeBackToBackground() {
const appRoot = yield select(state => state.app.root); const appRoot = yield select(state => state.app.root);
if (appRoot === ROOT_NEW_SERVER) { if (appRoot === ROOT_OUTSIDE) {
return; return;
} }
try { try {

View File

@ -8,7 +8,7 @@ import * as List from '../../containers/List';
import Button from '../../containers/Button'; import Button from '../../containers/Button';
import { toggleServerDropdown as toggleServerDropdownAction } from '../../actions/rooms'; import { toggleServerDropdown as toggleServerDropdownAction } from '../../actions/rooms';
import { selectServerRequest as selectServerRequestAction, serverInitAdd as serverInitAddAction } from '../../actions/server'; import { selectServerRequest as selectServerRequestAction, serverInitAdd as serverInitAddAction } from '../../actions/server';
import { ROOT_NEW_SERVER, appStart as appStartAction } from '../../actions/app'; import { ROOT_OUTSIDE, appStart as appStartAction } from '../../actions/app';
import RocketChat from '../../lib/rocketchat'; import RocketChat from '../../lib/rocketchat';
import I18n from '../../i18n'; import I18n from '../../i18n';
import EventEmitter from '../../utils/events'; import EventEmitter from '../../utils/events';
@ -20,7 +20,7 @@ import { KEY_COMMAND, handleCommandSelectServer } from '../../commands';
import { isTablet } from '../../utils/deviceInfo'; import { isTablet } from '../../utils/deviceInfo';
import { localAuthenticate } from '../../utils/localAuthentication'; import { localAuthenticate } from '../../utils/localAuthentication';
import { showConfirmationAlert } from '../../utils/info'; import { showConfirmationAlert } from '../../utils/info';
import { events, logEvent } from '../../utils/log'; import log, { events, logEvent } from '../../utils/log';
import { headerHeight } from '../../containers/Header'; import { headerHeight } from '../../containers/Header';
import { goRoom } from '../../utils/goRoom'; import { goRoom } from '../../utils/goRoom';
import UserPreferences from '../../lib/userPreferences'; import UserPreferences from '../../lib/userPreferences';
@ -102,15 +102,16 @@ class ServerDropdown extends Component {
logEvent(events.RL_CREATE_NEW_WORKSPACE); logEvent(events.RL_CREATE_NEW_WORKSPACE);
try { try {
await Linking.openURL('https://cloud.rocket.chat/trial'); await Linking.openURL('https://cloud.rocket.chat/trial');
} catch { } catch (e) {
logEvent(events.RL_CREATE_NEW_WORKSPACE_F); logEvent(events.RL_CREATE_NEW_WORKSPACE_F);
log(e);
} }
}; };
navToNewServer = previousServer => { navToNewServer = previousServer => {
const { appStart, initAdd } = this.props; const { appStart, initAdd } = this.props;
batch(() => { batch(() => {
appStart({ root: ROOT_NEW_SERVER }); appStart({ root: ROOT_OUTSIDE });
initAdd(previousServer); initAdd(previousServer);
}); });
}; };

View File

@ -9,7 +9,7 @@ describe('Onboarding', () => {
}); });
describe('Render', () => { describe('Render', () => {
it('should have onboarding screen as New Server View', async () => { it('should have onboarding screen', async () => {
await expect(element(by.id('new-server-view'))).toBeVisible(); await expect(element(by.id('new-server-view'))).toBeVisible();
}); });