Skip to content

A platform for community discussion. Free, open, simple.

FIX: Client not setting `TopicTimer#based_on_last_post`.

Guo Xiang Tan2fecb4b46e7f
diff --git a/app/assets/javascripts/discourse/components/edit-topic-timer-form.js.es6 b/app/assets/javascripts/discourse/components/edit-topic-timer-form.js.es6
index 421972b834c..4b853e541da 100644
--- a/app/assets/javascripts/discourse/components/edit-topic-timer-form.js.es6
+++ b/app/assets/javascripts/discourse/components/edit-topic-timer-form.js.es6
@@ -46,5 +46,12 @@ export default Ember.Component.extend({
}
this.set("topicTimer.updateTime", time);
- }
+ },
+
+ @observes("selection")
+ _updateBasedOnLastPost() {
+ if (!this.get('autoClose')) {
+ this.set('topicTimer.based_on_last_post', false);
+ }
+ },
});
diff --git a/app/assets/javascripts/discourse/components/topic-timer-info.js.es6 b/app/assets/javascripts/discourse/components/topic-timer-info.js.es6
index 98c9ad1c306..e0e8fb91420 100644
--- a/app/assets/javascripts/discourse/components/topic-timer-info.js.es6
+++ b/app/assets/javascripts/discourse/components/topic-timer-info.js.es6
@@ -18,7 +18,6 @@ export default Ember.Component.extend(bufferedRender({
if (!this.get('executeAt')) return;
let statusUpdateAt = moment(this.get('executeAt'));
- if (statusUpdateAt < new Date()) return;
let duration = moment.duration(statusUpdateAt - moment());
let minutesLeft = duration.asMinutes();
diff --git a/app/assets/javascripts/discourse/templates/components/edit-topic-timer-form.hbs b/app/assets/javascripts/discourse/templates/components/edit-topic-timer-form.hbs
index f90534931b7..52f618fec96 100644
--- a/app/assets/javascripts/discourse/templates/components/edit-topic-timer-form.hbs
+++ b/app/assets/javascripts/discourse/templates/components/edit-topic-timer-form.hbs
@@ -9,7 +9,7 @@
input=topicTimer.updateTime
statusType=selection
includeWeekend=true
- basedOnLastPost=false}}
+ basedOnLastPost=topicTimer.based_on_last_post}}
{{else if publishToCategory}}
<div class="control-group">
<label>{{i18n 'topic.topic_status_update.publish_to'}}</label>
@@ -23,7 +23,7 @@
statusType=selection
includeWeekend=true
categoryId=topicTimer.category_id
- basedOnLastPost=false}}
+ basedOnLastPost=topicTimer.based_on_last_post}}
{{else if autoClose}}
{{future-date-input
input=topicTimer.updateTime
diff --git a/app/assets/javascripts/select-kit/components/future-date-input-selector.js.es6 b/app/assets/javascripts/select-kit/components/future-date-input-selector.js.es6
index 580c351bb45..66b378d891d 100644
--- a/app/assets/javascripts/select-kit/components/future-date-input-selector.js.es6
+++ b/app/assets/javascripts/select-kit/components/future-date-input-selector.js.es6
@@ -155,7 +155,7 @@ export default ComboBoxComponent.extend(DatetimeMixin, {
},
mutateValue(value) {
- if (this.get("isCustom") || this.get("isBasedOnLastPost")) {
+ if (value === 'pick_date_and_time' || this.get("isBasedOnLastPost")) {
this.set("value", value);
} else {
let input = null;