1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2853 All content | Enhancement | Menu, cache, empty states (#1613)

This commit is contained in:
Konstantin Ivanov 2024-10-01 21:02:58 +02:00 committed by GitHub
parent 97fa5232b9
commit 8878d0760b
Signed by: github
GPG key ID: B5690EEEBB952194
18 changed files with 287 additions and 110 deletions

View file

@ -15,6 +15,7 @@ import com.anytypeio.anytype.core_models.primitives.SpaceId
import com.anytypeio.anytype.core_models.primitives.TypeId
import com.anytypeio.anytype.core_models.settings.VaultSettings
import com.anytypeio.anytype.data.auth.repo.UserSettingsCache
import com.anytypeio.anytype.persistence.AllContentSettings
import com.anytypeio.anytype.persistence.GlobalSearchHistoryProto
import com.anytypeio.anytype.persistence.SpacePreference
import com.anytypeio.anytype.persistence.SpacePreferences
@ -434,6 +435,40 @@ class DefaultUserSettingsCache(
}
}
override suspend fun getAllContentSort(space: SpaceId): Id {
return context.spacePrefsStore
.data
.map { preferences ->
preferences
.preferences[space.id]
?.allContent
?.sortKey
.orEmpty()
}
.first()
}
override suspend fun setAllContentSort(space: SpaceId, sort: Id) {
context.spacePrefsStore.updateData { existingPreferences ->
val givenSpacePreference = existingPreferences
.preferences
.getOrDefault(
key = space.id,
defaultValue = SpacePreference()
)
val updated = givenSpacePreference.copy(
allContent = AllContentSettings(
sortKey = sort
)
)
val result = buildMap {
putAll(existingPreferences.preferences)
put(key = space.id, updated)
}
SpacePreferences(preferences = result)
}
}
companion object {
const val CURRENT_SPACE_KEY = "prefs.user_settings.current_space"
const val DEFAULT_OBJECT_TYPE_ID_KEY = "prefs.user_settings.default_object_type.id"

View file

@ -22,9 +22,14 @@ message SpacePreference {
repeated string pinnedObjectTypeIds = 2;
optional string lastOpenedObject = 3;
optional GlobalSearchHistoryProto globalSearchHistory = 5;
optional AllContentSettings allContent = 6;
}
message GlobalSearchHistoryProto {
optional string lastSearchQuery = 1;
optional string lastSearchRelatedObjectId = 2;
}
message AllContentSettings {
optional string sortKey = 1;
}