Skip to content

Commit

Permalink
error handlings addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
ritikramuka committed Dec 13, 2023
1 parent 89adbd9 commit 0f8d2cb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
29 changes: 23 additions & 6 deletions src/web/client/WebExtensionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,16 +790,33 @@ class WebExtensionContext implements IWebExtensionContext {
this.connectedUsers.removeUser(userId);
}

public async openTeamsChat(userId: string): Promise<void> {
public async getMail(userId: string): Promise<string> {
const mail = await this.graphClientService.getUserEmail(userId);
const teamsChatLink = getTeamChatURL(mail);
vscode.env.openExternal(vscode.Uri.parse(teamsChatLink.href));
return mail;
}

public openTeamsChat(userId: string) {
this.getMail(userId).then((mail) => {
if (mail === undefined) {
vscode.window.showErrorMessage(Constants.WEB_EXTENSION_TEAMS_CHAT_NOT_AVAILABLE);
return;
} else {
const teamsChatLink = getTeamChatURL(mail);
vscode.env.openExternal(vscode.Uri.parse(teamsChatLink.href));
}
});
}

public async openMail(userId: string): Promise<void> {
const mail = await this.graphClientService.getUserEmail(userId);
const mailToPath = getMailToPath(mail);
vscode.env.openExternal(vscode.Uri.parse(mailToPath));
this.getMail(userId).then((mail) => {
if (mail === undefined) {
vscode.window.showErrorMessage(Constants.WEB_EXTENSION_SEND_EMAIL_NOT_AVAILABLE);
return;
} else {
const mailToPath = getMailToPath(mail);
vscode.env.openExternal(vscode.Uri.parse(mailToPath));
}
});
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/web/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,5 @@ export const THEME_ICON_ACCOUNT = "account";
export const THEME_ICON_MAIL = "mail";
export const START_TEAMS_CHAT = "Start Teams Chat";
export const SEND_AN_EMAIL = "Send an email";
export const WEB_EXTENSION_TEAMS_CHAT_NOT_AVAILABLE = "Teams chat is not available for this user";
export const WEB_EXTENSION_SEND_EMAIL_NOT_AVAILABLE = "Send email is not available for this user";
8 changes: 6 additions & 2 deletions src/web/client/webViews/QuickPickProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export class QuickPickProvider {
{
label: Constants.START_TEAMS_CHAT,
iconPath: {
light: '../assets/microsoftTeamsIcon/light/microsoftTeams.svg',
dark: '../assets/microsoftTeamsIcon/dark/microsoftTeams.svg',
light: vscode.Uri.joinPath(WebExtensionContext.extensionUri, 'src', 'web', 'client', 'assets', 'microsoftTeamsIcon', 'light', 'microsoftTeams.svg'),
dark: vscode.Uri.joinPath(WebExtensionContext.extensionUri, 'src', 'web', 'client', 'assets', 'microsoftTeamsIcon', 'dark', 'microsoftTeams.svg'),
}
},
{
Expand All @@ -90,10 +90,14 @@ export class QuickPickProvider {
if (collaborationOptionsSelected.label === Constants.START_TEAMS_CHAT) {
if (selectedOption.id) {
WebExtensionContext.openTeamsChat(selectedOption.id);
} else {
vscode.window.showInformationMessage(Constants.WEB_EXTENSION_TEAMS_CHAT_NOT_AVAILABLE);
}
} else if (collaborationOptionsSelected.label === Constants.SEND_AN_EMAIL) {
if (selectedOption.id) {
WebExtensionContext.openMail(selectedOption.id);
} else {
vscode.window.showInformationMessage(Constants.WEB_EXTENSION_SEND_EMAIL_NOT_AVAILABLE);
}
}
}
Expand Down

0 comments on commit 0f8d2cb

Please sign in to comment.