@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.groups.handler
3
3
import android.content.Context
4
4
import com.google.protobuf.ByteString
5
5
import dagger.hilt.android.qualifiers.ApplicationContext
6
+ import kotlinx.coroutines.DelicateCoroutinesApi
6
7
import kotlinx.coroutines.ExperimentalCoroutinesApi
7
8
import kotlinx.coroutines.GlobalScope
8
9
import kotlinx.coroutines.Job
@@ -49,6 +50,7 @@ private const val TAG = "RemoveGroupMemberHandler"
49
50
*
50
51
* It automatically does so by listening to the config updates changes and checking for any pending removals.
51
52
*/
53
+ @OptIn(DelicateCoroutinesApi ::class , ExperimentalCoroutinesApi ::class )
52
54
@Singleton
53
55
class RemoveGroupMemberHandler @Inject constructor(
54
56
@ApplicationContext private val context : Context ,
@@ -59,13 +61,8 @@ class RemoveGroupMemberHandler @Inject constructor(
59
61
private val storage : StorageProtocol ,
60
62
private val groupScope : GroupScope ,
61
63
) {
62
- private var job: Job ? = null
63
-
64
- @OptIn(ExperimentalCoroutinesApi ::class )
65
- fun start () {
66
- require(job == null ) { " Already started" }
67
-
68
- job = GlobalScope .launch {
64
+ init {
65
+ GlobalScope .launch {
69
66
textSecurePreferences
70
67
.watchLocalNumber()
71
68
.flatMapLatest { localNumber ->
@@ -80,14 +77,17 @@ class RemoveGroupMemberHandler @Inject constructor(
80
77
val adminKey = configFactory.getGroup(update.groupId)?.adminKey
81
78
if (adminKey != null ) {
82
79
groupScope.launch(update.groupId, " Handle possible group removals" ) {
83
- processPendingRemovalsForGroup(update.groupId, adminKey)
80
+ try {
81
+ processPendingRemovalsForGroup(update.groupId, adminKey)
82
+ } catch (ec: Exception ) {
83
+ Log .e(" RemoveGroupMemberHandler" , " Error processing pending removals" , ec)
84
+ }
84
85
}
85
86
}
86
87
}
87
88
}
88
89
}
89
90
90
-
91
91
private suspend fun processPendingRemovalsForGroup (
92
92
groupAccountId : AccountId ,
93
93
adminKey : ByteArray
0 commit comments