Adds refresh for when timeline changes

This commit is contained in:
Eric Amodio
2020-01-22 15:42:43 -05:00
committed by Eric Amodio
parent 87c2332fed
commit d7b5fe4cc7
8 changed files with 144 additions and 21 deletions

View File

@@ -8,10 +8,12 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { ITimelineService, TimelineItem, TimelineProviderDescriptor } from 'vs/workbench/contrib/timeline/common/timeline';
import { URI } from 'vs/base/common/uri';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Emitter } from 'vs/base/common/event';
@extHostNamedCustomer(MainContext.MainThreadTimeline)
export class MainThreadTimeline implements MainThreadTimelineShape {
private readonly _proxy: ExtHostTimelineShape;
private readonly _providerEmitters = new Map<string, Emitter<URI | undefined>>();
constructor(
context: IExtHostContext,
@@ -29,12 +31,24 @@ export class MainThreadTimeline implements MainThreadTimelineShape {
const proxy = this._proxy;
const emitters = this._providerEmitters;
let onDidChange = emitters.get(provider.source);
// eslint-disable-next-line eqeqeq
if (onDidChange == null) {
onDidChange = new Emitter<URI | undefined>();
emitters.set(provider.source, onDidChange);
}
this._timelineService.registerTimelineProvider({
...provider,
onDidChange: onDidChange.event,
provideTimeline(uri: URI, since: number, token: CancellationToken) {
return proxy.$getTimeline(provider.source, uri, since, token);
},
dispose() { }
dispose() {
emitters.delete(provider.source);
onDidChange?.dispose();
}
});
}
@@ -43,6 +57,13 @@ export class MainThreadTimeline implements MainThreadTimelineShape {
this._timelineService.unregisterTimelineProvider(source);
}
$emitTimelineChangeEvent(source: string, uri: URI | undefined): void {
console.log(`MainThreadTimeline#emitChangeEvent: source=${source} uri=${uri?.toString(true)}`);
const emitter = this._providerEmitters.get(source);
emitter?.fire(uri);
}
dispose(): void {
// noop
}