2024-04-29 14:46:21 +00:00
|
|
|
import { _converse, converse } from '../../../src/headless/core.js'
|
|
|
|
import { ChatRoomTaskLists } from './task-lists.js'
|
|
|
|
import { ChatRoomTaskList } from './task-list.js'
|
2024-04-30 16:30:44 +00:00
|
|
|
import { ChatRoomTasks } from './tasks.js'
|
2024-04-30 15:11:10 +00:00
|
|
|
import { getHeadingButtons, initOrDestroyChatRoomTaskLists } from './utils.js'
|
2024-04-30 16:30:44 +00:00
|
|
|
import './muc-task-view.js' // FIXME: here or in another file?
|
|
|
|
import './muc-task-list-view.js' // FIXME: here or in another file?
|
2024-04-30 07:21:18 +00:00
|
|
|
import './muc-task-lists-view.js' // FIXME: here or in another file?
|
|
|
|
import './modals/muc-task-lists.js' // FIXME: here or in another file?
|
2024-04-29 14:46:21 +00:00
|
|
|
|
2024-05-03 17:28:26 +00:00
|
|
|
// TODO: add a client disco feature (using api.listen.on('addClientFeatures' ...)).
|
|
|
|
|
2024-04-29 14:46:21 +00:00
|
|
|
converse.plugins.add('livechat-converse-tasks', {
|
|
|
|
dependencies: ['converse-muc', 'converse-disco'], // TODO: add converse-pubsub
|
|
|
|
|
|
|
|
initialize () {
|
|
|
|
_converse.ChatRoomTaskLists = ChatRoomTaskLists
|
|
|
|
_converse.ChatRoomTaskList = ChatRoomTaskList
|
2024-04-30 16:30:44 +00:00
|
|
|
_converse.ChatRoomTasks = ChatRoomTasks
|
2024-04-29 14:46:21 +00:00
|
|
|
|
2024-04-30 15:11:10 +00:00
|
|
|
_converse.api.listen.on('chatRoomInitialized', muc => {
|
|
|
|
muc.session.on('change:connection_status', _session => {
|
|
|
|
// When joining a room, initializing the TaskLists object (if user has access),
|
|
|
|
// When disconnected from a room, destroying the Tasklists object:
|
|
|
|
initOrDestroyChatRoomTaskLists(muc)
|
|
|
|
})
|
|
|
|
|
|
|
|
// When the current user role changes, we must also delete or initilize the TaskLists object:
|
|
|
|
muc.occupants.on('change:role', occupant => {
|
|
|
|
if (occupant.get('jid') !== _converse.bare_jid) { // only for myself
|
|
|
|
return
|
|
|
|
}
|
|
|
|
initOrDestroyChatRoomTaskLists(muc)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2024-04-30 07:21:18 +00:00
|
|
|
// adding the "Tasks" button in the MUC heading buttons:
|
2024-04-29 14:46:21 +00:00
|
|
|
_converse.api.listen.on('getHeadingButtons', getHeadingButtons)
|
|
|
|
}
|
|
|
|
})
|