mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: apply coding standards to plugins (#10594)
This commit is contained in:
@ -4,14 +4,14 @@ import { equal, gt } from "@ember/object/computed";
|
||||
import { inject as service } from "@ember/service";
|
||||
import discourseComputed, {
|
||||
observes,
|
||||
on
|
||||
on,
|
||||
} from "discourse-common/utils/decorators";
|
||||
import {
|
||||
REPLYING,
|
||||
CLOSED,
|
||||
EDITING,
|
||||
COMPOSER_TYPE,
|
||||
KEEP_ALIVE_DURATION_SECONDS
|
||||
KEEP_ALIVE_DURATION_SECONDS,
|
||||
} from "discourse/plugins/discourse-presence/discourse/lib/presence";
|
||||
|
||||
import { REPLY, EDIT } from "discourse/models/composer";
|
||||
@ -74,7 +74,7 @@ export default Component.extend({
|
||||
state: action === EDIT ? EDITING : REPLYING,
|
||||
whisper: this.get("model.whisper"),
|
||||
postId: this.get("model.post.id"),
|
||||
presenceStaffOnly: this.get("model._presenceStaffOnly")
|
||||
presenceStaffOnly: this.get("model._presenceStaffOnly"),
|
||||
};
|
||||
|
||||
this._prevPublishData = data;
|
||||
@ -118,5 +118,5 @@ export default Component.extend({
|
||||
cancel(this._throttle);
|
||||
this._throttle = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -23,5 +23,5 @@ export default Component.extend({
|
||||
@on("willDestroyElement")
|
||||
_destroyed() {
|
||||
this.presenceManager.unsubscribe(this.get("topic.id"), TOPIC_TYPE);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ const Presence = EmberObject.extend({
|
||||
this.setProperties({
|
||||
users: [],
|
||||
editingUsers: [],
|
||||
subscribers: new Set()
|
||||
subscribers: new Set(),
|
||||
});
|
||||
},
|
||||
|
||||
@ -52,7 +52,7 @@ const Presence = EmberObject.extend({
|
||||
if (this.subscribers.size === 0) {
|
||||
this.messageBus.subscribe(
|
||||
this.channel,
|
||||
message => {
|
||||
(message) => {
|
||||
const { user, state } = message;
|
||||
if (this.get("currentUser.id") === user.id) return;
|
||||
|
||||
@ -62,7 +62,7 @@ const Presence = EmberObject.extend({
|
||||
break;
|
||||
case EDITING:
|
||||
this._appendUser(this.editingUsers, user, {
|
||||
post_id: parseInt(message.post_id, 10)
|
||||
post_id: parseInt(message.post_id, 10),
|
||||
});
|
||||
break;
|
||||
case CLOSED:
|
||||
@ -87,7 +87,7 @@ const Presence = EmberObject.extend({
|
||||
|
||||
this.setProperties({
|
||||
users: [],
|
||||
editingUsers: []
|
||||
editingUsers: [],
|
||||
});
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ const Presence = EmberObject.extend({
|
||||
|
||||
const data = {
|
||||
state,
|
||||
topic_id: this.topicId
|
||||
topic_id: this.topicId,
|
||||
};
|
||||
|
||||
if (whisper) {
|
||||
@ -121,22 +121,22 @@ const Presence = EmberObject.extend({
|
||||
|
||||
return ajax("/presence/publish", {
|
||||
type: "POST",
|
||||
data
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
_removeUser(user) {
|
||||
[this.users, this.editingUsers].forEach(users => {
|
||||
[this.users, this.editingUsers].forEach((users) => {
|
||||
const existingUser = users.findBy("id", user.id);
|
||||
if (existingUser) users.removeObject(existingUser);
|
||||
});
|
||||
},
|
||||
|
||||
_cleanUpUsers() {
|
||||
[this.users, this.editingUsers].forEach(users => {
|
||||
[this.users, this.editingUsers].forEach((users) => {
|
||||
const staleUsers = [];
|
||||
|
||||
users.forEach(user => {
|
||||
users.forEach((user) => {
|
||||
if (user.last_seen <= Date.now() - BUFFER_DURATION_SECONDS * 1000) {
|
||||
staleUsers.push(user);
|
||||
}
|
||||
@ -152,7 +152,7 @@ const Presence = EmberObject.extend({
|
||||
let existingUser;
|
||||
let usersLength = 0;
|
||||
|
||||
users.forEach(u => {
|
||||
users.forEach((u) => {
|
||||
if (u.id === user.id) {
|
||||
existingUser = u;
|
||||
}
|
||||
@ -204,7 +204,7 @@ const Presence = EmberObject.extend({
|
||||
if (!this._timer) {
|
||||
this.set("_timer", this._scheduleTimer(callback));
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default Presence;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Service from "@ember/service";
|
||||
import Presence, {
|
||||
CLOSED
|
||||
CLOSED,
|
||||
} from "discourse/plugins/discourse-presence/discourse/lib/presence";
|
||||
|
||||
const PresenceManager = Service.extend({
|
||||
@ -10,7 +10,7 @@ const PresenceManager = Service.extend({
|
||||
this._super(...arguments);
|
||||
|
||||
this.setProperties({
|
||||
presences: {}
|
||||
presences: {},
|
||||
});
|
||||
},
|
||||
|
||||
@ -49,7 +49,7 @@ const PresenceManager = Service.extend({
|
||||
},
|
||||
|
||||
cleanUpPresence(type) {
|
||||
Object.keys(this.presences).forEach(key => {
|
||||
Object.keys(this.presences).forEach((key) => {
|
||||
this.publish(key, CLOSED);
|
||||
this.unsubscribe(key, type);
|
||||
});
|
||||
@ -61,12 +61,12 @@ const PresenceManager = Service.extend({
|
||||
messageBus: this.messageBus,
|
||||
siteSettings: this.siteSettings,
|
||||
currentUser: this.currentUser,
|
||||
topicId
|
||||
topicId,
|
||||
});
|
||||
}
|
||||
|
||||
return this.presences[topicId];
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default PresenceManager;
|
||||
|
@ -1,5 +1,5 @@
|
||||
export default {
|
||||
shouldRender(_, component) {
|
||||
return component.siteSettings.presence_enabled;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
export default {
|
||||
shouldRender(_, component) {
|
||||
return component.siteSettings.presence_enabled;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user