Simplify handling of permissions for websocket, only send permissions the user actually has

This commit is contained in:
Dane Everitt 2020-04-06 21:03:00 -07:00
parent a924eb56cc
commit b1e7e0b8b0
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 38 additions and 27 deletions

View file

@ -20,7 +20,7 @@ export class Websocket extends EventEmitter {
// refreshed at a pretty continuous interval. The socket server will respond
// with "token expiring" and "token expired" events when approaching 3 minutes
// and 0 minutes to expiry.
private token: string = '';
private token = '';
// Connects to the websocket instance and sets the token for the initial request.
connect (url: string): this {
@ -28,7 +28,7 @@ export class Websocket extends EventEmitter {
this.socket = new Sockette(`${this.url}`, {
onmessage: e => {
try {
let { event, args } = JSON.parse(e.data);
const { event, args } = JSON.parse(e.data);
args ? this.emit(event, ...args) : this.emit(event);
} catch (ex) {
console.warn('Failed to parse incoming websocket message.', ex);