2024-05-23 09:42:14 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-07-25 16:03:46 +00:00
|
|
|
import { customizeHeading } from './livechat-specific/heading'
|
|
|
|
import { customizeToolbar } from './livechat-specific/toolbar'
|
|
|
|
import { initReconnectionStuff } from './livechat-specific/reconnection'
|
|
|
|
import { chatRoomOverrides } from './livechat-specific/chatroom'
|
|
|
|
import { chatRoomMessageOverrides } from './livechat-specific/chatroom-message'
|
2024-07-26 08:51:55 +00:00
|
|
|
import { customizeMessageAction } from './livechat-specific/message-action'
|
2024-07-25 16:03:46 +00:00
|
|
|
|
2024-03-27 15:26:32 +00:00
|
|
|
export const livechatSpecificsPlugin = {
|
|
|
|
dependencies: ['converse-muc', 'converse-muc-views'],
|
|
|
|
initialize: function (this: any) {
|
|
|
|
const _converse = this._converse
|
2024-04-18 14:24:09 +00:00
|
|
|
|
|
|
|
_converse.api.settings.extend({
|
|
|
|
// if user is authenticated with an external account (to add a logout button)
|
2024-06-20 14:46:14 +00:00
|
|
|
livechat_specific_external_authent: false,
|
|
|
|
// if user is anonymous
|
|
|
|
livechat_specific_is_anonymous: false
|
2024-04-18 14:24:09 +00:00
|
|
|
})
|
|
|
|
|
2024-07-25 16:03:46 +00:00
|
|
|
customizeHeading(this)
|
|
|
|
customizeToolbar(this)
|
2024-07-26 08:51:55 +00:00
|
|
|
customizeMessageAction(this)
|
2024-07-15 14:50:26 +00:00
|
|
|
|
2024-03-27 15:26:32 +00:00
|
|
|
_converse.api.listen.on('chatRoomViewInitialized', function (this: any, _model: any): void {
|
|
|
|
// Remove the spinner if present...
|
|
|
|
document.getElementById('livechat-loading-spinner')?.remove()
|
|
|
|
})
|
|
|
|
|
2024-07-25 16:03:46 +00:00
|
|
|
initReconnectionStuff(this)
|
2024-03-28 11:22:30 +00:00
|
|
|
|
2024-03-28 10:16:33 +00:00
|
|
|
if (window.location.protocol === 'http:') {
|
|
|
|
// We are probably on a dev instance, so we will add _converse in window:
|
|
|
|
(window as any)._livechatConverse = _converse
|
|
|
|
}
|
2024-03-27 15:26:32 +00:00
|
|
|
},
|
|
|
|
overrides: {
|
2024-07-25 16:03:46 +00:00
|
|
|
ChatRoom: chatRoomOverrides(),
|
2024-07-25 16:32:38 +00:00
|
|
|
ChatRoomMessage: chatRoomMessageOverrides()
|
2024-07-15 14:50:26 +00:00
|
|
|
}
|
|
|
|
}
|