peertube-plugin-livechat/conversejs/custom/plugins/mam-search/index.js

34 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-08-01 14:10:34 +00:00
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
import { api, converse } from '../../../src/headless/index.js'
2024-08-06 15:32:37 +00:00
import { getMessageActionButtons, getOccupantActionButtons } from './utils.js'
2024-08-01 14:10:34 +00:00
import mamSearchApi from './api.js'
2024-08-01 16:58:25 +00:00
import './components/muc-mam-search-app-view.js'
import './components/muc-mam-search-occupant-view.js'
2024-08-05 09:44:11 +00:00
import './components/muc-mam-search-message-view.js'
2024-08-01 14:10:34 +00:00
converse.plugins.add('livechat-converse-mam-search', {
dependencies: ['converse-muc', 'converse-muc-views'],
async initialize () {
const _converse = this._converse
Object.assign(api, {
livechat_mam_search: mamSearchApi
})
2024-08-01 16:58:25 +00:00
_converse.api.settings.extend({
livechat_mam_search_app_enabled: false
})
2024-08-06 15:32:37 +00:00
// Adding buttons on messages:
2024-08-01 14:10:34 +00:00
_converse.api.listen.on('getMessageActionButtons', getMessageActionButtons)
2024-08-06 15:32:37 +00:00
// Adding buttons on occupants:
_converse.api.listen.on('getOccupantActionButtons', getOccupantActionButtons)
2024-08-01 14:10:34 +00:00
// FIXME: should we listen to any event (feature/affiliation change?, mam_enabled?) to refresh messageActionButtons?
}
})