FIX: Toggle bookmark for topic was not working after cancelling the modal (#9418)

* When bookmarking the topic, if the user cancelled the bookmark modal the bookmark topic button no longer worked because we did not reset the "bookmarked" property
* Prefill the custom reminder time to 8:00am
This commit is contained in:
Martin Brennan 2020-04-14 15:17:24 +10:00 committed by GitHub
parent 6f9177e2ed
commit 2d122f0393
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -78,7 +78,7 @@ export default Controller.extend(ModalFunctionality, {
closeWithoutSaving: false, closeWithoutSaving: false,
isSavingBookmarkManually: false, isSavingBookmarkManually: false,
customReminderDate: null, customReminderDate: null,
customReminderTime: null, customReminderTime: this.defaultCustomReminderTime(),
lastCustomReminderDate: null, lastCustomReminderDate: null,
lastCustomReminderTime: null, lastCustomReminderTime: null,
userTimezone: this.currentUser.resolvedTimezone() userTimezone: this.currentUser.resolvedTimezone()
@ -270,6 +270,10 @@ export default Controller.extend(ModalFunctionality, {
return moment.tz(date + " " + time, this.userTimezone); return moment.tz(date + " " + time, this.userTimezone);
}, },
defaultCustomReminderTime() {
return `0${START_OF_DAY_HOUR}:00`;
},
reminderAt() { reminderAt() {
if (!this.selectedReminderType) { if (!this.selectedReminderType) {
return; return;
@ -295,7 +299,7 @@ export default Controller.extend(ModalFunctionality, {
case REMINDER_TYPES.CUSTOM: case REMINDER_TYPES.CUSTOM:
this.set( this.set(
"customReminderTime", "customReminderTime",
this.customReminderTime || `0${START_OF_DAY_HOUR}:00` this.customReminderTime || this.defaultCustomReminderTime()
); );
const customDateTime = this.parseCustomDateTime( const customDateTime = this.parseCustomDateTime(
this.customReminderDate, this.customReminderDate,

View File

@ -349,8 +349,8 @@ const Post = RestModel.extend({
controller.setProperties({ controller.setProperties({
onCloseWithoutSaving: () => { onCloseWithoutSaving: () => {
this.toggleProperty("bookmarked_with_reminder"); this.toggleProperty("bookmarked_with_reminder");
resolve({ closedWithoutSaving: true });
this.appEvents.trigger("post-stream:refresh", { id: this.id }); this.appEvents.trigger("post-stream:refresh", { id: this.id });
resolve();
}, },
afterSave: (reminderAtISO, reminderType) => { afterSave: (reminderAtISO, reminderType) => {
this.setProperties({ this.setProperties({
@ -358,8 +358,8 @@ const Post = RestModel.extend({
bookmark_reminder_at: reminderAtISO, bookmark_reminder_at: reminderAtISO,
bookmark_reminder_type: reminderType bookmark_reminder_type: reminderType
}); });
resolve({ closedWithoutSaving: false });
this.appEvents.trigger("post-stream:refresh", { id: this.id }); this.appEvents.trigger("post-stream:refresh", { id: this.id });
resolve();
} }
}); });
}); });

View File

@ -438,9 +438,13 @@ const Topic = RestModel.extend({
const toggleBookmarkOnServer = () => { const toggleBookmarkOnServer = () => {
if (bookmark) { if (bookmark) {
if (this.siteSettings.enable_bookmarks_with_reminders) { if (this.siteSettings.enable_bookmarks_with_reminders) {
return firstPost.toggleBookmarkWithReminder().then(() => { return firstPost.toggleBookmarkWithReminder().then(response => {
this.set("bookmarking", false); this.set("bookmarking", false);
if (response.closedWithoutSaving) {
this.set("bookmarked", false);
} else {
return this.afterTopicBookmarked(firstPost); return this.afterTopicBookmarked(firstPost);
}
}); });
} else { } else {
return ajax(`/t/${this.id}/bookmark`, { type: "PUT" }) return ajax(`/t/${this.id}/bookmark`, { type: "PUT" })