From 6abe6c682cbf84cb4162a34e690070d1d572bc73 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:17:52 +1100 Subject: [PATCH] clearAll + same name checking before updating --- .../securesms/dependencies/ConfigFactory.kt | 8 +++++++- .../securesms/groups/GroupManagerV2Impl.kt | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt b/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt index 5bca2ca524..f3bb2bfa2a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt @@ -441,7 +441,13 @@ class ConfigFactory @Inject constructor( } fun clearAll() { - //TODO: clear all configs + synchronized(userConfigs) { + userConfigs.clear() + } + + synchronized(groupConfigs) { + groupConfigs.clear() + } } private class GroupSubAccountSwarmAuth( diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManagerV2Impl.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManagerV2Impl.kt index 909d43ff27..6095d7b496 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManagerV2Impl.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManagerV2Impl.kt @@ -826,8 +826,17 @@ class GroupManagerV2Impl @Inject constructor( withContext(dispatcher) { val adminKey = requireAdminAccess(groupId) - configFactory.withMutableGroupConfigs(groupId) { - it.groupInfo.setName(newName) + val nameChanged = configFactory.withMutableGroupConfigs(groupId) { configs -> + if (configs.groupInfo.getName() != newName) { + configs.groupInfo.setName(newName) + true + } else { + false + } + } + + if (!nameChanged) { + return@withContext } val timestamp = clock.currentTimeMills()