diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationViewModel.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationViewModel.kt index 3c283009084a81ea524edbc534fb2d75b9e0e299..17e197550661a26cd39f1b8e487b2209496cd1f8 100644 --- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationViewModel.kt +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationViewModel.kt @@ -1,6 +1,6 @@ /* * Briar Desktop - * Copyright (C) 2021-2022 The Briar Project + * Copyright (C) 2021-2023 The Briar Project * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -64,6 +64,7 @@ import org.briarproject.briar.desktop.contact.ContactItem import org.briarproject.briar.desktop.contact.loadContactItem import org.briarproject.briar.desktop.conversation.ConversationRequestItem.RequestType.FORUM import org.briarproject.briar.desktop.conversation.ConversationRequestItem.RequestType.INTRODUCTION +import org.briarproject.briar.desktop.forums.sharing.ForumInvitationSentEvent import org.briarproject.briar.desktop.threading.BriarExecutors import org.briarproject.briar.desktop.utils.KLoggerUtils.e import org.briarproject.briar.desktop.utils.KLoggerUtils.i @@ -375,6 +376,9 @@ constructor( } } + is ForumInvitationSentEvent -> + if (_contactId.value in e.contactIds) reloadMessages() + is ContactConnectedEvent -> { if (e.contactId == _contactId.value) { LOG.i { "Contact connected" } diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/forums/sharing/ForumInvitationSentEvent.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/forums/sharing/ForumInvitationSentEvent.kt new file mode 100644 index 0000000000000000000000000000000000000000..016dfd976ffec2ba09c6001b81de71b59cdc9a17 --- /dev/null +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/forums/sharing/ForumInvitationSentEvent.kt @@ -0,0 +1,30 @@ +/* + * Briar Desktop + * Copyright (C) 2021-2023 The Briar Project + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package org.briarproject.briar.desktop.forums.sharing + +import org.briarproject.bramble.api.contact.ContactId +import org.briarproject.bramble.api.event.Event + +/** + * An event that is broadcast when a forum invitation + * is sent to a contact. + */ +data class ForumInvitationSentEvent( + val contactIds: List<ContactId>, +) : Event() diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/forums/sharing/ForumSharingViewModel.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/forums/sharing/ForumSharingViewModel.kt index c7602af618914100bc11603d64aefe684244b362..03dc7a57be0a89d6deb86f9cd7b4607519979ab3 100644 --- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/forums/sharing/ForumSharingViewModel.kt +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/forums/sharing/ForumSharingViewModel.kt @@ -1,6 +1,6 @@ /* * Briar Desktop - * Copyright (C) 2021-2022 The Briar Project + * Copyright (C) 2021-2023 The Briar Project * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -149,6 +149,9 @@ class ForumSharingViewModel @Inject constructor( _shareableSelected.value.forEach { contactId -> forumSharingManager.sendInvitation(txn, groupId, contactId, message) } + // send custom event to force message reload if private chat is open for contactId + // todo: switch to a more generic approach where every locally sent message broadcasts an event per default + txn.attach(ForumInvitationSentEvent(_shareableSelected.value.toList())) txn.attach { reload() } }