DEV: linting of discourse-presence (#10722)

This commit is contained in:
Joffrey JAFFEUX 2020-09-22 17:20:00 +02:00 committed by GitHub
parent baa407fd9b
commit 4b94af077d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 9 deletions

View File

@ -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++;
} }

View File

@ -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,