got deleting working and added attempts logic again

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2024-10-08 07:46:07 -05:00 committed by backportbot[bot]
parent 2e7c662237
commit 4e4eafd2a2
3 changed files with 9 additions and 4 deletions

View file

@ -147,7 +147,6 @@ class MessageInputViewModel @Inject constructor(
dataStore.saveMessageQueue(internalId, messageQueue)
_messageQueueSizeFlow.update { messageQueue.size }
val id = internalId.substringBefore('@')
dataStore.deleteAllMessageQueuesFor(id)
_messageQueueFlow.postValue(listOf(qMsg))
return
}

View file

@ -196,7 +196,7 @@ public class AccountRemovalWorker extends Worker {
if (user.getId() != null) {
String username = user.getUsername();
try {
// appPreferences.deleteAllMessageQueuesFor(user.getUserId()); // TODO uncomment this when done
appPreferences.deleteAllMessageQueuesFor(user.getUserId());
userManager.deleteUser(user.getId());
Log.d(TAG, "deleted user: " + username);
} catch (Throwable e) {

View file

@ -527,11 +527,17 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
override fun deleteAllMessageQueuesFor(userId: String) {
runBlocking {
async {
val keyList = mutableListOf<Preferences.Key<*>>()
val preferencesMap = context.dataStore.data.first().asMap()
for (preference in preferencesMap) {
if (preference.key.name.contains("$userId@")) {
Log.d("Julius", "found: ${preference.key} :\n ${preference.value}\n")
// TODO remove it somehow
keyList.add(preference.key)
}
}
for (key in keyList) {
context.dataStore.edit {
it.remove(key)
}
}
}