diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt index 0b33b6ff7d..afb5d99364 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt @@ -12,6 +12,7 @@ data class Config( val profile: Id, val gateway: Url, val space: Id, + val techSpace: Id, val spaceView: Id, val widgets: Id, val analytics: Id, diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt index 1d69424624..d5240b846f 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt @@ -18,6 +18,7 @@ object ObjectTypeIds { const val TASK = "ot-task" const val DATE = "ot-date" const val PROFILE = "ot-profile" //contains User Profile page and Anytype Person page + const val HUMAN = "ot-human" const val NOTE = "ot-note" const val WORKSPACE = "ot-space" const val DASHBOARD = "ot-dashboard" @@ -60,6 +61,7 @@ object MarketplaceObjectTypeIds { const val TASK = "_ottask" const val DATE = "_otdate" const val PROFILE = "_otprofile" + const val HUMAN = "_othuman" const val NOTE = "_otnote" const val DASHBOARD = "_otdashboard" const val BOOKMARK = "_otbookmark" diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt index c6a84b160b..f8c9c63479 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt @@ -74,6 +74,8 @@ object Relations { const val SPACE_ACCOUNT_STATUS = "spaceAccountStatus" const val SPACE_LOCAL_STATUS = "spaceLocalStatus" + const val IDENTITY_PROFILE_LINK = "identityProfileLink" + val systemRelationKeys = listOf( "id", "name", diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt index 409d25534b..e19bf2cfc5 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt @@ -53,7 +53,8 @@ fun Rpc.Account.Select.Response.toAccountSetup(): AccountSetup { widgets = info.widgetsId, analytics = info.analyticsId, device = info.deviceId, - network = info.networkId + network = info.networkId, + techSpace = info.techSpaceId ), status = status?.core() ?: AccountStatus.Unknown ) diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/ToCoreModelMappers.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/ToCoreModelMappers.kt index b75384b60b..1ad4e0840e 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/ToCoreModelMappers.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/ToCoreModelMappers.kt @@ -769,6 +769,7 @@ fun Account.Info.config() : Config = Config( profile = profileObjectId, gateway = gatewayUrl, space = accountSpaceId, + techSpace = techSpaceId, spaceView = spaceViewId, widgets = widgetsId, analytics = analyticsId, diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/ObjectWrapperMapper.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/ObjectWrapperMapper.kt index 00f19d46e8..6ef775ad7c 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/ObjectWrapperMapper.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/ObjectWrapperMapper.kt @@ -2,7 +2,9 @@ package com.anytypeio.anytype.presentation.objects import com.anytypeio.anytype.core_models.Id import com.anytypeio.anytype.core_models.Marketplace +import com.anytypeio.anytype.core_models.MarketplaceObjectTypeIds import com.anytypeio.anytype.core_models.ObjectType +import com.anytypeio.anytype.core_models.ObjectTypeUniqueKeys import com.anytypeio.anytype.core_models.ObjectWrapper import com.anytypeio.anytype.core_models.Relations import com.anytypeio.anytype.core_models.Relations.SOURCE_OBJECT @@ -18,6 +20,7 @@ import com.anytypeio.anytype.presentation.relations.RelationValueView import com.anytypeio.anytype.presentation.sets.filter.CreateFilterView import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider import com.anytypeio.anytype.presentation.widgets.collection.CollectionView +import timber.log.Timber @Deprecated("To be deleted") fun List.toView( @@ -53,13 +56,20 @@ fun List.toViews( gradientProvider: SpaceGradientProvider = SpaceGradientProvider.Default ): List = map { obj -> val typeUrl = obj.getProperType() + val isProfile = typeUrl == MarketplaceObjectTypeIds.PROFILE val layout = obj.getProperLayout() DefaultObjectView( id = obj.id, name = obj.getProperName(), description = obj.description, type = typeUrl, - typeName = objectTypes.firstOrNull { it.id == typeUrl }?.name, + typeName = objectTypes.firstOrNull { type -> + if (isProfile) { + type.uniqueKey == ObjectTypeUniqueKeys.PROFILE + } else { + type.id == typeUrl + } + }?.name, layout = layout, icon = ObjectIcon.from( obj = obj, diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchConstants.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchConstants.kt index 146fa48575..914f03d432 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchConstants.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchConstants.kt @@ -21,7 +21,7 @@ import com.anytypeio.anytype.presentation.objects.SupportedLayouts object ObjectSearchConstants { //region SEARCH OBJECTS - fun filterSearchObjects(space: Id) = listOf( + fun filterSearchObjects(spaces: List) = listOf( DVFilter( relation = Relations.IS_ARCHIVED, condition = DVFilterCondition.NOT_EQUAL, @@ -57,8 +57,8 @@ object ObjectSearchConstants { ), DVFilter( relation = Relations.SPACE_ID, - condition = DVFilterCondition.EQUAL, - value = space + condition = DVFilterCondition.IN, + value = spaces ) ) diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchViewModel.kt index 9f4828fdfd..6816a23e95 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/search/ObjectSearchViewModel.kt @@ -6,6 +6,7 @@ import com.anytypeio.anytype.analytics.base.Analytics import com.anytypeio.anytype.core_models.Id import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.ObjectWrapper +import com.anytypeio.anytype.core_models.Relations import com.anytypeio.anytype.core_utils.common.EventWrapper import com.anytypeio.anytype.core_utils.ext.cancel import com.anytypeio.anytype.core_utils.ui.TextInputDialogBottomBehaviorApplier @@ -155,7 +156,6 @@ open class ObjectSearchViewModel( val target = view.id sendSearchResultEvent(target) when (view.layout) { - ObjectType.Layout.PROFILE, ObjectType.Layout.BASIC, ObjectType.Layout.TODO, ObjectType.Layout.NOTE, @@ -164,6 +164,18 @@ open class ObjectSearchViewModel( ObjectType.Layout.BOOKMARK -> { navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = target))) } + ObjectType.Layout.PROFILE -> { + val obj = objects + .value + .getOrNull() + ?.find { obj -> obj.id == view.id } + val identity = obj?.getValue(Relations.IDENTITY_PROFILE_LINK) + if (identity != null) { + navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = identity))) + } else { + navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = target))) + } + } ObjectType.Layout.SET, ObjectType.Layout.COLLECTION -> { navigate(EventWrapper(AppNavigation.Command.LaunchObjectSet(target = target))) } @@ -190,11 +202,22 @@ open class ObjectSearchViewModel( open suspend fun getSearchObjectsParams(ignore: Id?) = SearchObjects.Params( limit = SEARCH_LIMIT, filters = ObjectSearchConstants.filterSearchObjects( - space = spaceManager.get() + spaces = buildList { + val config = spaceManager.getConfig() + if (config != null) { + add(config.space) + add(config.techSpace) + } else { + add(spaceManager.get()) + } + } ), sorts = ObjectSearchConstants.sortsSearchObjects, fulltext = EMPTY_QUERY, - keys = ObjectSearchConstants.defaultKeys + keys = buildList { + addAll(ObjectSearchConstants.defaultKeys) + add("identityProfileLink") + } ) override fun onDialogCancelled() { diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt index 945151417d..8c068584da 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt @@ -11,6 +11,7 @@ import com.anytypeio.anytype.core_models.ObjectWrapper import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.core_models.SearchResult +import com.anytypeio.anytype.core_models.StubConfig import com.anytypeio.anytype.core_models.primitives.TypeId import com.anytypeio.anytype.core_models.primitives.TypeKey import com.anytypeio.anytype.core_models.restrictions.DataViewRestrictions @@ -206,17 +207,7 @@ open class ObjectSetViewModelTestSetup { computation = rule.dispatcher, main = rule.dispatcher ) - spaceConfig = Config( - home = "morbi", - profile = "indoctum", - gateway = "luctus", - space = "nonumy", - spaceView = "etiam", - widgets = "eloquentiam", - analytics = "quem", - device = "elaboraret", - network = "network" - ) + spaceConfig = StubConfig() spaceManager = SpaceManager.Impl( repo = repo, dispatchers = dispatchers, @@ -320,19 +311,9 @@ open class ObjectSetViewModelTestSetup { suspend fun stubSpaceManager(space: Id) { repo.stub { - onBlocking { getSpaceConfig(space) } doReturn Config( - home = "morbi", - profile = "indoctum", - gateway = "luctus", - space = space, - spaceView = "etiam", - widgets = "eloquentiam", - analytics = "quem", - device = "elaboraret", - network = "network" - ) + onBlocking { getSpaceConfig(space) } doReturn spaceConfig + spaceManager.set(space) } - spaceManager.set(space) } suspend fun stubSubscriptionResults( @@ -340,7 +321,7 @@ open class ObjectSetViewModelTestSetup { spaceId: Id, collection: Id? = null, objects: List = emptyList(), - dependencies: List = listOf(), + dependencies: List = listOf(), dvFilters: List = emptyList(), dvSorts: List = emptyList(), storeOfRelations: StoreOfRelations, @@ -378,7 +359,7 @@ open class ObjectSetViewModelTestSetup { } } - protected suspend fun stubStoreOfRelations(mockObjectCollection: MockCollection) { + suspend fun stubStoreOfRelations(mockObjectCollection: MockCollection) { storeOfRelations.merge( listOf( mockObjectCollection.relationObject1, @@ -391,7 +372,7 @@ open class ObjectSetViewModelTestSetup { ) } - protected suspend fun stubStoreOfRelations(mockObjectSet: MockSet) { + suspend fun stubStoreOfRelations(mockObjectSet: MockSet) { storeOfRelations.merge( listOf( mockObjectSet.relationObject1, @@ -412,7 +393,7 @@ open class ObjectSetViewModelTestSetup { name: String = defaultObjectPageTypeName, id: TypeId = TypeId(MockDataFactory.randomString()), template: Id? = null - ) { + ) { getDefaultObjectType.stub { onBlocking { run(Unit) } doReturn GetDefaultObjectType.Response( type = type, diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/types/ObjectTypeChangeViewModelTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/types/ObjectTypeChangeViewModelTest.kt index 5c8e804f3f..17496e60c8 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/types/ObjectTypeChangeViewModelTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/types/ObjectTypeChangeViewModelTest.kt @@ -152,10 +152,10 @@ class ObjectTypeChangeViewModelTest { // SETUP - val marketplaceType1 = StubObjectType() - val marketplaceType2 = StubObjectType() - val installedType1 = StubObjectType(sourceObject = marketplaceType1.id) - val installedType2 = StubObjectType(sourceObject = marketplaceType2.id) + val marketplaceType1 = StubObjectType(uniqueKey = MockDataFactory.randomUuid()) + val marketplaceType2 = StubObjectType(uniqueKey = MockDataFactory.randomUuid()) + val installedType1 = StubObjectType(uniqueKey = marketplaceType1.uniqueKey) + val installedType2 = StubObjectType(uniqueKey = marketplaceType2.uniqueKey) stubSpaceManager(spaceId) val vm = givenViewModel() @@ -179,11 +179,11 @@ class ObjectTypeChangeViewModelTest { addAll(ObjectSearchConstants.filterObjectTypeMarketplace) add( DVFilter( - relation = Relations.ID, + relation = Relations.UNIQUE_KEY, condition = DVFilterCondition.NOT_IN, value = listOf( - marketplaceType1.id, - marketplaceType2.id, + marketplaceType1.uniqueKey, + marketplaceType2.uniqueKey, MarketplaceObjectTypeIds.BOOKMARK ) ) @@ -258,10 +258,10 @@ class ObjectTypeChangeViewModelTest { // SETUP - val marketplaceType1 = StubObjectType() - val marketplaceType2 = StubObjectType() - val installedType1 = StubObjectType(sourceObject = marketplaceType1.id) - val installedType2 = StubObjectType(sourceObject = marketplaceType2.id) + val marketplaceType1 = StubObjectType(uniqueKey = MockDataFactory.randomUuid()) + val marketplaceType2 = StubObjectType(uniqueKey = MockDataFactory.randomUuid()) + val installedType1 = StubObjectType(uniqueKey = marketplaceType1.uniqueKey) + val installedType2 = StubObjectType(uniqueKey = marketplaceType2.uniqueKey) stubSpaceManager(spaceId) val vm = givenViewModel() @@ -285,11 +285,11 @@ class ObjectTypeChangeViewModelTest { addAll(ObjectSearchConstants.filterObjectTypeMarketplace) add( DVFilter( - relation = Relations.ID, + relation = Relations.UNIQUE_KEY, condition = DVFilterCondition.NOT_IN, value = listOf( - marketplaceType1.id, - marketplaceType2.id, + marketplaceType1.uniqueKey, + marketplaceType2.uniqueKey, MarketplaceObjectTypeIds.BOOKMARK ) ) diff --git a/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt b/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt index 93442d6a72..96f09afcac 100644 --- a/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt +++ b/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt @@ -30,18 +30,20 @@ fun StubConfig( home: Id = MockDataFactory.randomUuid(), profile: Id = MockDataFactory.randomUuid(), gateway: Url = MockDataFactory.randomUuid(), - workspace: Id = MockDataFactory.randomUuid(), + spaceView: Id = MockDataFactory.randomUuid(), widgets: Id = MockDataFactory.randomUuid(), analytics: Id = MockDataFactory.randomUuid(), device: Id = MockDataFactory.randomUuid(), space: Id = MockDataFactory.randomUuid(), + techSpace: Id = MockDataFactory.randomUuid(), network: Id = MockDataFactory.randomUuid() ) : Config = Config( home = home, profile = profile, gateway = gateway, - spaceView = workspace, + spaceView = spaceView, space = space, + techSpace = techSpace, widgets = widgets, analytics = analytics, device = device,