mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 19:34:25 +08:00
FIX: Account for different composer 'edit' states in discourse-presence (#10631)
Previously we were manually comparing the composer 'action' to the REPLY and EDIT constants. This meant that other forms of editing (e.g. shared drafts) were not included. This commit changes the presence logic to use the existing composer computed variables.
This commit is contained in:
parent
e4fbe404b4
commit
d84dee4519
@ -1,6 +1,6 @@
|
|||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { cancel, throttle } from "@ember/runloop";
|
import { cancel, throttle } from "@ember/runloop";
|
||||||
import { equal, gt } from "@ember/object/computed";
|
import { gt, readOnly } from "@ember/object/computed";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import discourseComputed, {
|
import discourseComputed, {
|
||||||
observes,
|
observes,
|
||||||
@ -14,8 +14,6 @@ import {
|
|||||||
KEEP_ALIVE_DURATION_SECONDS,
|
KEEP_ALIVE_DURATION_SECONDS,
|
||||||
} from "discourse/plugins/discourse-presence/discourse/lib/presence";
|
} from "discourse/plugins/discourse-presence/discourse/lib/presence";
|
||||||
|
|
||||||
import { REPLY, EDIT } from "discourse/models/composer";
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
// Passed in variables
|
// Passed in variables
|
||||||
presenceManager: service(),
|
presenceManager: service(),
|
||||||
@ -30,7 +28,8 @@ export default Component.extend({
|
|||||||
return this.presenceManager.editingUsers(topicId);
|
return this.presenceManager.editingUsers(topicId);
|
||||||
},
|
},
|
||||||
|
|
||||||
isReply: equal("model.action", REPLY),
|
isReply: readOnly("model.replyingToTopic"),
|
||||||
|
isEdit: readOnly("model.editingPost"),
|
||||||
|
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
subscribe() {
|
subscribe() {
|
||||||
@ -41,12 +40,13 @@ export default Component.extend({
|
|||||||
"model.post.id",
|
"model.post.id",
|
||||||
"editingUsers.@each.last_seen",
|
"editingUsers.@each.last_seen",
|
||||||
"users.@each.last_seen",
|
"users.@each.last_seen",
|
||||||
"model.action"
|
"isReply",
|
||||||
|
"isEdit"
|
||||||
)
|
)
|
||||||
presenceUsers(postId, editingUsers, users, action) {
|
presenceUsers(postId, editingUsers, users, isReply, isEdit) {
|
||||||
if (action === EDIT) {
|
if (isEdit) {
|
||||||
return editingUsers.filterBy("post_id", postId);
|
return editingUsers.filterBy("post_id", postId);
|
||||||
} else if (action === REPLY) {
|
} else if (isReply) {
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
@ -60,18 +60,13 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_typing() {
|
_typing() {
|
||||||
const action = this.get("model.action");
|
if ((!this.isReply && !this.isEdit) || !this.get("model.composerOpened")) {
|
||||||
|
|
||||||
if (
|
|
||||||
(action !== REPLY && action !== EDIT) ||
|
|
||||||
!this.get("model.composerOpened")
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
topicId: this.get("model.topic.id"),
|
topicId: this.get("model.topic.id"),
|
||||||
state: action === EDIT ? EDITING : REPLYING,
|
state: this.isEdit ? EDITING : REPLYING,
|
||||||
whisper: this.get("model.whisper"),
|
whisper: this.get("model.whisper"),
|
||||||
postId: this.get("model.post.id"),
|
postId: this.get("model.post.id"),
|
||||||
presenceStaffOnly: this.get("model._presenceStaffOnly"),
|
presenceStaffOnly: this.get("model._presenceStaffOnly"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user