mirror of
https://github.com/discourse/discourse.git
synced 2025-03-31 18:25:59 +08:00
FIX: Throttle typing function in discourse-presence.
This commit is contained in:
parent
0e09c5837f
commit
aa40a07d73
plugins/discourse-presence/assets/javascripts/discourse
16
plugins/discourse-presence/assets/javascripts/discourse/components/composer-presence-display.js.es6
16
plugins/discourse-presence/assets/javascripts/discourse/components/composer-presence-display.js.es6
@ -1,12 +1,18 @@
|
|||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { cancel } from "@ember/runloop";
|
import { cancel, throttle } from "@ember/runloop";
|
||||||
import { equal, gt } from "@ember/object/computed";
|
import { equal, gt } from "@ember/object/computed";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import discourseComputed, {
|
import discourseComputed, {
|
||||||
observes,
|
observes,
|
||||||
on
|
on
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import { REPLYING, CLOSED, EDITING, COMPOSER_TYPE } from "../lib/presence";
|
import {
|
||||||
|
REPLYING,
|
||||||
|
CLOSED,
|
||||||
|
EDITING,
|
||||||
|
COMPOSER_TYPE,
|
||||||
|
KEEP_ALIVE_DURATION_SECONDS
|
||||||
|
} from "../lib/presence";
|
||||||
import { REPLY, EDIT } from "discourse/models/composer";
|
import { REPLY, EDIT } from "discourse/models/composer";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
@ -55,6 +61,10 @@ export default Component.extend({
|
|||||||
|
|
||||||
@observes("reply", "title")
|
@observes("reply", "title")
|
||||||
typing() {
|
typing() {
|
||||||
|
throttle(this, this._typing, KEEP_ALIVE_DURATION_SECONDS * 1000);
|
||||||
|
},
|
||||||
|
|
||||||
|
_typing() {
|
||||||
const action = this.action;
|
const action = this.action;
|
||||||
|
|
||||||
if (action !== REPLY && action !== EDIT) {
|
if (action !== REPLY && action !== EDIT) {
|
||||||
@ -70,7 +80,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
this._prevPublishData = data;
|
this._prevPublishData = data;
|
||||||
|
|
||||||
this._throttle = this.presenceManager.throttlePublish(
|
this._throttle = this.presenceManager.publish(
|
||||||
data.topicId,
|
data.topicId,
|
||||||
data.state,
|
data.state,
|
||||||
data.whisper,
|
data.whisper,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { cancel, later, throttle } from "@ember/runloop";
|
import { cancel, later } from "@ember/runloop";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
@ -99,17 +99,6 @@ const Presence = EmberObject.extend({
|
|||||||
return `/presence/${topicId}`;
|
return `/presence/${topicId}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
throttlePublish(state, whisper, postId) {
|
|
||||||
return throttle(
|
|
||||||
this,
|
|
||||||
this.publish,
|
|
||||||
state,
|
|
||||||
whisper,
|
|
||||||
postId,
|
|
||||||
KEEP_ALIVE_DURATION_SECONDS * 1000
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
publish(state, whisper, postId) {
|
publish(state, whisper, postId) {
|
||||||
if (this.get("currentUser.hide_profile_and_presence")) return;
|
if (this.get("currentUser.hide_profile_and_presence")) return;
|
||||||
|
|
||||||
|
@ -36,11 +36,6 @@ const PresenceManager = Service.extend({
|
|||||||
return this._getPresence(topicId).editingUsers;
|
return this._getPresence(topicId).editingUsers;
|
||||||
},
|
},
|
||||||
|
|
||||||
throttlePublish(topicId, state, whisper, postId) {
|
|
||||||
if (!topicId) return;
|
|
||||||
return this._getPresence(topicId).throttlePublish(state, whisper, postId);
|
|
||||||
},
|
|
||||||
|
|
||||||
publish(topicId, state, whisper, postId) {
|
publish(topicId, state, whisper, postId) {
|
||||||
if (!topicId) return;
|
if (!topicId) return;
|
||||||
return this._getPresence(topicId).publish(state, whisper, postId);
|
return this._getPresence(topicId).publish(state, whisper, postId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user