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:
parent
5b9dedffad
commit
9a467e62a0
12 changed files with 44 additions and 23 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class MyTypesDelegate @Inject constructor(
|
|||
Relations.RESTRICTIONS
|
||||
),
|
||||
filters = ObjectSearchConstants.filterTypes(
|
||||
spaceId = space
|
||||
spaces = listOf(space)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue