From 87d11893d6a25ca2a11941897c3d9db10f4cb2b7 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 7 Feb 2025 11:55:43 +0200 Subject: [PATCH] Some MUC improvements - Don't show the bookmarked icon in the header. - Don't use the `name` from the bookmark, since Converse doesn't let you set the bookmark name and using it adds complexity. - While refreshing the disco, set the MUC name --- src/headless/plugins/bookmarks/plugin.js | 11 +---------- src/headless/plugins/muc/muc.js | 6 ++++++ .../muc-views/modals/templates/muc-details.js | 14 +++++++------- .../muc-views/styles/muc-details-modal.scss | 1 + src/plugins/muc-views/templates/muc-head.js | 8 -------- 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/headless/plugins/bookmarks/plugin.js b/src/headless/plugins/bookmarks/plugin.js index 0e567315aa..17388b27c1 100644 --- a/src/headless/plugins/bookmarks/plugin.js +++ b/src/headless/plugins/bookmarks/plugin.js @@ -27,16 +27,7 @@ converse.plugins.add('converse-bookmarks', { // New functions which don't exist yet can also be added. ChatRoom: { - getDisplayName() { - const { _converse, getDisplayName } = this.__super__; - const { bookmarks } = _converse.state; - const bookmark = this.get('bookmarked') ? bookmarks?.get(this.get('jid')) : null; - return bookmark?.get('name') || getDisplayName.apply(this, arguments); - }, - - /** - * @param {string} nick - */ + /** @param {string} nick */ getAndPersistNickname(nick) { nick = nick || getNicknameFromBookmark(this.get('jid')); return this.__super__.getAndPersistNickname.call(this, nick); diff --git a/src/headless/plugins/muc/muc.js b/src/headless/plugins/muc/muc.js index 4472da3507..ab2c68cea9 100644 --- a/src/headless/plugins/muc/muc.js +++ b/src/headless/plugins/muc/muc.js @@ -1235,14 +1235,20 @@ class MUC extends ModelWithMessages(ColorAwareModel(ChatBoxBase)) { */ async getDiscoInfoFields () { const fields = await api.disco.getFields(this.get('jid')); + const config = fields.reduce((config, f) => { const name = f.get('var'); + if (name === 'muc#roomconfig_roomname') { + config['roomname'] = f.get('value'); + } if (name?.startsWith('muc#roominfo_')) { config[name.replace('muc#roominfo_', '')] = f.get('value'); } return config; }, {}); + this.config.save(config); + if (config['roomname']) this.save({ name: config['roomname'] }); } /** diff --git a/src/plugins/muc-views/modals/templates/muc-details.js b/src/plugins/muc-views/modals/templates/muc-details.js index ff7d6ea8c5..ae51506d24 100644 --- a/src/plugins/muc-views/modals/templates/muc-details.js +++ b/src/plugins/muc-views/modals/templates/muc-details.js @@ -11,8 +11,8 @@ const subject = (model) => { const i18n_topic = __('Topic'); const i18n_topic_author = __('Topic author'); return html` -

${i18n_topic}:

-

${i18n_topic_author}: ${subject && subject.author}

+

${i18n_topic}:

+

${i18n_topic_author}: ${subject && subject.author}

`; } @@ -65,13 +65,13 @@ export default (model) => { nonce=${model.vcard?.get('vcard_updated')} height="72" width="72"> -

${i18n_name}: ${model.get('name')}

-

${i18n_address}:

+

${i18n_name}: ${model.get('name')}

+

${i18n_address}:


-

${i18n_desc}:

+

${i18n_desc}:

${ (model.get('subject')) ? subject(model) : '' } -

${i18n_online_users}: ${num_occupants}

-

${i18n_features}: +

${i18n_online_users}: ${num_occupants}

+

${i18n_features}: