[MM-38524] Rework the closing and opening tab logic, fixed login issue (#1735)

* Rework the closing and opening tab logic to better suit adding and removing servers

* A couple more fixes

* Lint fix

* [MM-38524] Fix login issue

* Remove unneeded code
This commit is contained in:
Devin Binnie
2021-09-16 13:35:07 -04:00
committed by GitHub
parent df57051eaa
commit b25ccfeecf
12 changed files with 76 additions and 55 deletions

View File

@@ -104,8 +104,8 @@ export default class MainPage extends React.PureComponent<Props, State> {
const firstServer = this.props.teams.find((team) => team.order === this.props.lastActiveTeam || 0);
let firstTab = firstServer?.tabs.find((tab) => tab.order === firstServer.lastActiveTab || 0);
if (firstTab?.isClosed) {
const openTabs = firstServer?.tabs.filter((tab) => !tab.isClosed) || [];
if (!firstTab?.isOpen) {
const openTabs = firstServer?.tabs.filter((tab) => tab.isOpen) || [];
firstTab = openTabs?.find((e) => e.order === 0) || openTabs[0];
}

View File

@@ -15,7 +15,6 @@ import {CombinedConfig, LocalConfiguration, Team} from 'types/config';
import {DeepPartial} from 'types/utils';
import {GET_LOCAL_CONFIGURATION, UPDATE_CONFIGURATION, DOUBLE_CLICK_ON_WINDOW, GET_DOWNLOAD_LOCATION, ADD_SERVER, RELOAD_CONFIGURATION} from 'common/communication';
import {getDefaultTeamWithTabsFromTeam} from 'common/tabs/TabView';
import AutoSaveIndicator, {SavingState} from './AutoSaveIndicator';
@@ -349,23 +348,6 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
allowSaveSpellCheckerURL,
});
}
updateTeam = (index: number, newData: Team) => {
const teams = this.state.teams || [];
teams[index] = newData;
window.timers.setImmediate(this.saveSetting, CONFIG_TYPE_SERVERS, {key: 'teams', data: teams});
this.setState({
teams,
});
}
addServer = (team: Team) => {
const teams = this.state.teams || [];
teams.push(getDefaultTeamWithTabsFromTeam(team));
window.timers.setImmediate(this.saveSetting, CONFIG_TYPE_SERVERS, {key: 'teams', data: teams});
this.setState({
teams,
});
}
handleDoubleClick = () => {
window.ipcRenderer.send(DOUBLE_CLICK_ON_WINDOW, 'settings');

View File

@@ -85,7 +85,7 @@ export default class TabBar extends React.PureComponent<Props> {
index={orderedIndex}
>
{(provided, snapshot) => {
if (tab.isClosed) {
if (!tab.isOpen) {
return (
<div
ref={provided.innerRef}