Task lists WIP

This commit is contained in:
John Livingston
2024-04-30 17:11:10 +02:00
parent ad090eaca4
commit ca026c2e10
10 changed files with 187 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import { _converse, converse } from '../../../src/headless/core.js'
import { ChatRoomTaskLists } from './task-lists.js'
import { ChatRoomTaskList } from './task-list.js'
import { getHeadingButtons } from './utils.js'
import { getHeadingButtons, initOrDestroyChatRoomTaskLists } from './utils.js'
import './muc-task-lists-view.js' // FIXME: here or in another file?
import './modals/muc-task-lists.js' // FIXME: here or in another file?
@ -12,6 +12,22 @@ converse.plugins.add('livechat-converse-tasks', {
_converse.ChatRoomTaskLists = ChatRoomTaskLists
_converse.ChatRoomTaskList = ChatRoomTaskList
_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)
})
})
// adding the "Tasks" button in the MUC heading buttons:
_converse.api.listen.on('getHeadingButtons', getHeadingButtons)
}