Skip to content

Commit

Permalink
Some MUC improvements
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jcbrand committed Feb 7, 2025
1 parent 5f8616d commit 87d1189
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
11 changes: 1 addition & 10 deletions src/headless/plugins/bookmarks/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/headless/plugins/muc/muc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'] });
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/plugins/muc-views/modals/templates/muc-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const subject = (model) => {
const i18n_topic = __('Topic');
const i18n_topic_author = __('Topic author');
return html`
<p class="room-info"><strong>${i18n_topic}</strong>: <converse-texture text=${subject.text} render_styling></converse-texture></p>
<p class="room-info"><strong>${i18n_topic_author}</strong>: ${subject && subject.author}</p>
<p class="room-info"><strong>${i18n_topic}:</strong> <converse-texture text=${subject.text} render_styling></converse-texture></p>
<p class="room-info"><strong>${i18n_topic_author}:</strong> ${subject && subject.author}</p>
`;
}

Expand Down Expand Up @@ -65,13 +65,13 @@ export default (model) => {
nonce=${model.vcard?.get('vcard_updated')}
height="72" width="72"></converse-avatar>
<p class="room-info"><strong>${i18n_name}</strong>: ${model.get('name')}</p>
<p class="room-info"><strong>${i18n_address}</strong>: <converse-texture text="xmpp:${model.get('jid')}?join"></converse-texture></p>
<p class="room-info"><strong>${i18n_name}:</strong> ${model.get('name')}</p>
<p class="room-info"><strong>${i18n_address}:</strong> <converse-texture text="xmpp:${model.get('jid')}?join"></converse-texture></p>
<br/>
<p class="room-info"><strong>${i18n_desc}</strong>: <converse-texture text="${config.description}" render_styling></converse-texture></p>
<p class="room-info"><strong>${i18n_desc}:</strong> <converse-texture text="${config.description}" render_styling></converse-texture></p>
${ (model.get('subject')) ? subject(model) : '' }
<p class="room-info"><strong>${i18n_online_users}</strong>: ${num_occupants}</p>
<p class="room-info"><strong>${i18n_features}</strong>:
<p class="room-info"><strong>${i18n_online_users}:</strong> ${num_occupants}</p>
<p class="room-info"><strong>${i18n_features}:</strong>
<div class="chatroom-features">
<ul class="features-list">
${ features.passwordprotected ? html`<li class="feature"><converse-icon size="1em" class="fa fa-lock"></converse-icon>${i18n_password_protected} - <em>${i18n_password_help}</em></li>` : '' }
Expand Down
1 change: 1 addition & 0 deletions src/plugins/muc-views/styles/muc-details-modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ converse-muc-details-modal {
}
strong {
color: var(--muc-color);
margin-right: 0.5em;
}
}

Expand Down
8 changes: 0 additions & 8 deletions src/plugins/muc-views/templates/muc-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default (el) => {
const subject_hidden = el.user_settings?.get('mucs_with_hidden_subject', [])?.includes(el.model.get('jid'));
const heading_buttons_promise = el.getHeadingButtons(subject_hidden);
const i18n_hide_topic = __('Hide the groupchat topic');
const i18n_bookmarked = __('This groupchat is bookmarked');
const subject = o.subject ? o.subject.text : '';
const show_subject = (subject && !subject_hidden);
return html`
Expand All @@ -37,13 +36,6 @@ export default (el) => {
role="heading" aria-level="2"
title="${ (api.settings.get('locked_muc_domain') !== 'hidden') ? o.jid : '' }">
${ el.model.getDisplayName() }
${ (o.bookmarked) ?
html`<converse-icon
class="fa fa-bookmark chatbox-title__text--bookmarked"
size="1em"
color="var(--muc-color)"
title="${i18n_bookmarked}">
</converse-icon>` : '' }
</div>
</div>
<div class="chatbox-title__buttons btn-toolbar g-0">
Expand Down

0 comments on commit 87d1189

Please sign in to comment.