From 1b9d1bb621d15cd151e027e4ec8f19b3874a6af6 Mon Sep 17 00:00:00 2001 From: Taras Smakula <tarassmakula@gmail.com> Date: Tue, 19 Sep 2023 16:17:27 +0300 Subject: [PATCH] Save spaces config to user's account data --- .../futo/circles/core/room/CoreSpacesTreeBuilder.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/futo/circles/core/room/CoreSpacesTreeBuilder.kt b/core/src/main/java/org/futo/circles/core/room/CoreSpacesTreeBuilder.kt index 1cb6b3b41..b20e24c07 100644 --- a/core/src/main/java/org/futo/circles/core/room/CoreSpacesTreeBuilder.kt +++ b/core/src/main/java/org/futo/circles/core/room/CoreSpacesTreeBuilder.kt @@ -21,7 +21,8 @@ import javax.inject.Inject class CoreSpacesTreeBuilder @Inject constructor( @ApplicationContext private val context: Context, - private val createRoomDataSource: CreateRoomDataSource + private val createRoomDataSource: CreateRoomDataSource, + private val userAccountDataDataSource: UserAccountDataDataSource ) { val loadingLiveData = MutableLiveData<LoadingData>() @@ -37,10 +38,13 @@ class CoreSpacesTreeBuilder @Inject constructor( suspend fun createCoreSpacesTree() { loadingLiveData.postValue(LoadingData(messageId = R.string.configuring_workspace)) - coreSpaces.forEach { - createRoomDataSource.createRoom(it) + val configMap = mutableMapOf<String, String>() + coreSpaces.forEach { room -> + val roomId = createRoomDataSource.createRoom(room) + room.accountDataKey?.let { configMap.put(it, roomId) } delay(CREATE_ROOM_DELAY) } + userAccountDataDataSource.saveSpacesTreeConfig(configMap) createRoomDataSource.createRoom(Gallery(), context.getString(R.string.photos)) loadingLiveData.postValue(LoadingData(isLoading = false)) } -- GitLab