Skip to content

Commit dabd739

Browse files
committed
Remove duplicate state
1 parent 4269965 commit dabd739

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/components/GitPanel.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export interface IGitSessionNodeState {
3636
unstagedFiles: Git.IStatusFileResult[];
3737
untrackedFiles: Git.IStatusFileResult[];
3838

39-
isHistoryVisible: boolean;
4039
tab: number;
4140
}
4241

@@ -62,7 +61,6 @@ export class GitPanel extends React.Component<
6261
stagedFiles: [],
6362
unstagedFiles: [],
6463
untrackedFiles: [],
65-
isHistoryVisible: false,
6664
tab: 0
6765
};
6866

@@ -77,7 +75,7 @@ export class GitPanel extends React.Component<
7775
}, this);
7876
props.model.headChanged.connect(async () => {
7977
await this.refreshBranch();
80-
if (this.state.isHistoryVisible) {
78+
if (this.state.tab === 1) {
8179
this.refreshHistory();
8280
} else {
8381
this.refreshStatus();
@@ -233,9 +231,7 @@ export class GitPanel extends React.Component<
233231
return (
234232
<React.Fragment>
235233
{this._renderTabs()}
236-
{this.state.isHistoryVisible
237-
? this._renderHistory()
238-
: this._renderChanges()}
234+
{this.state.tab === 1 ? this._renderHistory() : this._renderChanges()}
239235
</React.Fragment>
240236
);
241237
}
@@ -321,7 +317,7 @@ export class GitPanel extends React.Component<
321317
private _renderHistory() {
322318
return (
323319
<HistorySideBar
324-
isExpanded={this.state.isHistoryVisible}
320+
isExpanded={this.state.tab === 1}
325321
branches={this.state.branches}
326322
pastCommits={this.state.pastCommits}
327323
model={this.props.model}
@@ -358,16 +354,11 @@ export class GitPanel extends React.Component<
358354
* @param tab - tab number
359355
*/
360356
private _onTabChange = (event: any, tab: number): void => {
361-
let isHistoryVisible;
362357
if (tab === 1) {
363358
this.refreshHistory();
364-
isHistoryVisible = true;
365-
} else {
366-
isHistoryVisible = false;
367359
}
368360
this.setState({
369-
tab: tab,
370-
isHistoryVisible: isHistoryVisible
361+
tab: tab
371362
});
372363
};
373364

@@ -378,7 +369,7 @@ export class GitPanel extends React.Component<
378369
*/
379370
private _onRefresh = async () => {
380371
await this.refreshBranch();
381-
if (this.state.isHistoryVisible) {
372+
if (this.state.tab === 1) {
382373
this.refreshHistory();
383374
} else {
384375
this.refreshStatus();

0 commit comments

Comments
 (0)