Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Have editMeetingTimes use same funcs as createMeetingTimes #1592

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 20 additions & 50 deletions client/src/components/manageProjects/editMeetingTimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ const EditMeetingTimes = ({
};
}

//if there is a description or a blank description
if (values.description || !values.description) {
Copy link
Member Author

@trillium trillium Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion of the code always evaluates to true, removed if block

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lolol

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be

if (values.description) {

theUpdatedEvent = {
...theUpdatedEvent,
description: values.description,
};
}
theUpdatedEvent = {
...theUpdatedEvent,
description: values.description,
};

if (values.videoConferenceLink) {
theUpdatedEvent = {
Expand All @@ -63,50 +60,23 @@ const EditMeetingTimes = ({
updatedDate,
};

// If the day has been changed, find the next occurence of the changed day
if (values.day) {
const date = findNextOccuranceOfDay(values.day);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion of the code is what creates a false time stamp. values always has a .day property in the front end, so the code assumes we are needing tom update the day.

This is the most relevant changes to this PR

const dateGMT = new Date(date).toISOString();

theUpdatedEvent = {
...theUpdatedEvent,
date: dateGMT,
};
}

// Set start time, End time and Duration if either start time or duration is changed
if (values.startTime || values.duration) {
/*
We need a start time and a duration to calculate everything we need.
If only the start time or only the duration is changing,
we use the previous time or duration for the calculation.
*/
// Find next occurance of Day in the future
// Assign new start time and end time
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In createMeetingTimes.js the timing selections for a meeting are used to create a correct meeting time. We have access to the same information and it has been consistently correct, this is the most correct information we have about the meeting times.

const date = findNextOccuranceOfDay(values.day);
const startTimeDate = timeConvertFromForm(date, values.startTime);
const endTime = addDurationToTime(startTimeDate, values.duration);

let startTimeToUse = startTimeOriginal;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting rid of the old timing code

let durationToUse = durationOriginal;

if (values.startTime) {
startTimeToUse = values.startTime;
}

if (values.duration) {
durationToUse = values.duration;
}

const timeDate = timeConvertFromForm(new Date(), startTimeToUse);
const endTime = addDurationToTime(timeDate, durationToUse);

// convert to ISO and GMT
const startTimeGMT = new Date(timeDate).toISOString();
const endTimeGMT = new Date(endTime).toISOString();

theUpdatedEvent = {
...theUpdatedEvent,
startTime: startTimeGMT,
endTime: endTimeGMT,
hours: durationToUse,
};
}
// Revert timestamps to GMT
const startDateTimeGMT = new Date(startTimeDate).toISOString();
const endTimeGMT = new Date(endTime).toISOString();

theUpdatedEvent = {
...theUpdatedEvent,
date: startDateTimeGMT,
startTime: startDateTimeGMT,
endTime: endTimeGMT,
duration: values.duration
};

updateRecurringEvent(theUpdatedEvent, eventID);
showSnackbar("Recurring event updated", 'info')
Expand Down
Loading