-
Notifications
You must be signed in to change notification settings - Fork 7
Calendar: Edit: Recurrence: Move changeRemainder() from UI to logic - try 2 #763
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
base: master
Are you sure you want to change the base?
Conversation
Alternative to #750 This code still doesn't work. When "changing remainder", it deletes all instances from here on, including this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When "changing remainder", it deletes all instances from here on, including this one.
Isn't that the desired behaviour? The new series starts from this instance. (Well, it does if you remember to add it to the calendar...)
await saveEvent(master); | ||
master.finishEditing(); | ||
let newMaster = event.cloneSeriesFromThisInstance(); | ||
await newMaster.save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saveEvent
used to add the event to the calendar.
await saveEvent(master); | |
master.finishEditing(); | |
let newMaster = event.cloneSeriesFromThisInstance(); | |
await newMaster.save(); | |
let newMaster = event.cloneSeriesFromThisInstance(); | |
await newMaster.save(); | |
newMaster.calendar.events.add(newMaster); |
let end = new Date(event.startTime); | ||
event.parentEvent.cancelEditing(); | ||
event.cancelEditing(); | ||
await event.truncateRecurrence(); | ||
await event.setRecurrenceEndTime(end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event
isn't the master here, and you probably want to delete the current instance too:
let end = new Date(event.startTime); | |
event.parentEvent.cancelEditing(); | |
event.cancelEditing(); | |
await event.truncateRecurrence(); | |
await event.setRecurrenceEndTime(end); | |
event.parentEvent.cancelEditing(); | |
event.cancelEditing(); | |
await event.truncateRecurrencesFromHere(); |
@@ -729,6 +729,7 @@ export class Event extends Observable { | |||
* Used when a master recurrence rule is removed or changed incompatibly. | |||
*/ | |||
protected clearExceptions() { | |||
assert(this.recurrenceCase == RecurrenceCase.Master, "Must be a recurring master"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.recurrenceCase
can't be relied upon at this point, because we might have just cleared the recurrence rule.
event.truncateRecurrencesFromHere(); | ||
await event.save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want to save the event here as that tries to turn it from an instance into an exception. (The old truncateRecurrence
had await master.save()
, which is why it was async
.)
event.truncateRecurrencesFromHere(); | |
await event.save(); | |
event.truncateRecurrencesFromHere(); | |
await event.parentEvent.save(); |
event.truncateRecurrencesFromHere(); | ||
await event.save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
event.truncateRecurrencesFromHere(); | |
await event.save(); | |
event.truncateRecurrencesFromHere(); | |
await event.parentEvent.save(); |
/** Creates a new series with the same properties and recurrence, | ||
* but starting at this instance. | ||
* | ||
* It will also truncate the old series at that start time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not any more it doesn't.
let { frequency, interval, week, weekdays } = oldMaster.recurrenceRule; | ||
newMaster.newRecurrenceRule(frequency, interval, week, weekdays); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oldMaster.recurrenceRule
could be null if you changed the frequency in the UI first. (This would replace the remainder of the series with a single event.)
Problem is that the new series is not created
Oh, duh! Is that the reason why I work on this since 2 days and nothing works? Is it that silly? sigh |
No description provided.