FIX: removes the need for intermediate property and updates code (#114)

FIX: removes the need for intermediate property and updates code (#114)

Before this commit, changing the value of the reminder frequency on a user notifications page was not working.

This commit also get rid of a few deprecations warning.

diff --git a/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6 b/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6
index a57cdf5..7cac81f 100644
--- a/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6
+++ b/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6
@@ -1,10 +1,14 @@
 import I18n from "I18n";
-import computed from "discourse-common/utils/decorators";
+import { or } from "@ember/object/computed";
+import discourseComputed from "discourse-common/utils/decorators";
 
 export default Ember.Component.extend({
-  selectedFrequency: null,
+  selectedFrequency: or(
+    "user.custom_fields.remind_assigns_frequency",
+    "siteSettings.remind_assigns_frequency"
+  ),
 
-  @computed("user.reminders_frequency")
+  @discourseComputed("user.reminders_frequency")
   availableFrequencies(userRemindersFrequency) {
     return userRemindersFrequency.map((freq) => {
       return {
@@ -14,24 +18,4 @@ export default Ember.Component.extend({
       };
     });
   },
-
-  didInsertElement() {
-    this._super(...arguments);
-
-    let currentFrequency = this.get(
-      "user.custom_fields.remind_assigns_frequency"
-    );
-
-    if (currentFrequency === undefined) {
-      currentFrequency = this.get("siteSettings.remind_assigns_frequency");
-    }
-
-    this.set("selectedFrequency", currentFrequency);
-  },
-
-  actions: {
-    setFrequency(newFrequency) {
-      this.set("user.custom_fields.remind_assigns_frequency", newFrequency);
-    },
-  },
 });
diff --git a/assets/javascripts/discourse/templates/components/remind-assigns-frequency.hbs b/assets/javascripts/discourse/templates/components/remind-assigns-frequency.hbs
index b7f611b..9270210 100644
--- a/assets/javascripts/discourse/templates/components/remind-assigns-frequency.hbs
+++ b/assets/javascripts/discourse/templates/components/remind-assigns-frequency.hbs
@@ -2,10 +2,10 @@
   <div class="controls controls-dropdown">
     <label>{{i18n "discourse_assign.reminders_frequency.description"}}</label>
     {{combo-box
-      valueAttribute="value"
+      valueProperty="value"
       content=availableFrequencies
       value=selectedFrequency
-      onSelect=(action "setFrequency")
+      onChange=(mut user.custom_fields.remind_assigns_frequency)
     }}
   </div>
 {{/if}}

GitHub sha: 977f7592

This commit appears in #114 which was approved by CvX. It was merged by jjaffeux.