mirror of
https://github.com/discourse/discourse.git
synced 2025-03-30 02:49:25 +08:00
DEV: linting of discourse-presence (#10722)
This commit is contained in:
parent
baa407fd9b
commit
4b94af077d
@ -54,7 +54,9 @@ const Presence = EmberObject.extend({
|
|||||||
this.channel,
|
this.channel,
|
||||||
(message) => {
|
(message) => {
|
||||||
const { user, state } = message;
|
const { user, state } = message;
|
||||||
if (this.get("currentUser.id") === user.id) return;
|
if (this.get("currentUser.id") === user.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case REPLYING:
|
case REPLYING:
|
||||||
@ -100,7 +102,9 @@ const Presence = EmberObject.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
publish(state, whisper, postId, staffOnly) {
|
publish(state, whisper, postId, staffOnly) {
|
||||||
if (this.get("currentUser.hide_profile_and_presence")) return;
|
if (this.get("currentUser.hide_profile_and_presence")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
state,
|
state,
|
||||||
@ -128,7 +132,9 @@ const Presence = EmberObject.extend({
|
|||||||
_removeUser(user) {
|
_removeUser(user) {
|
||||||
[this.users, this.editingUsers].forEach((users) => {
|
[this.users, this.editingUsers].forEach((users) => {
|
||||||
const existingUser = users.findBy("id", user.id);
|
const existingUser = users.findBy("id", user.id);
|
||||||
if (existingUser) users.removeObject(existingUser);
|
if (existingUser) {
|
||||||
|
users.removeObject(existingUser);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -158,7 +164,9 @@ const Presence = EmberObject.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attrs && attrs.post_id) {
|
if (attrs && attrs.post_id) {
|
||||||
if (u.post_id === attrs.post_id) usersLength++;
|
if (u.post_id === attrs.post_id) {
|
||||||
|
usersLength++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
usersLength++;
|
usersLength++;
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,16 @@ const PresenceManager = Service.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
subscribe(topicId, type) {
|
subscribe(topicId, type) {
|
||||||
if (!topicId) return;
|
if (!topicId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._getPresence(topicId).subscribe(type);
|
this._getPresence(topicId).subscribe(type);
|
||||||
},
|
},
|
||||||
|
|
||||||
unsubscribe(topicId, type) {
|
unsubscribe(topicId, type) {
|
||||||
if (!topicId) return;
|
if (!topicId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const presence = this._getPresence(topicId);
|
const presence = this._getPresence(topicId);
|
||||||
|
|
||||||
if (presence.unsubscribe(type)) {
|
if (presence.unsubscribe(type)) {
|
||||||
@ -29,17 +33,23 @@ const PresenceManager = Service.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
users(topicId) {
|
users(topicId) {
|
||||||
if (!topicId) return [];
|
if (!topicId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return this._getPresence(topicId).users;
|
return this._getPresence(topicId).users;
|
||||||
},
|
},
|
||||||
|
|
||||||
editingUsers(topicId) {
|
editingUsers(topicId) {
|
||||||
if (!topicId) return [];
|
if (!topicId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return this._getPresence(topicId).editingUsers;
|
return this._getPresence(topicId).editingUsers;
|
||||||
},
|
},
|
||||||
|
|
||||||
publish(topicId, state, whisper, postId, staffOnly) {
|
publish(topicId, state, whisper, postId, staffOnly) {
|
||||||
if (!topicId) return;
|
if (!topicId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return this._getPresence(topicId).publish(
|
return this._getPresence(topicId).publish(
|
||||||
state,
|
state,
|
||||||
whisper,
|
whisper,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user