Skip to content

Commit 4e66810

Browse files
committed
Wait for member left message to be sent before deleting group
1 parent d5625f9 commit 4e66810

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/src/main/java/org/thoughtcrime/securesms/groups/GroupLeavingWorker.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.work.WorkerParameters
1212
import dagger.assisted.Assisted
1313
import dagger.assisted.AssistedInject
1414
import kotlinx.coroutines.CancellationException
15+
import kotlinx.coroutines.channels.Channel
1516
import org.session.libsession.messaging.groups.GroupScope
1617
import org.session.libsession.messaging.messages.control.GroupUpdated
1718
import org.session.libsession.messaging.sending_receiving.MessageSender
@@ -73,14 +74,19 @@ class GroupLeavingWorker @AssistedInject constructor(
7374
)
7475

7576
// If we are not the only admin, send a left message for other admin to handle the member removal
77+
// We'll have to wait for this message to be sent before going ahead to delete the group
78+
val statusChannel = Channel<kotlin.Result<Unit>>()
7679
MessageSender.send(
7780
GroupUpdated(
7881
GroupUpdateMessage.newBuilder()
7982
.setMemberLeftMessage(DataMessage.GroupUpdateMemberLeftMessage.getDefaultInstance())
8083
.build()
8184
),
8285
address,
86+
statusCallback = statusChannel
8387
)
88+
89+
statusChannel.receive().getOrThrow()
8490
}
8591

8692
// If we are the only admin, leaving this group will destroy the group

0 commit comments

Comments
 (0)