DEV: defines a constant for INPUT_DELAY (#9169)

This commit is contained in:
Joffrey JAFFEUX 2020-03-11 15:28:16 +01:00 committed by GitHub
parent 40d7686234
commit 4e0b2ae294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 41 additions and 22 deletions

View File

@ -1,6 +1,7 @@
import discourseComputed from "discourse-common/utils/decorators";
import { debounce } from "@ember/runloop";
import Controller from "@ember/controller";
import { INPUT_DELAY } from "discourse-common/config/environment";
const { get } = Ember;
@ -23,7 +24,7 @@ export default Controller.extend({
actions: {
filterReports(filter) {
debounce(this, this._performFiltering, filter, 250);
debounce(this, this._performFiltering, filter, INPUT_DELAY);
}
},

View File

@ -1,10 +1,11 @@
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
import discourseDebounce from "discourse/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default AdminEmailLogsController.extend({
@observes("filter.{status,user,address,type}")
filterEmailLogs: discourseDebounce(function() {
this.loadLogs();
}, 250)
}, INPUT_DELAY)
});

View File

@ -2,12 +2,13 @@ import AdminEmailLogsController from "admin/controllers/admin-email-logs";
import discourseDebounce from "discourse/lib/debounce";
import IncomingEmail from "admin/models/incoming-email";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default AdminEmailLogsController.extend({
@observes("filter.{status,from,to,subject}")
filterIncomingEmails: discourseDebounce(function() {
this.loadLogs(IncomingEmail);
}, 250),
}, INPUT_DELAY),
actions: {
loadMore() {

View File

@ -2,12 +2,13 @@ import AdminEmailLogsController from "admin/controllers/admin-email-logs";
import discourseDebounce from "discourse/lib/debounce";
import IncomingEmail from "admin/models/incoming-email";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default AdminEmailLogsController.extend({
@observes("filter.{status,from,to,subject,error}")
filterIncomingEmails: discourseDebounce(function() {
this.loadLogs(IncomingEmail);
}, 250),
}, INPUT_DELAY),
actions: {
loadMore() {

View File

@ -1,10 +1,11 @@
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
import discourseDebounce from "discourse/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default AdminEmailLogsController.extend({
@observes("filter.{status,user,address,type,reply_key}")
filterEmailLogs: discourseDebounce(function() {
this.loadLogs();
}, 250)
}, INPUT_DELAY)
});

View File

@ -1,10 +1,11 @@
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
import discourseDebounce from "discourse/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default AdminEmailLogsController.extend({
@observes("filter.{status,user,address,type}")
filterEmailLogs: discourseDebounce(function() {
this.loadLogs();
}, 250)
}, INPUT_DELAY)
});

View File

@ -4,6 +4,7 @@ import { outputExportResult } from "discourse/lib/export-result";
import { exportEntity } from "discourse/lib/export-csv";
import ScreenedIpAddress from "admin/models/screened-ip-address";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default Controller.extend({
loading: false,
@ -16,7 +17,7 @@ export default Controller.extend({
ScreenedIpAddress.findAll(this.filter).then(result => {
this.setProperties({ model: result, loading: false });
});
}, 250),
}, INPUT_DELAY),
actions: {
allow(record) {

View File

@ -2,6 +2,7 @@ import Controller from "@ember/controller";
import discourseDebounce from "discourse/lib/debounce";
import Permalink from "admin/models/permalink";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default Controller.extend({
loading: false,
@ -13,7 +14,7 @@ export default Controller.extend({
this.set("model", result);
this.set("loading", false);
});
}, 250),
}, INPUT_DELAY),
actions: {
recordAdded(arg) {

View File

@ -3,6 +3,7 @@ import { alias } from "@ember/object/computed";
import Controller from "@ember/controller";
import discourseDebounce from "discourse/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default Controller.extend({
filter: null,
@ -84,7 +85,7 @@ export default Controller.extend({
} else {
this.filterContentNow();
}
}, 250),
}, INPUT_DELAY),
actions: {
clearFilter() {

View File

@ -4,6 +4,7 @@ import discourseDebounce from "discourse/lib/debounce";
import { i18n } from "discourse/lib/computed";
import AdminUser from "admin/models/admin-user";
import CanCheckEmails from "discourse/mixins/can-check-emails";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default Controller.extend(CanCheckEmails, {
model: null,
@ -32,7 +33,7 @@ export default Controller.extend(CanCheckEmails, {
@observes("listFilter")
_filterUsers: discourseDebounce(function() {
this.resetFilters();
}, 250),
}, INPUT_DELAY),
resetFilters() {
this._page = 1;

View File

@ -4,6 +4,7 @@ import EmberObject from "@ember/object";
import Controller from "@ember/controller";
import discourseDebounce from "discourse/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default Controller.extend({
filter: null,
@ -48,7 +49,7 @@ export default Controller.extend({
filterContent: discourseDebounce(function() {
this.filterContentNow();
this.set("filtered", !isEmpty(this.filter));
}, 250),
}, INPUT_DELAY),
actions: {
clearFilter() {

View File

@ -1 +1,3 @@
export const INPUT_DELAY = 250;
export default { environment: Ember.testing ? "test" : "development" };

View File

@ -9,7 +9,7 @@ import {
emojiSearch
} from "pretty-text/emoji";
import { safariHacksDisabled } from "discourse/lib/utilities";
import ENV from "discourse-common/config/environment";
import ENV, { INPUT_DELAY } from "discourse-common/config/environment";
const { run } = Ember;
@ -94,7 +94,7 @@ export default Component.extend({
@observes("filter")
filterChanged() {
this.$filter.find(".clear-filter").toggle(!_.isEmpty(this.filter));
const filterDelay = this.site.isMobileDevice ? 400 : 250;
const filterDelay = this.site.isMobileDevice ? 400 : INPUT_DELAY;
run.debounce(this, this._filterEmojisList, filterDelay);
},

View File

@ -2,6 +2,7 @@ import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import discourseDebounce from "discourse/lib/debounce";
import { selectedText, selectedElement } from "discourse/lib/utilities";
import { INPUT_DELAY } from "discourse-common/config/environment";
function getQuoteTitle(element) {
const titleEl = element.querySelector(".title");
@ -146,7 +147,7 @@ export default Component.extend({
didInsertElement() {
const { isWinphone, isAndroid } = this.capabilities;
const wait = isWinphone || isAndroid ? 250 : 25;
const wait = isWinphone || isAndroid ? INPUT_DELAY : 25;
const onSelectionChanged = discourseDebounce(
() => this._selectionChanged(),
wait

View File

@ -5,6 +5,7 @@ import { escapeExpression } from "discourse/lib/utilities";
import Group from "discourse/models/group";
import Badge from "discourse/models/badge";
import Category from "discourse/models/category";
import { INPUT_DELAY } from "discourse-common/config/environment";
const REGEXP_BLOCKS = /(([^" \t\n\x0B\f\r]+)?(("[^"]+")?))/g;
@ -82,7 +83,7 @@ export default Component.extend({
@observes("searchTerm")
_updateOptions() {
this._update();
debounce(this, this._update, 250);
debounce(this, this._update, INPUT_DELAY);
},
_init() {

View File

@ -4,6 +4,7 @@ import Invite from "discourse/models/invite";
import discourseDebounce from "discourse/lib/debounce";
import { popupAjaxError } from "discourse/lib/ajax-error";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default Controller.extend({
user: null,
@ -30,7 +31,7 @@ export default Controller.extend({
this.filter,
this.searchTerm
).then(invites => this.set("model", invites));
}, 250),
}, INPUT_DELAY),
inviteRedeemed: equal("filter", "redeemed"),

View File

@ -4,6 +4,7 @@ import Composer from "discourse/models/composer";
import { minimumOffset } from "discourse/lib/offset-calculator";
import { ajax } from "discourse/lib/ajax";
import { throttle } from "@ember/runloop";
import { INPUT_DELAY } from "discourse-common/config/environment";
const bindings = {
"!": { postAction: "showFlags" },
@ -299,19 +300,19 @@ export default {
},
setTrackingToMuted(event) {
throttle(this, "_setTracking", { id: 0, event }, 250, true);
throttle(this, "_setTracking", { id: 0, event }, INPUT_DELAY, true);
},
setTrackingToRegular(event) {
throttle(this, "_setTracking", { id: 1, event }, 250, true);
throttle(this, "_setTracking", { id: 1, event }, INPUT_DELAY, true);
},
setTrackingToTracking(event) {
throttle(this, "_setTracking", { id: 2, event }, 250, true);
throttle(this, "_setTracking", { id: 2, event }, INPUT_DELAY, true);
},
setTrackingToWatching(event) {
throttle(this, "_setTracking", { id: 3, event }, 250, true);
throttle(this, "_setTracking", { id: 3, event }, INPUT_DELAY, true);
},
_setTracking(params) {

View File

@ -4,6 +4,7 @@ import {
safariHacksDisabled,
iOSWithVisualViewport
} from "discourse/lib/utilities";
import { INPUT_DELAY } from "discourse-common/config/environment";
// TODO: remove calcHeight once iOS 13 adoption > 90%
// In iOS 13 and up we use visualViewport API to calculate height
@ -136,7 +137,7 @@ function positioningWorkaround($fixedElement) {
positioningWorkaround.blur(evt);
};
var blurred = discourseDebounce(blurredNow, 250);
var blurred = discourseDebounce(blurredNow, INPUT_DELAY);
var positioningHack = function(evt) {
// we need this, otherwise changing focus means we never clear

View File

@ -10,6 +10,7 @@ import loadScript from "discourse/lib/load-script";
import computed, { observes } from "discourse-common/utils/decorators";
import { cookAsync } from "discourse/lib/text";
import discourseDebounce from "discourse/lib/debounce";
import { INPUT_DELAY } from "discourse-common/config/environment";
export default Component.extend({
timeFormat: "HH:mm:ss",
@ -66,7 +67,7 @@ export default Component.extend({
);
});
}
}, 250),
}, INPUT_DELAY),
@computed("date", "toDate", "toTime")
isRange(date, toDate, toTime) {