Skip to content

Commit

Permalink
fixup! Apply Timeline plugin API
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Sep 1, 2020
1 parent 6973e49 commit 3987218
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/timeline/src/browser/timeline-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { TimelineWidget } from './timeline-widget';
import { TimelineService } from './timeline-service';
import { Command, CommandContribution, CommandRegistry } from '@theia/core/lib/common';
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { toArray } from '@phosphor/algorithm';

@injectable()
export class TimelineContribution implements CommandContribution, TabBarToolbarContribution {
Expand Down Expand Up @@ -86,7 +87,11 @@ export class TimelineContribution implements CommandContribution, TabBarToolbarC
});
commands.registerCommand(TimelineContribution.LOAD_MORE_COMMAND, {
execute: async () => {
const widget = this.shell.getWidgetById(navigableId);
let navigable;
if (!navigableId) {
navigable = toArray(this.shell.mainPanel.widgets()).find(w => Navigatable.is(w) && w.isVisible && !w.isHidden);
}
const widget = this.shell.getWidgetById(navigableId) || navigable;
if (Navigatable.is(widget)) {
const uri = widget.getResourceUri();
const timeline = await this.widgetManager.getWidget<TimelineWidget>(TimelineWidget.ID);
Expand Down
4 changes: 2 additions & 2 deletions packages/timeline/src/browser/timeline-tree-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface TimelineNode extends SelectableTreeNode {
@injectable()
export class TimelineTreeModel extends TreeModelImpl {

updateTree(items: TimelineItem[], loadMore: boolean): void {
updateTree(items: TimelineItem[], hasMoreItems: boolean): void {
const root = {
id: 'timeline-tree-root',
parent: undefined,
Expand All @@ -47,7 +47,7 @@ export class TimelineTreeModel extends TreeModelImpl {
visible: true
} as TimelineNode)
);
if (loadMore) {
if (hasMoreItems) {
const loadMoreNode: TimelineItem = { label: 'Load-more', timestamp: 0, handle: '', uri: '', source: '' };
loadMoreNode.command = TimelineContribution.LOAD_MORE_COMMAND;
children.push({
Expand Down
8 changes: 6 additions & 2 deletions packages/timeline/src/browser/timeline-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { inject, injectable, postConstruct } from 'inversify';
import {
ApplicationShell,
BaseWidget,
MessageLoop,
MessageLoop, Navigatable,
NavigatableWidget,
Panel,
PanelLayout
Expand Down Expand Up @@ -76,7 +76,11 @@ export class TimelineWidget extends BaseWidget {
}
})
);
this.toDispose.push(this.applicationShell.onDidChangeCurrentWidget(async event => this.refresh()));
this.toDispose.push(this.applicationShell.onDidChangeCurrentWidget(async e => {
if ((e.newValue && Navigatable.is(e.newValue)) || !this.suitableWidgetsOpened()) {
this.refresh();
}
}));
this.toDispose.push(this.timelineService.onDidChangeProviders(e => this.onProvidersChanged(e)));
}

Expand Down

0 comments on commit 3987218

Please sign in to comment.