Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lostintangent committed Jul 2, 2019
1 parent eb72f38 commit 96f0906
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/services/liveShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ export async function initialize(
config: Config,
activateProfileHandler: (profile: string) => void
) {
// Check to see if the end-user has the Live Share
// extension installed, and if not, exit early.
const liveShare = await vsls.getApi();
if (!liveShare) {
return;
}

// Begin listening for the beginning and end of Live
// Share sessions, in case we need to switch profiles.
liveShare.onDidChangeSession(e => {
if (e.session.id) {
const liveShareProfile = config.getLiveShareProfile();
if (!liveShareProfile) {
return;
}
// If the end-user never set a Live Share profile, then
// there's nothing we need to do. Note that we're calling
// this here, instead of as part of the activation flow,
// so that the end-user can set their profile any time
// and have it take effect immediately.
const liveShareProfile = config.getLiveShareProfile();
if (!liveShareProfile) {
return;
}

if (e.session.id) {
activateProfileHandler(liveShareProfile);
} else {
const previousProfile = config.getPreviousProfile();
Expand Down

0 comments on commit 96f0906

Please # to comment.