|
|
@ -1,3 +1,4 @@ |
|
|
|
import type { ConfigurationChangeEvent } from 'vscode'; |
|
|
|
import { Disposable, extensions, workspace } from 'vscode'; |
|
|
|
import type { LiveShare, LiveShareExtension, SessionChangeEvent } from '../@types/vsls'; |
|
|
|
import { Schemes } from '../constants'; |
|
|
@ -5,7 +6,6 @@ import type { Container } from '../container'; |
|
|
|
import { configuration } from '../system/configuration'; |
|
|
|
import { setContext } from '../system/context'; |
|
|
|
import { debug } from '../system/decorators/log'; |
|
|
|
import { timeout } from '../system/decorators/timeout'; |
|
|
|
import { once } from '../system/event'; |
|
|
|
import { Logger } from '../system/logger'; |
|
|
|
import type { Deferred } from '../system/promise'; |
|
|
@ -43,7 +43,10 @@ export class VslsController implements Disposable { |
|
|
|
|
|
|
|
constructor(private readonly container: Container) { |
|
|
|
this._ready = defer<void>(); |
|
|
|
this._disposable = Disposable.from(once(container.onReady)(this.onReady, this)); |
|
|
|
this._disposable = Disposable.from( |
|
|
|
once(container.onReady)(this.onReady, this), |
|
|
|
configuration.onDidChange(this.onConfigurationChanged, this), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
dispose() { |
|
|
@ -59,6 +62,11 @@ export class VslsController implements Disposable { |
|
|
|
} |
|
|
|
|
|
|
|
private async initialize() { |
|
|
|
if (!this.enabled) { |
|
|
|
void setContext('gitlens:vsls', false); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// If we have a vsls: workspace open, we might be a guest, so wait until live share transitions into a mode
|
|
|
|
if (workspace.workspaceFolders?.some(f => f.uri.scheme === Schemes.Vsls)) { |
|
|
|
this.setReadonly(true); |
|
|
@ -88,6 +96,12 @@ export class VslsController implements Disposable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private onConfigurationChanged(e: ConfigurationChangeEvent) { |
|
|
|
if (configuration.changed(e, 'liveshare.enabled')) { |
|
|
|
void this.initialize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async onLiveShareSessionChanged(api: LiveShare, e: SessionChangeEvent) { |
|
|
|
this._host?.dispose(); |
|
|
|
this._host = undefined; |
|
|
@ -151,6 +165,10 @@ export class VslsController implements Disposable { |
|
|
|
void setContext('gitlens:readonly', value ? true : undefined); |
|
|
|
} |
|
|
|
|
|
|
|
get enabled() { |
|
|
|
return configuration.get('liveshare.enabled'); |
|
|
|
} |
|
|
|
|
|
|
|
async guest() { |
|
|
|
if (this._guest != null) return this._guest; |
|
|
|
|
|
|
@ -196,12 +214,6 @@ export class VslsController implements Disposable { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@debug() |
|
|
|
@timeout(250) |
|
|
|
maybeGetPresence(email: string | undefined): Promise<ContactPresence | undefined> { |
|
|
|
return this.getContactPresence(email); |
|
|
|
} |
|
|
|
|
|
|
|
async invite(email: string | undefined) { |
|
|
|
if (email == null) return undefined; |
|
|
|
|
|
|
|