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

DROID-1925 Types | Fix | Extend search api to be able to include several spaces when needed (#573)

This commit is contained in:
Evgenii Kozlov 2023-11-20 13:54:52 +01:00 committed by GitHub
parent 5b9dedffad
commit 9a467e62a0
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 44 additions and 23 deletions

View file

@ -559,7 +559,9 @@ open class EditorTestSetup {
repo.stub {
onBlocking {
searchObjects(
filters = ObjectSearchConstants.filterTypes(workspaceId),
filters = ObjectSearchConstants.filterTypes(
spaces = listOf(workspaceId)
),
keys = ObjectSearchConstants.defaultKeysObjectType,
sorts = emptyList(),
limit = 0,

View file

@ -4843,7 +4843,9 @@ class EditorViewModel(
val params = GetObjectTypes.Params(
sorts = emptyList(),
filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get(),
spaces = buildList {
add(spaceManager.get())
},
recommendedLayouts = SupportedLayouts.editorLayouts
),
keys = ObjectSearchConstants.defaultKeysObjectType
@ -5919,7 +5921,9 @@ class EditorViewModel(
val params = GetObjectTypes.Params(
sorts = emptyList(),
filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get(),
spaces = buildList {
add(spaceManager.get())
},
recommendedLayouts = SupportedLayouts.createObjectLayouts
),
keys = ObjectSearchConstants.defaultKeysObjectType

View file

@ -49,7 +49,7 @@ class LibraryTypesDelegate @Inject constructor(
subscription = SUB_LIBRARY_TYPES,
keys = ObjectSearchConstants.defaultKeys,
filters = ObjectSearchConstants.filterTypes(
spaceId = MARKETPLACE_SPACE_ID
spaces = listOf(MARKETPLACE_SPACE_ID)
)
)
}

View file

@ -63,7 +63,7 @@ class MyTypesDelegate @Inject constructor(
Relations.RESTRICTIONS
),
filters = ObjectSearchConstants.filterTypes(
spaceId = space
spaces = listOf(space)
)
)
}

View file

@ -126,7 +126,7 @@ class MoveToViewModel(
val params = GetObjectTypes.Params(
sorts = emptyList(),
filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get(),
spaces = listOf(spaceManager.get()),
recommendedLayouts = SupportedLayouts.editorLayouts
),
keys = ObjectSearchConstants.defaultKeysObjectType

View file

@ -37,7 +37,7 @@ class CreateObjectOfTypeViewModel(
GetObjectTypes.Params(
sorts = emptyList(),
filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get(),
spaces = listOf(spaceManager.get()),
recommendedLayouts = SupportedLayouts.createObjectLayouts
),
keys = ObjectSearchConstants.defaultKeysObjectType,

View file

@ -236,7 +236,7 @@ class ObjectTypeChangeViewModel(
filters = buildList {
addAll(
ObjectSearchConstants.filterTypes(
spaceId = Marketplace.MARKETPLACE_SPACE_ID,
spaces = listOf(Marketplace.MARKETPLACE_SPACE_ID),
recommendedLayouts = SupportedLayouts.editorLayouts
)
)
@ -263,7 +263,7 @@ class ObjectTypeChangeViewModel(
) = getObjectTypes.run(
GetObjectTypes.Params(
filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get(),
spaces = listOf(spaceManager.get()),
recommendedLayouts = SupportedLayouts.editorLayouts
),
sorts = ObjectSearchConstants.defaultObjectSearchSorts(),

View file

@ -641,7 +641,7 @@ object ObjectSearchConstants {
//region OBJECT TYPES
fun filterTypes(
spaceId: Id,
spaces: List<Id>,
recommendedLayouts: List<ObjectType.Layout> = emptyList()
): List<DVFilter> {
return buildList {
@ -669,8 +669,8 @@ object ObjectSearchConstants {
),
DVFilter(
relation = Relations.SPACE_ID,
condition = DVFilterCondition.EQUAL,
value = spaceId
condition = DVFilterCondition.IN,
value = spaces
)
)
)

View file

@ -118,7 +118,7 @@ open class ObjectSearchViewModel(
val params = GetObjectTypes.Params(
sorts = emptyList(),
filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get()
spaces = listOf(spaceManager.get())
),
keys = ObjectSearchConstants.defaultKeysObjectType
)

View file

@ -1805,7 +1805,7 @@ class ObjectSetViewModel(
private suspend fun fetchAndProcessObjectTypes(selectedType: Id, widgetState: TypeTemplatesWidgetUI.Data) {
val filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get(),
spaces = listOf(spaceManager.get()),
recommendedLayouts = SupportedLayouts.createObjectLayouts
)
val params = GetObjectTypes.Params(

View file

@ -166,7 +166,7 @@ class CollectionViewModel(
val params = GetObjectTypes.Params(
sorts = emptyList(),
filters = ObjectSearchConstants.filterTypes(
spaceId = spaceManager.get()
spaces = listOf(spaceManager.get())
),
keys = ObjectSearchConstants.defaultKeysObjectType
)

View file

@ -111,7 +111,10 @@ class ObjectTypeChangeViewModelTest {
stubSpaceManager(spaceId)
val vm = givenViewModel()
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(spaceId, SupportedLayouts.editorLayouts)
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(
spaces = listOf(spaceId),
recommendedLayouts = SupportedLayouts.editorLayouts
)
// TESTING
@ -150,14 +153,17 @@ class ObjectTypeChangeViewModelTest {
stubSpaceManager(spaceId)
val vm = givenViewModel()
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(spaceId, SupportedLayouts.editorLayouts)
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(
spaces = listOf(spaceId),
recommendedLayouts = SupportedLayouts.editorLayouts
)
val expectedMyTypeKeys = ObjectSearchConstants.defaultKeysObjectType
val expectedMarketplaceTypeKeys = ObjectSearchConstants.defaultKeysObjectType
val expectedMarketplaceTypeFilters = buildList {
addAll(
ObjectSearchConstants.filterTypes(
spaceId = MARKETPLACE_SPACE_ID,
spaces = listOf(MARKETPLACE_SPACE_ID),
recommendedLayouts = SupportedLayouts.editorLayouts
)
)
@ -241,14 +247,17 @@ class ObjectTypeChangeViewModelTest {
stubSpaceManager(spaceId)
val vm = givenViewModel()
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(spaceId, SupportedLayouts.editorLayouts)
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(
spaces = listOf(spaceId),
recommendedLayouts = SupportedLayouts.editorLayouts
)
val expectedMyTypeKeys = ObjectSearchConstants.defaultKeysObjectType
val expectedMarketplaceTypeKeys = ObjectSearchConstants.defaultKeysObjectType
val expectedMarketplaceTypeFilters = buildList {
addAll(
ObjectSearchConstants.filterTypes(
spaceId = MARKETPLACE_SPACE_ID,
spaces = listOf(MARKETPLACE_SPACE_ID),
recommendedLayouts = SupportedLayouts.editorLayouts
)
)
@ -410,14 +419,17 @@ class ObjectTypeChangeViewModelTest {
val expectedInstalledTypeId = MockDataFactory.randomUuid()
val expectedInstalledTypeUniqueKey = ObjectTypeIds.PAGE
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(space, SupportedLayouts.editorLayouts)
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(
spaces = listOf(space),
recommendedLayouts = SupportedLayouts.editorLayouts
)
val expectedMyTypeKeys = ObjectSearchConstants.defaultKeysObjectType
val expectedMarketplaceTypeKeys = ObjectSearchConstants.defaultKeysObjectType
val expectedMarketplaceTypeFilters = buildList {
addAll(
ObjectSearchConstants.filterTypes(
spaceId = MARKETPLACE_SPACE_ID,
spaces = listOf(MARKETPLACE_SPACE_ID),
recommendedLayouts = SupportedLayouts.editorLayouts
)
)
@ -556,7 +568,10 @@ class ObjectTypeChangeViewModelTest {
stubSpaceManager(spaceId)
val vm = givenViewModel()
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(spaceId, SupportedLayouts.editorLayouts)
val expectedMyTypesFilters = ObjectSearchConstants.filterTypes(
spaces = listOf(spaceId),
recommendedLayouts = SupportedLayouts.editorLayouts
)
val expectedMyTypeKeys = ObjectSearchConstants.defaultKeysObjectType
blockRepository.stub {