mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-465 Editor | Fix | Do not show self object when search in Link-to-object (#2661)
This commit is contained in:
parent
f97fa3ab4c
commit
7aeecc217e
7 changed files with 30 additions and 16 deletions
|
@ -1108,7 +1108,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
delay(DEFAULT_ANIM_DURATION)
|
||||
val fr = LinkToObjectFragment.new(
|
||||
target = command.target,
|
||||
position = command.position
|
||||
position = command.position,
|
||||
ignore = vm.context
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ class LinkToObjectFragment : BaseBottomSheetTextInputFragment<FragmentObjectSear
|
|||
|
||||
private val target get() = arg<Id>(ARG_TARGET)
|
||||
private val position get() = argOrNull<Int>(ARG_POSITION)
|
||||
private val ignore get() = arg<Id>(ARG_IGNORE)
|
||||
|
||||
private val moveToAdapter by lazy {
|
||||
DefaultObjectViewAdapter(
|
||||
|
@ -101,7 +102,7 @@ class LinkToObjectFragment : BaseBottomSheetTextInputFragment<FragmentObjectSear
|
|||
jobs += subscribe(vm.commands) { execute(it) }
|
||||
}
|
||||
super.onStart()
|
||||
vm.onStart(EventsDictionary.Routes.searchMenu)
|
||||
vm.onStart(EventsDictionary.Routes.searchMenu, ignore)
|
||||
expand()
|
||||
}
|
||||
|
||||
|
@ -259,11 +260,17 @@ class LinkToObjectFragment : BaseBottomSheetTextInputFragment<FragmentObjectSear
|
|||
companion object {
|
||||
const val ARG_TARGET = "arg.link_to.target"
|
||||
const val ARG_POSITION = "arg.link_to.position"
|
||||
const val ARG_IGNORE = "arg.link_to.ignore"
|
||||
|
||||
fun new(target: Id, position: Int?) = LinkToObjectFragment().apply {
|
||||
fun new(
|
||||
target: Id,
|
||||
position: Int?,
|
||||
ignore: Id
|
||||
) = LinkToObjectFragment().apply {
|
||||
arguments = bundleOf(
|
||||
ARG_TARGET to target,
|
||||
ARG_POSITION to position
|
||||
ARG_POSITION to position,
|
||||
ARG_IGNORE to ignore
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -278,5 +285,6 @@ interface OnLinkToAction {
|
|||
icon: ObjectIcon,
|
||||
isSet: Boolean
|
||||
)
|
||||
|
||||
fun onLinkToClose(block: Id, position: Int?)
|
||||
}
|
|
@ -5660,7 +5660,7 @@ class EditorViewModel(
|
|||
val fullText = filter.removePrefix(MENTION_PREFIX)
|
||||
val params = SearchObjects.Params(
|
||||
limit = ObjectSearchViewModel.SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterLinkTo,
|
||||
filters = ObjectSearchConstants.getFilterLinkTo(context),
|
||||
sorts = ObjectSearchConstants.sortLinkTo,
|
||||
fulltext = fullText,
|
||||
keys = ObjectSearchConstants.defaultKeys
|
||||
|
|
|
@ -212,7 +212,7 @@ class LinkToObjectOrWebViewModel(
|
|||
|
||||
fun getSearchObjectsParams() = SearchObjects.Params(
|
||||
limit = ObjectSearchViewModel.SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterLinkTo,
|
||||
filters = ObjectSearchConstants.getFilterLinkTo(ignore = null),
|
||||
sorts = ObjectSearchConstants.sortLinkTo,
|
||||
fulltext = ObjectSearchViewModel.EMPTY_QUERY
|
||||
)
|
||||
|
|
|
@ -6,8 +6,8 @@ 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.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.navigation.DefaultObjectView
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.SupportedLayouts
|
||||
|
@ -30,9 +30,9 @@ class LinkToObjectViewModel(
|
|||
|
||||
val commands = MutableSharedFlow<Command>(replay = 0)
|
||||
|
||||
override fun getSearchObjectsParams() = SearchObjects.Params(
|
||||
override fun getSearchObjectsParams(ignore: Id?) = SearchObjects.Params(
|
||||
limit = SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterLinkTo,
|
||||
filters = ObjectSearchConstants.getFilterLinkTo(ignore),
|
||||
sorts = ObjectSearchConstants.sortLinkTo,
|
||||
fulltext = EMPTY_QUERY,
|
||||
keys = ObjectSearchConstants.defaultKeys
|
||||
|
|
|
@ -53,7 +53,7 @@ object ObjectSearchConstants {
|
|||
//endregion
|
||||
|
||||
//region LINK TO
|
||||
val filterLinkTo = listOf(
|
||||
fun getFilterLinkTo(ignore: Id?) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
|
@ -76,6 +76,11 @@ object ObjectSearchConstants {
|
|||
VIDEO_URL,
|
||||
AUDIO_URL
|
||||
)
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = ignore
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import com.anytypeio.anytype.core_utils.common.EventWrapper
|
|||
import com.anytypeio.anytype.core_utils.ext.cancel
|
||||
import com.anytypeio.anytype.core_utils.ui.ViewStateViewModel
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsSearchQueryEvent
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsSearchResultEvent
|
||||
import com.anytypeio.anytype.presentation.navigation.AppNavigation
|
||||
|
@ -72,10 +72,10 @@ open class ObjectSearchViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onStart(route: String) {
|
||||
fun onStart(route: String, ignore: Id? = null) {
|
||||
eventRoute = route
|
||||
getObjectTypes()
|
||||
startProcessingSearchQuery()
|
||||
startProcessingSearchQuery(ignore)
|
||||
}
|
||||
|
||||
fun onStop() {
|
||||
|
@ -92,11 +92,11 @@ open class ObjectSearchViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private fun startProcessingSearchQuery() {
|
||||
private fun startProcessingSearchQuery(ignore: Id?) {
|
||||
jobs += viewModelScope.launch {
|
||||
searchQuery.collectLatest { query ->
|
||||
sendSearchQueryEvent(query)
|
||||
val params = getSearchObjectsParams().copy(fulltext = query)
|
||||
val params = getSearchObjectsParams(ignore).copy(fulltext = query)
|
||||
searchObjects(params = params).process(
|
||||
success = { objects -> setObjects(objects) },
|
||||
failure = { Timber.e(it, "Error while searching for objects") }
|
||||
|
@ -157,7 +157,7 @@ open class ObjectSearchViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
open fun getSearchObjectsParams() = SearchObjects.Params(
|
||||
open fun getSearchObjectsParams(ignore: Id?) = SearchObjects.Params(
|
||||
limit = SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterSearchObjects,
|
||||
sorts = ObjectSearchConstants.sortsSearchObjects,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue