Skip to content

Commit

Permalink
Fix missing commit and amend widgets on opening new workspace
Browse files Browse the repository at this point in the history
Signed-off-by: Nigel Westbury <nigelipse@miegel.org>
  • Loading branch information
westbury committed May 7, 2020
1 parent 7cf845b commit 3807c58
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
13 changes: 6 additions & 7 deletions packages/scm/src/browser/scm-amend-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from 'inversify';
import { Message } from '@phosphor/messaging';
import { injectable, inject, postConstruct } from 'inversify';
import { SelectionService } from '@theia/core/lib/common';
import * as React from 'react';
import {
Expand Down Expand Up @@ -51,11 +50,11 @@ export class ScmAmendWidget extends ReactWidget {
this.id = ScmAmendWidget.ID;
}

protected onUpdateRequest(msg: Message): void {
if (!this.isAttached || !this.isVisible) {
return;
}
super.onUpdateRequest(msg);
@postConstruct()
protected init(): void {
this.toDispose.push(this.scmService.onDidChangeSelectedRepository(() => {
this.update();
}));
}

protected render(): React.ReactNode {
Expand Down
21 changes: 9 additions & 12 deletions packages/scm/src/browser/scm-commit-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from 'inversify';
import { injectable, inject, postConstruct } from 'inversify';
import { Message } from '@phosphor/messaging';
import { SelectionService } from '@theia/core/lib/common';
import * as React from 'react';
import TextareaAutosize from 'react-autosize-textarea';
import { ScmInput } from './scm-input';
import {
ContextMenuRenderer, ReactWidget, LabelProvider, KeybindingRegistry, StatefulWidget} from '@theia/core/lib/browser';
ContextMenuRenderer, ReactWidget, KeybindingRegistry, StatefulWidget} from '@theia/core/lib/browser';
import { ScmService } from './scm-service';

@injectable()
Expand All @@ -30,8 +29,6 @@ export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
static ID = 'scm-commit-widget';

@inject(ScmService) protected readonly scmService: ScmService;
@inject(SelectionService) protected readonly selectionService: SelectionService;
@inject(LabelProvider) protected readonly labelProvider: LabelProvider;
@inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry;

protected shouldScrollToRow = true;
Expand All @@ -51,6 +48,13 @@ export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
this.id = ScmCommitWidget.ID;
}

@postConstruct()
protected init(): void {
this.toDispose.push(this.scmService.onDidChangeSelectedRepository(() => {
this.update();
}));
}

protected onActivateRequest(msg: Message): void {
super.onActivateRequest(msg);
this.focus();
Expand All @@ -60,13 +64,6 @@ export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
(this.inputRef.current || this.node).focus();
}

protected onUpdateRequest(msg: Message): void {
if (!this.isAttached || !this.isVisible) {
return;
}
super.onUpdateRequest(msg);
}

protected render(): React.ReactNode {
const repository = this.scmService.selectedRepository;
if (repository) {
Expand Down
3 changes: 0 additions & 3 deletions packages/scm/src/browser/scm-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ export class ScmWidget extends BaseWidget implements StatefulWidget {
}

protected onUpdateRequest(msg: Message): void {
if (!this.isAttached || !this.isVisible) {
return;
}
MessageLoop.sendMessage(this.commitWidget, msg);
MessageLoop.sendMessage(this.resourceWidget, msg);
MessageLoop.sendMessage(this.amendWidget, msg);
Expand Down

0 comments on commit 3807c58

Please sign in to comment.