diff options
-rw-r--r-- | qml/ChatPage.qml | 44 | ||||
-rw-r--r-- | qml/ChatlistPage.qml | 21 |
2 files changed, 28 insertions, 37 deletions
diff --git a/qml/ChatPage.qml b/qml/ChatPage.qml index 1862b44..4496954 100644 --- a/qml/ChatPage.qml +++ b/qml/ChatPage.qml @@ -48,44 +48,36 @@ Kirigami.ScrollablePage { } } - signal chatModified() - onChatModified: { - console.log("CHAT MODIFIED!") - } - - signal incomingEvent() - onIncomingEvent: { - console.log("EVENT!") - } - ListModel { id: messagelistModel } - signal incomingMessage() - onIncomingMessage: { - console.log("Incoming message for chat " + chatId) + Connections { + target: chatPage.eventEmitter - if (chatId == chatPage.chatId) { - updateMessagelist() + function onIncomingEvent() { + console.log("EVENT!") } - } + function onChatModified() { + console.log("CHAT MODIFIED!") + } + function onIncomingMessage() { + console.log("Incoming message for chat " + chatId) - signal messagesChanged(var accountId, int chatId, int msgId) - onMessagesChanged: { - console.log("Messages changed for chat " + chatId) + if (chatId == chatPage.chatId) { + updateMessagelist() + } + } + function onMessagesChanged(accountId, chatId, msgId) { + console.log("Messages changed for chat " + chatId) - if (chatId == chatPage.chatId) { - updateMessagelist() + if (chatId == chatPage.chatId) { + updateMessagelist() + } } } Component.onCompleted: { - eventEmitter.onIncomingEvent.connect(incomingEvent) - eventEmitter.onChatModified.connect(chatModified) - eventEmitter.onIncomingMessage.connect(incomingMessage) - eventEmitter.onMessagesChanged.connect(messagesChanged) - updateMessagelist() } diff --git a/qml/ChatlistPage.qml b/qml/ChatlistPage.qml index dfc41f0..a6c3795 100644 --- a/qml/ChatlistPage.qml +++ b/qml/ChatlistPage.qml @@ -13,21 +13,20 @@ Kirigami.ScrollablePage { required property DcContext context required property DcAccountsEventEmitter eventEmitter - signal messagesChanged - onMessagesChanged: { - // Reload chatlist - updateChatlist(); - } + Connections { + target: chatlistPage.eventEmitter - signal messagesNoticed - onMessagesNoticed: { - // Reload chatlist - updateChatlist(); + function onMessagesChanged() { + // Reload chatlist + updateChatlist(); + } + function onMessagesNoticed() { + // Reload chatlist + updateChatlist(); + } } Component.onCompleted: { - eventEmitter.onMessagesChanged.connect(messagesChanged) - eventEmitter.onMessagesNoticed.connect(messagesNoticed) updateChatlist() } |