diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/PollerFactory.kt b/app/src/main/java/org/thoughtcrime/securesms/dependencies/PollerFactory.kt index 27dbdec92c..996abdf47f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/PollerFactory.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/PollerFactory.kt @@ -1,17 +1,22 @@ package org.thoughtcrime.securesms.dependencies +import dagger.Lazy import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.plus import network.loki.messenger.libsession_util.util.GroupInfo +import org.session.libsession.messaging.groups.GroupManagerV2 import org.session.libsession.messaging.sending_receiving.pollers.ClosedGroupPoller import org.session.libsignal.utilities.AccountId import java.util.concurrent.ConcurrentHashMap -class PollerFactory(private val scope: CoroutineScope, - private val executor: CoroutineDispatcher, - private val configFactory: ConfigFactory) { +class PollerFactory( + private val scope: CoroutineScope, + private val executor: CoroutineDispatcher, + private val configFactory: ConfigFactory, + private val groupManagerV2: Lazy, + ) { private val pollers = ConcurrentHashMap() @@ -20,7 +25,7 @@ class PollerFactory(private val scope: CoroutineScope, if (configFactory.userGroups?.getClosedGroup(sessionId.hexString)?.invited != false) return null return pollers.getOrPut(sessionId) { - ClosedGroupPoller(scope + SupervisorJob(), executor, sessionId, configFactory) + ClosedGroupPoller(scope + SupervisorJob(), executor, sessionId, configFactory, groupManagerV2.get()) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SessionUtilModule.kt b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SessionUtilModule.kt index 7681536af3..045727968e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SessionUtilModule.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SessionUtilModule.kt @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.dependencies import android.content.Context +import dagger.Lazy import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -11,6 +12,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope +import org.session.libsession.messaging.groups.GroupManagerV2 import org.session.libsession.utilities.ConfigFactoryUpdateListener import org.session.libsession.utilities.TextSecurePreferences import org.thoughtcrime.securesms.crypto.KeyPairUtilities @@ -54,6 +56,7 @@ object SessionUtilModule { @Singleton fun providePollerFactory(@Named(POLLER_SCOPE) coroutineScope: CoroutineScope, @Named(POLLER_SCOPE) dispatcher: CoroutineDispatcher, - configFactory: ConfigFactory) = PollerFactory(coroutineScope, dispatcher, configFactory) + configFactory: ConfigFactory, + groupManagerV2: Lazy) = PollerFactory(coroutineScope, dispatcher, configFactory, groupManagerV2) } \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/EditGroupViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/EditGroupViewModel.kt index 03435e8d90..482d22f004 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/EditGroupViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/EditGroupViewModel.kt @@ -218,9 +218,12 @@ class EditGroupViewModel @AssistedInject constructor( fun onEditNameConfirmClicked() { val newName = mutableEditingName.value - if (newName != null) { - storage.setName(groupSessionId, newName.trim()) - mutableEditingName.value = null + + performGroupOperation { + if (!newName.isNullOrBlank()) { + groupManager.setName(AccountId(groupSessionId), newName) + mutableEditingName.value = null + } } }