Skip to content

Commit

Permalink
fix: Use Wire add-in on mobile - still in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin.jaroschewski committed Jul 3, 2024
1 parent 3343147 commit d363274
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
38 changes: 24 additions & 14 deletions src/calendarIntegration/addMeetingLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isOutlookCalIntegrationEnabled } from "./isOutlookCalIntegrationEnabled
import { createEvent } from "./createEvent";
import { mailboxItem } from "../commands/commands";
import { EventResult } from "../types/EventResult";
import { getUserDetails } from "../utils/userDetailsStore";

const defaultSubjectValue = "New Appointment";
let createdMeeting: EventResult;
Expand Down Expand Up @@ -82,11 +83,18 @@ async function createNewMeeting(): Promise<void> {
* @return {Promise<void>} A promise that resolves when the meeting details are updated.
*/
async function updateMeetingDetails(eventResult: EventResult): Promise<void> {
getOrganizer(mailboxItem, async (organizer) => {
await setLocation(mailboxItem, eventResult.link, () => {});
const meetingSummary = createMeetingSummary(eventResult.link, organizer);
await appendToBody(mailboxItem, meetingSummary);
});

await setLocation(mailboxItem, eventResult.link, () => {});
// const organizer = await getOrganizer(mailboxItem);
const user = getUserDetails();
const meetingSummary = createMeetingSummary(eventResult.link, user.name);
await appendToBody(mailboxItem, user.name);
// getOrganizer(mailboxItem, async (organizer) => {
// const meetingSummary = createMeetingSummary(eventResult.link, organizer);
// await appendToBody(mailboxItem, meetingSummary);
// });


}

/**
Expand All @@ -104,15 +112,15 @@ async function handleExistingMeeting(): Promise<void> {
const normalizedCurrentBody = currentBody.replace(/&amp;/g, "&");
const normalizedMeetingLink = createdMeeting.link?.replace(/&amp;/g, "&");

getOrganizer(mailboxItem, async (organizer) => {
if (!currentLocation) {
await setLocation(mailboxItem, createdMeeting.link, () => {});
}
const meetingSummary = createMeetingSummary(createdMeeting.link, organizer);
if (!normalizedCurrentBody.includes(normalizedMeetingLink)) {
await appendToBody(mailboxItem, meetingSummary);
}
});
// getOrganizer(mailboxItem, async (organizer) => {
// if (!currentLocation) {
// await setLocation(mailboxItem, createdMeeting.link, () => {});
// }
// const meetingSummary = createMeetingSummary(createdMeeting.link, organizer);
// if (!normalizedCurrentBody.includes(normalizedMeetingLink)) {
// await appendToBody(mailboxItem, meetingSummary);
// }
// });

await setCustomPropertyAsync(mailboxItem, "wireId", createdMeeting.id);
await setCustomPropertyAsync(mailboxItem, "wireLink", createdMeeting.link);
Expand All @@ -126,9 +134,11 @@ async function handleExistingMeeting(): Promise<void> {
*/
async function addMeetingLink(event: Office.AddinCommands.Event): Promise<void> {
try {

const isEnabled = await isFeatureEnabled();
if (!isEnabled) return;


await fetchCustomProperties();
if (!createdMeeting) {
await createNewMeeting();
Expand Down
19 changes: 11 additions & 8 deletions src/utils/mailbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ export async function getMailboxItemSubject(item): Promise<string> {
});
}

export async function getOrganizer(item, callback) {
const { organizer } = item;
export async function getOrganizer(item): Promise<string> {
return new Promise((resolve, reject) => {
const { organizer } = item;

await organizer.getAsync(function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.error("Failed to get organizer.");
} else {
callback(asyncResult.value.displayName);
}
organizer.getAsync(function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
resolve(asyncResult.value.displayName);
} else {
console.error(asyncResult.error);
reject(new Error("Failed to get organizer"));
}
});
});
}

Expand Down

0 comments on commit d363274

Please sign in to comment.