Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
import com.anytypeio.anytype.domain.block.repo.BlockRepository
import com.anytypeio.anytype.domain.misc.DateProvider
import com.anytypeio.anytype.domain.misc.UrlBuilder
import com.anytypeio.anytype.domain.multiplayer.SpaceViewSubscriptionContainer
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
import com.anytypeio.anytype.domain.primitives.FieldParser
import com.anytypeio.anytype.domain.search.SearchObjects
Expand Down Expand Up @@ -79,4 +80,5 @@ interface BacklinkOrAddToObjectDependencies : ComponentDependencies {
fun dateProvider(): DateProvider
fun fieldParser(): FieldParser
fun storeOfObjectTypes(): StoreOfObjectTypes
}
fun spaceViews(): SpaceViewSubscriptionContainer
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
import com.anytypeio.anytype.domain.block.repo.BlockRepository
import com.anytypeio.anytype.domain.config.UserSettingsRepository
import com.anytypeio.anytype.domain.misc.UrlBuilder
import com.anytypeio.anytype.domain.multiplayer.SpaceViewSubscriptionContainer
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
import com.anytypeio.anytype.domain.objects.StoreOfRelations
import com.anytypeio.anytype.domain.primitives.FieldParser
Expand Down Expand Up @@ -60,4 +61,5 @@ interface GlobalSearchDependencies : ComponentDependencies {
fun analyticsHelper(): AnalyticSpaceHelperDelegate
fun userSettingsRepository(): UserSettingsRepository
fun fieldParser(): FieldParser
}
fun spaceViews(): SpaceViewSubscriptionContainer
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ object SupportedLayouts {
*/
fun getSystemLayouts(spaceUxType: SpaceUxType?): List<ObjectType.Layout> {
return when (spaceUxType) {
SpaceUxType.CHAT -> baseSystemLayouts + listOf(ObjectType.Layout.CHAT_DERIVED)
SpaceUxType.CHAT -> baseSystemLayouts + listOf(ObjectType.Layout.CHAT_DERIVED, ObjectType.Layout.CHAT)
else -> baseSystemLayouts
}
}
Expand Down Expand Up @@ -170,4 +170,21 @@ object SupportedLayouts {
else -> baseLayouts + listOf(ObjectType.Layout.CHAT_DERIVED)
}
}

/**
* Get layouts for object search (global search, link to, etc.).
*
* Combines base layouts, file layouts, date layouts, and object type layout,
* filtered by space UX type.
*
* @param spaceUxType The UX type of the current space
* @return List of layouts for object search operations
*/
fun getObjectSearchLayouts(spaceUxType: SpaceUxType? = null): List<ObjectType.Layout> {
return getLayouts(spaceUxType)
.plus(fileLayouts)
.plus(dateLayouts)
.plus(listOf(ObjectType.Layout.OBJECT_TYPE))
.distinct()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6526,11 +6526,13 @@ class EditorViewModel(
return
}
val fullText = filter.removePrefix(MENTION_PREFIX)
val spaceUxType = spaceViews.get(vmParams.space)?.spaceUxType
val params = SearchObjects.Params(
space = vmParams.space,
limit = ObjectSearchViewModel.SEARCH_LIMIT,
filters = ObjectSearchConstants.getFilterLinkTo(
ignore = context
ignore = context,
spaceUxType = spaceUxType
),
sorts = ObjectSearchConstants.sortLinkTo,
fulltext = fullText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.anytypeio.anytype.domain.base.Resultat
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
import com.anytypeio.anytype.domain.misc.DateProvider
import com.anytypeio.anytype.domain.misc.UrlBuilder
import com.anytypeio.anytype.domain.multiplayer.SpaceViewSubscriptionContainer
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
import com.anytypeio.anytype.domain.primitives.FieldParser
import com.anytypeio.anytype.domain.search.SearchObjects
Expand All @@ -30,6 +31,7 @@ class BackLinkOrAddToObjectViewModel(
analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
fieldParser: FieldParser,
storeOfObjectTypes: StoreOfObjectTypes,
spaceViews: SpaceViewSubscriptionContainer
) : ObjectSearchViewModel(
vmParams = vmParams,
urlBuilder = urlBuilder,
Expand All @@ -38,7 +40,8 @@ class BackLinkOrAddToObjectViewModel(
analytics = analytics,
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
fieldParser = fieldParser,
storeOfObjectTypes = storeOfObjectTypes
storeOfObjectTypes = storeOfObjectTypes,
spaceViews = spaceViews
) {

private val _commands = MutableSharedFlow<Command>(replay = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,15 @@ class LinkToObjectOrWebViewModel(
fun getSearchObjectsParams(ignore: Id) = SearchObjects.Params(
space = vmParams.space,
limit = ObjectSearchViewModel.SEARCH_LIMIT,
filters = ObjectSearchConstants.getFilterLinkTo(
ignore = ignore
),
filters = buildList {
val spaceUxType = spaceViews.get(vmParams.space)?.spaceUxType
addAll(
ObjectSearchConstants.getFilterLinkTo(
ignore = ignore,
spaceUxType = spaceUxType
)
)
},
sorts = ObjectSearchConstants.sortLinkTo,
fulltext = ObjectSearchViewModel.EMPTY_QUERY,
keys = ObjectSearchConstants.defaultKeys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class LinkToObjectViewModel(
analytics = analytics,
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
fieldParser = fieldParser,
storeOfObjectTypes = storeOfObjectTypes
storeOfObjectTypes = storeOfObjectTypes,
spaceViews = spaceViews
) {

val commands = MutableSharedFlow<Command>(replay = 0)
Expand All @@ -51,9 +52,15 @@ class LinkToObjectViewModel(
override suspend fun getSearchObjectsParams(ignore: Id?) = SearchObjects.Params(
space = vmParams.space,
limit = SEARCH_LIMIT,
filters = ObjectSearchConstants.getFilterLinkTo(
ignore = ignore
),
filters = buildList {
val spaceUxType = spaceViews.get(vmParams.space)?.spaceUxType
addAll(
ObjectSearchConstants.getFilterLinkTo(
ignore = ignore,
spaceUxType = spaceUxType
)
)
},
sorts = ObjectSearchConstants.sortLinkTo,
fulltext = EMPTY_QUERY,
keys = ObjectSearchConstants.defaultKeys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class BackLinkOrAddToObjectViewModelFactory @Inject constructor(
private val analytics: Analytics,
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
private val fieldParser: FieldParser,
private val storeOfObjectTypes: StoreOfObjectTypes
private val storeOfObjectTypes: StoreOfObjectTypes,
private val spaceViews: SpaceViewSubscriptionContainer
) : ViewModelProvider.Factory {

@Suppress("UNCHECKED_CAST")
Expand All @@ -94,7 +95,8 @@ class BackLinkOrAddToObjectViewModelFactory @Inject constructor(
analytics = analytics,
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
fieldParser = fieldParser,
storeOfObjectTypes = storeOfObjectTypes
storeOfObjectTypes = storeOfObjectTypes,
spaceViews = spaceViews
) as T
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.anytypeio.anytype.core_models.primitives.SpaceId
import com.anytypeio.anytype.domain.base.Resultat
import com.anytypeio.anytype.domain.base.fold
import com.anytypeio.anytype.domain.misc.UrlBuilder
import com.anytypeio.anytype.domain.multiplayer.SpaceViewSubscriptionContainer
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
import com.anytypeio.anytype.domain.objects.StoreOfRelations
import com.anytypeio.anytype.domain.objects.getTypeOfObject
Expand Down Expand Up @@ -77,7 +78,8 @@ class GlobalSearchViewModel @Inject constructor(
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
private val restoreGlobalSearchHistory: RestoreGlobalSearchHistory,
private val updateGlobalSearchHistory: UpdateGlobalSearchHistory,
private val fieldParser: FieldParser
private val fieldParser: FieldParser,
private val spaceViews: SpaceViewSubscriptionContainer
) : BaseViewModel(), AnalyticSpaceHelperDelegate by analyticSpaceHelperDelegate {

private val userInput = MutableStateFlow("")
Expand Down Expand Up @@ -278,7 +280,8 @@ class GlobalSearchViewModel @Inject constructor(
offset = 0,
keys = DEFAULT_KEYS,
filters = buildList {
addAll(filterSearchObjects())
val spaceUxType = spaceViews.get(vmParams.space)?.spaceUxType
addAll(filterSearchObjects(spaceUxType = spaceUxType))
add(
DVFilter(
relation = Relations.ID,
Expand Down Expand Up @@ -307,7 +310,10 @@ class GlobalSearchViewModel @Inject constructor(
limit = DEFAULT_SEARCH_LIMIT,
offset = 0,
keys = DEFAULT_KEYS,
filters = ObjectSearchConstants.filterSearchObjects(),
filters = buildList {
val spaceUxType = spaceViews.get(vmParams.space)?.spaceUxType
addAll(ObjectSearchConstants.filterSearchObjects(spaceUxType = spaceUxType))
},
sorts = ObjectSearchConstants.sortsSearchObjects,
withMetaRelationDetails = true,
withMeta = true,
Expand Down Expand Up @@ -420,7 +426,8 @@ class GlobalSearchViewModel @Inject constructor(
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
private val restoreGlobalSearchHistory: RestoreGlobalSearchHistory,
private val updateGlobalSearchHistory: UpdateGlobalSearchHistory,
private val fieldParser: FieldParser
private val fieldParser: FieldParser,
private val spaceViews: SpaceViewSubscriptionContainer
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
Expand All @@ -434,7 +441,8 @@ class GlobalSearchViewModel @Inject constructor(
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
restoreGlobalSearchHistory = restoreGlobalSearchHistory,
updateGlobalSearchHistory = updateGlobalSearchHistory,
fieldParser = fieldParser
fieldParser = fieldParser,
spaceViews = spaceViews
) as T
}
}
Expand Down
Loading