From 70f702f78ecde5b49b24143ea15444243fe1325c Mon Sep 17 00:00:00 2001 From: John Livingston Date: Wed, 31 Jul 2024 17:45:51 +0200 Subject: [PATCH] Fix: clicking on the current user nickname in message history was failing to open the profile modal. --- CHANGELOG.md | 1 + conversejs/lib/plugins/livechat-specific.ts | 2 ++ .../lib/plugins/livechat-specific/profile.ts | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 conversejs/lib/plugins/livechat-specific/profile.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 017e1625..54cd5bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Translation updates: Crotian, Japanese. * Updated mod_muc_moderation to upstream. * Fix new task ordering. +* Fix: clicking on the current user nickname in message history was failing to open the profile modal. ## 10.3.3 diff --git a/conversejs/lib/plugins/livechat-specific.ts b/conversejs/lib/plugins/livechat-specific.ts index 494f88bb..6313564d 100644 --- a/conversejs/lib/plugins/livechat-specific.ts +++ b/conversejs/lib/plugins/livechat-specific.ts @@ -8,6 +8,7 @@ import { initReconnectionStuff } from './livechat-specific/reconnection' import { chatRoomOverrides } from './livechat-specific/chatroom' import { chatRoomMessageOverrides } from './livechat-specific/chatroom-message' import { customizeMessageAction } from './livechat-specific/message-action' +import { customizeProfileModal } from './livechat-specific/profile' export const livechatSpecificsPlugin = { dependencies: ['converse-muc', 'converse-muc-views'], @@ -24,6 +25,7 @@ export const livechatSpecificsPlugin = { customizeHeading(this) customizeToolbar(this) customizeMessageAction(this) + customizeProfileModal(this) _converse.api.listen.on('chatRoomViewInitialized', function (this: any, _model: any): void { // Remove the spinner if present... diff --git a/conversejs/lib/plugins/livechat-specific/profile.ts b/conversejs/lib/plugins/livechat-specific/profile.ts new file mode 100644 index 00000000..fbb60bd6 --- /dev/null +++ b/conversejs/lib/plugins/livechat-specific/profile.ts @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2024 John Livingston +// +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * Livechat Converse does not include plugins/profile, + * so the default profile modal is broken. + * Moreover this modal includes some features that we do not want (password change, ...). + * So we simply define the converse-profile-modal to be converse-muc-occupant-modal! + * @param plugin The plugin object + */ +export function customizeProfileModal (plugin: any): void { + const _converse = plugin._converse + const OccupantModal = _converse.api.elements.registry['converse-muc-occupant-modal'] + if (!OccupantModal) { return } + class ProfileModal extends OccupantModal { + initialize (): any { + // We just need to change the modal for the occupant: + if (this.model?.getOccupant) { + this.model = this.model.getOccupant() + } + return super.initialize() + } + } + _converse.api.elements.define('converse-profile-modal', ProfileModal) +}