fix: clean up session and party presence
This commit is contained in:
parent
255c57e2ac
commit
039cb4bfbe
3 changed files with 24 additions and 31 deletions
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
|
@ -9,8 +9,7 @@
|
||||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||||
"stopOnEntry": false,
|
"stopOnEntry": false,
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ],
|
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ]
|
||||||
"preLaunchTask": "build"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
15
.vscode/tasks.json
vendored
15
.vscode/tasks.json
vendored
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
||||||
// for the documentation about the tasks.json format
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "build",
|
|
||||||
"type": "gulp",
|
|
||||||
"task": "build",
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gulp-tsc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -96,6 +96,7 @@ export default class Activity implements Disposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async allowSpectate(): Promise<State | void> {
|
public async allowSpectate(): Promise<State | void> {
|
||||||
|
if (!this._state) return;
|
||||||
const liveshare = await vsls.getApi();
|
const liveshare = await vsls.getApi();
|
||||||
if (!liveshare) return;
|
if (!liveshare) return;
|
||||||
const join = await liveshare.share({ suppressNotification: true, access: vsls.Access.ReadOnly });
|
const join = await liveshare.share({ suppressNotification: true, access: vsls.Access.ReadOnly });
|
||||||
|
@ -109,19 +110,19 @@ export default class Activity implements Disposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disableSpectate(): Promise<State | void> {
|
public async disableSpectate(): Promise<State | void> {
|
||||||
|
if (!this._state) return;
|
||||||
const liveshare = await vsls.getApi();
|
const liveshare = await vsls.getApi();
|
||||||
if (!liveshare) return;
|
if (!liveshare) return;
|
||||||
await liveshare.end();
|
await liveshare.end();
|
||||||
this._state = {
|
|
||||||
...this._state,
|
delete this._state.spectateSecret;
|
||||||
spectateSecret: undefined,
|
this._state.instance = false;
|
||||||
instance: false
|
|
||||||
};
|
|
||||||
|
|
||||||
return this._state;
|
return this._state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async allowJoinRequests(): Promise<State | void> {
|
public async allowJoinRequests(): Promise<State | void> {
|
||||||
|
if (!this._state) return;
|
||||||
const liveshare = await vsls.getApi();
|
const liveshare = await vsls.getApi();
|
||||||
if (!liveshare) return;
|
if (!liveshare) return;
|
||||||
const join = await liveshare.share({ suppressNotification: true });
|
const join = await liveshare.share({ suppressNotification: true });
|
||||||
|
@ -138,28 +139,36 @@ export default class Activity implements Disposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disableJoinRequests(): Promise<State | void> {
|
public async disableJoinRequests(): Promise<State | void> {
|
||||||
|
if (!this._state) return;
|
||||||
const liveshare = await vsls.getApi();
|
const liveshare = await vsls.getApi();
|
||||||
if (!liveshare) return;
|
if (!liveshare) return;
|
||||||
await liveshare.end();
|
await liveshare.end();
|
||||||
this._state = {
|
|
||||||
...this._state,
|
delete this._state.partyId;
|
||||||
partyId: undefined,
|
delete this._state.partySize;
|
||||||
partySize: undefined,
|
delete this._state.partyMax;
|
||||||
partyMax: undefined,
|
delete this._state.joinSecret;
|
||||||
joinSecret: undefined,
|
this._state.instance = false;
|
||||||
instance: false
|
|
||||||
};
|
|
||||||
|
|
||||||
return this._state;
|
return this._state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public changePartyId(id?: string): State | void {
|
public changePartyId(id?: string): State | void {
|
||||||
if (!this._state) return;
|
if (!this._state) return;
|
||||||
|
if (!id) {
|
||||||
|
delete this._state.partyId;
|
||||||
|
delete this._state.partySize;
|
||||||
|
delete this._state.partyMax;
|
||||||
|
this._state.instance = false;
|
||||||
|
|
||||||
|
return this._state;
|
||||||
|
}
|
||||||
this._state = {
|
this._state = {
|
||||||
...this._state,
|
...this._state,
|
||||||
partyId: id,
|
partyId: id,
|
||||||
partySize: this._state.partySize ? this._state.partySize + 1 : 1,
|
partySize: this._state.partySize ? this._state.partySize + 1 : 1,
|
||||||
partyMax: id ? 5 : undefined
|
partyMax: 5,
|
||||||
|
instance: true
|
||||||
};
|
};
|
||||||
|
|
||||||
return this._state;
|
return this._state;
|
||||||
|
|
Loading…
Reference in a new issue