Remove server.adding

This commit is contained in:
Diego Mello 2021-09-22 10:45:44 -03:00
parent 64f4cc3cf1
commit 943e179e18
5 changed files with 35 additions and 38 deletions

View File

@ -7,7 +7,6 @@ const initialState = {
server: '', server: '',
version: null, version: null,
loading: true, loading: true,
adding: false,
previousServer: null, previousServer: null,
changingServer: false changingServer: false
}; };
@ -58,13 +57,11 @@ export default function server(state = initialState, action) {
case SERVER.INIT_ADD: case SERVER.INIT_ADD:
return { return {
...state, ...state,
adding: true,
previousServer: action.previousServer previousServer: action.previousServer
}; };
case SERVER.FINISH_ADD: case SERVER.FINISH_ADD:
return { return {
...state, ...state,
adding: false,
previousServer: null previousServer: null
}; };
default: default:

View File

@ -118,7 +118,7 @@ const fetchRooms = function* fetchRooms() {
const handleLoginSuccess = function* handleLoginSuccess({ user }) { const handleLoginSuccess = function* handleLoginSuccess({ user }) {
try { try {
const adding = yield select(state => state.server.adding); // const adding = yield select(state => state.server.adding);
RocketChat.getUserPresence(user.id); RocketChat.getUserPresence(user.id);
@ -170,25 +170,26 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) {
yield put(setUser(user)); yield put(setUser(user));
EventEmitter.emit('connected'); EventEmitter.emit('connected');
let currentRoot; // let currentRoot;
if (adding) { // const currentRoot = yield select(state => state.app.root);
yield put(serverFinishAdd()); // if (adding) {
// yield put(serverFinishAdd());
// yield put(appStart({ root: ROOT_INSIDE }));
// } else {
// currentRoot = yield select(state => state.app.root);
// if (currentRoot !== ROOT_INSIDE) {
yield put(appStart({ root: ROOT_INSIDE })); yield put(appStart({ root: ROOT_INSIDE }));
} else { // }
currentRoot = yield select(state => state.app.root); // }
if (currentRoot !== ROOT_INSIDE) {
yield put(appStart({ root: ROOT_INSIDE }));
}
}
// after a successful login, check if it's been invited via invite link // after a successful login, check if it's been invited via invite link
currentRoot = yield select(state => state.app.root); // currentRoot = yield select(state => state.app.root);
if (currentRoot === ROOT_INSIDE) { // if (currentRoot === ROOT_INSIDE) {
const inviteLinkToken = yield select(state => state.inviteLinks.token); const inviteLinkToken = yield select(state => state.inviteLinks.token);
if (inviteLinkToken) { if (inviteLinkToken) {
yield put(inviteLinksRequest(inviteLinkToken)); yield put(inviteLinksRequest(inviteLinkToken));
} }
} // }
} catch (e) { } catch (e) {
log(e); log(e);
} }

View File

@ -137,11 +137,11 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
logServerVersion(serverVersion); logServerVersion(serverVersion);
yield put(selectServerSuccess(server, serverVersion)); yield put(selectServerSuccess(server, serverVersion));
// if the adding state is true, finish add server // // if the adding state is true, finish add server
const adding = yield select(state => state.server.adding); // const adding = yield select(state => state.server.adding);
if (adding) { // if (adding) {
yield put(serverFinishAdd()); // yield put(serverFinishAdd());
} // }
} catch (e) { } catch (e) {
yield put(selectServerFailure()); yield put(selectServerFailure());
log(e); log(e);

View File

@ -74,7 +74,7 @@ class NewServerView extends React.Component {
connecting: PropTypes.bool.isRequired, connecting: PropTypes.bool.isRequired,
connectServer: PropTypes.func.isRequired, connectServer: PropTypes.func.isRequired,
selectServer: PropTypes.func.isRequired, selectServer: PropTypes.func.isRequired,
adding: PropTypes.bool, // adding: PropTypes.bool,
previousServer: PropTypes.string, previousServer: PropTypes.string,
inviteLinksClear: PropTypes.func inviteLinksClear: PropTypes.func
}; };
@ -100,12 +100,12 @@ class NewServerView extends React.Component {
this.queryServerHistory(); this.queryServerHistory();
} }
componentDidUpdate(prevProps) { // componentDidUpdate(prevProps) {
const { adding } = this.props; // const { adding } = this.props;
if (prevProps.adding !== adding) { // if (prevProps.adding !== adding) {
this.setHeader(); // this.setHeader();
} // }
} // }
componentWillUnmount() { componentWillUnmount() {
EventEmitter.removeListener('NewServer', this.handleNewServerEvent); EventEmitter.removeListener('NewServer', this.handleNewServerEvent);
@ -113,8 +113,8 @@ class NewServerView extends React.Component {
} }
setHeader = () => { setHeader = () => {
const { adding, navigation } = this.props; const { previousServer, navigation } = this.props;
if (adding) { if (previousServer) {
return navigation.setOptions({ return navigation.setOptions({
headerTitle: I18n.t('Workspaces'), headerTitle: I18n.t('Workspaces'),
headerLeft: () => <HeaderButton.CloseModal navigation={navigation} onPress={this.close} testID='new-server-view-close' /> headerLeft: () => <HeaderButton.CloseModal navigation={navigation} onPress={this.close} testID='new-server-view-close' />
@ -314,9 +314,9 @@ class NewServerView extends React.Component {
}; };
render() { render() {
const { connecting, theme, adding, width, height } = this.props; const { connecting, theme, previousServer, width, height } = this.props;
const { text, connectingOpen, serversHistory } = this.state; const { text, connectingOpen, serversHistory } = this.state;
const marginTopHeader = adding ? 25 : 70; const marginTopHeader = previousServer ? 0 : 70;
return ( return (
<FormContainer theme={theme} testID='new-server-view' keyboardShouldPersistTaps='never'> <FormContainer theme={theme} testID='new-server-view' keyboardShouldPersistTaps='never'>
@ -402,7 +402,7 @@ class NewServerView extends React.Component {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
connecting: state.server.connecting, connecting: state.server.connecting,
adding: state.server.adding, // adding: state.server.adding,
previousServer: state.server.previousServer previousServer: state.server.previousServer
}); });

View File

@ -96,7 +96,6 @@ class WorkspaceView extends React.Component {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
server: state.server.server, server: state.server.server,
adding: state.server.adding,
Site_Name: state.settings.Site_Name, Site_Name: state.settings.Site_Name,
Site_Url: state.settings.Site_Url, Site_Url: state.settings.Site_Url,
Assets_favicon_512: state.settings.Assets_favicon_512, Assets_favicon_512: state.settings.Assets_favicon_512,