From 1dd9df9cd0832d91279a22e626fb842dc29c0a2a Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 7 May 2020 16:39:53 +0200 Subject: [PATCH] REFACTOR: removes overwritten properties and duplicates fn (#9686) --- .../admin/components/admin-report.js | 2 -- .../discourse/app/components/text-field.js | 33 +++++-------------- .../discourse/app/controllers/composer.js | 2 -- .../discourse-local-dates-create-form.js.es6 | 1 - 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/admin/components/admin-report.js b/app/assets/javascripts/admin/components/admin-report.js index 757a90a7dbc..352b92fb939 100644 --- a/app/assets/javascripts/admin/components/admin-report.js +++ b/app/assets/javascripts/admin/components/admin-report.js @@ -59,8 +59,6 @@ export default Component.extend({ forcedModes: null, showAllReportsLink: false, filters: null, - startDate: null, - endDate: null, showTrend: false, showHeader: true, showTitle: true, diff --git a/app/assets/javascripts/discourse/app/components/text-field.js b/app/assets/javascripts/discourse/app/components/text-field.js index 5809d25a86c..affad24e803 100644 --- a/app/assets/javascripts/discourse/app/components/text-field.js +++ b/app/assets/javascripts/discourse/app/components/text-field.js @@ -6,9 +6,6 @@ import { next, debounce, cancel } from "@ember/runloop"; const DEBOUNCE_MS = 500; export default TextField.extend({ - _prevValue: null, - _timer: null, - attributeBindings: [ "autocorrect", "autocapitalize", @@ -17,13 +14,22 @@ export default TextField.extend({ "dir" ], + init() { + this._super(...arguments); + + this._prevValue = null; + this._timer = null; + }, + didReceiveAttrs() { this._super(...arguments); + this._prevValue = this.value; }, didUpdateAttrs() { this._super(...arguments); + if (this._prevValue !== this.value) { if (this.onChangeImmediate) { next(() => this.onChangeImmediate(this.value)); @@ -71,27 +77,6 @@ export default TextField.extend({ } }, - didReceiveAttrs() { - this._super(...arguments); - this._prevValue = this.value; - }, - - didUpdateAttrs() { - this._super(...arguments); - if (this._prevValue !== this.value) { - if (this.onChangeImmediate) { - next(() => this.onChangeImmediate(this.value)); - } - if (this.onChange) { - debounce(this, this._debouncedChange, DEBOUNCE_MS); - } - } - }, - - _debouncedChange() { - next(() => this.onChange(this.value)); - }, - @discourseComputed("placeholderKey") placeholder: { get() { diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js index 9ed71e654a3..6a0fa4e6eff 100644 --- a/app/assets/javascripts/discourse/app/controllers/composer.js +++ b/app/assets/javascripts/discourse/app/controllers/composer.js @@ -95,8 +95,6 @@ export default Controller.extend({ scopedCategoryId: null, lastValidatedAt: null, isUploading: false, - allowUpload: false, - uploadIcon: "upload", topic: null, linkLookup: null, showPreview: true, diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 index df092d9a898..0ba26c48b46 100644 --- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 +++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 @@ -24,7 +24,6 @@ export default Component.extend({ formats: null, recurring: null, advancedMode: false, - isValid: true, timezone: null, fromSelected: null, fromFilled: notEmpty("date"),