From 828e8d85352a37c48d563bb1793f52382ec51b7b Mon Sep 17 00:00:00 2001 From: ubermanu <e.vodor@gmail.com> Date: Tue, 16 Mar 2021 04:06:17 +0100 Subject: [PATCH] minor: working rai, close the chatbox once it's left removed enableRAI method --- src/plugins/converse-rai.js | 41 ++----------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/src/plugins/converse-rai.js b/src/plugins/converse-rai.js index 91606bb..fb72df1 100644 --- a/src/plugins/converse-rai.js +++ b/src/plugins/converse-rai.js @@ -13,31 +13,12 @@ converse.plugins.add('converse-rai', { this.listenTo(this, 'change:hidden', this.onHiddenChange); }, - /** - * Subscribe to RAI if connected to the room, but it's hidden. - * @private - * @method _converse.ChatRoom#onConnectionStatusChanged - */ - async onConnectionStatusChanged() { - console.log('ChatRoom#onConnectionStatusChanged'); - const { api } = this.__super__._converse; - if (this.session.get('connection_status') === converse.ROOMSTATUS.ENTERED) { - if (this.get('hidden') && api.settings.get('muc_subscribe_to_rai') && this.getOwnAffiliation() !== 'none') { - await this.leave(); - // this.enableRAI(); - } else { - await this.__super__.onConnectionStatusChanged.apply(this, arguments); - } - } - }, - /** * Handler that gets called when the 'hidden' flag is toggled. * @private * @method _converse.ChatRoom#onHiddenChange */ async onHiddenChange() { - console.log('ChatRoomView#onHiddenChange'); const conn_status = this.session.get('connection_status'); const { api } = this.__super__._converse; @@ -46,29 +27,11 @@ converse.plugins.add('converse-rai', { if (conn_status !== converse.ROOMSTATUS.DISCONNECTED) { this.sendMarkerForLastMessage('received', true); await this.leave(); + await this.close(); } - // this.enableRAI(); } } else if (conn_status === converse.ROOMSTATUS.DISCONNECTED) { - this.rejoin(); - } - }, - - /** - * Ensures that the user is subscribed to XEP-0437 Room Activity Indicators - * if `muc_subscribe_to_rai` is set to `true`. - * Only affiliated users can subscribe to RAI, but this method doesn't - * check whether the current user is affiliated because it's intended to be - * called after the MUC has been left and we don't have that information - * anymore. - * @private - * @method _converse.ChatRoom#enableRAI - */ - enableRAI() { - console.log('ChatRoom#enableRAI'); - const { api } = this.__super__._converse; - if (api.settings.get('muc_subscribe_to_rai')) { - api.rooms.subscribe(this.get('jid')); + await this.rejoin(); } }, }, -- GitLab