From 4d8768771f67f517d8550b9fa00535c56b43504e Mon Sep 17 00:00:00 2001 From: Evgenii Kozlov Date: Tue, 9 Aug 2022 20:04:56 +0300 Subject: [PATCH] DROID-290 Navigation | Enhancement | Open bookmark object instead of opening system browser (#2495) --- .../editor/render/DefaultBlockViewRenderer.kt | 3 +-- .../presentation/objects/SupportedLayouts.kt | 3 ++- .../search/ObjectSearchViewModel.kt | 3 ++- .../presentation/sets/ObjectSetViewModel.kt | 24 +++++-------------- .../sets/RelationValueBaseViewModel.kt | 3 ++- 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/render/DefaultBlockViewRenderer.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/render/DefaultBlockViewRenderer.kt index 32058a07f3..60a38e4a34 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/render/DefaultBlockViewRenderer.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/render/DefaultBlockViewRenderer.kt @@ -1510,8 +1510,7 @@ class DefaultBlockViewRenderer @Inject constructor( color = block.textColor() ) } - ObjectType.Layout.FILE, ObjectType.Layout.IMAGE -> { - + ObjectType.Layout.FILE, ObjectType.Layout.IMAGE, ObjectType.Layout.BOOKMARK -> { BlockView.Title.Basic( mode = blockMode, id = block.id, diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/SupportedLayouts.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/SupportedLayouts.kt index 4400b99ecb..4349713fcf 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/SupportedLayouts.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/objects/SupportedLayouts.kt @@ -11,6 +11,7 @@ object SupportedLayouts { ObjectType.Layout.PROFILE, ObjectType.Layout.SET, ObjectType.Layout.TODO, - ObjectType.Layout.NOTE + ObjectType.Layout.NOTE, + ObjectType.Layout.BOOKMARK ) } \ No newline at end of file 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 d620b1087a..393651dec7 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 @@ -128,7 +128,8 @@ open class ObjectSearchViewModel( ObjectType.Layout.TODO, ObjectType.Layout.NOTE, ObjectType.Layout.FILE, - ObjectType.Layout.IMAGE -> { + ObjectType.Layout.IMAGE, + ObjectType.Layout.BOOKMARK -> { navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = target))) } ObjectType.Layout.SET -> { diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt index 5d164504cd..51ca7dfbbe 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt @@ -588,29 +588,16 @@ class ObjectSetViewModel( val record = records.records.find { rec -> rec[Relations.ID] == target } if (record != null) { val obj = ObjectWrapper.Basic(record) - if (obj.layout != ObjectType.Layout.BOOKMARK) { - proceedWithNavigation( - target = target, - layout = obj.layout - ) - } else { - proceedWithBrowsingBookmarkObject(obj) - } + proceedWithNavigation( + target = target, + layout = obj.layout + ) } else { toast("Record not found. Please, try again later.") } } } - private fun proceedWithBrowsingBookmarkObject(obj: ObjectWrapper.Basic) { - val url = obj.url - if (url.isNullOrEmpty()) { - toast("Url is empty.") - } else { - dispatch(ObjectSetCommand.Intent.GoTo(url)) - } - } - fun onTaskCheckboxClicked(target: Id) { val set = reducer.state.value if (set.isInitialized) { @@ -1102,7 +1089,8 @@ class ObjectSetViewModel( ObjectType.Layout.TODO, ObjectType.Layout.NOTE, ObjectType.Layout.IMAGE, - ObjectType.Layout.FILE -> proceedWithOpeningPage(target) + ObjectType.Layout.FILE, + ObjectType.Layout.BOOKMARK -> proceedWithOpeningPage(target) ObjectType.Layout.SET -> { viewModelScope.launch { closeBlock(CloseBlock.Params(context)).process( diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/RelationValueBaseViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/RelationValueBaseViewModel.kt index 1b4fc65e76..984b330238 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/RelationValueBaseViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/RelationValueBaseViewModel.kt @@ -300,7 +300,8 @@ abstract class RelationValueBaseViewModel( ObjectType.Layout.TODO, ObjectType.Layout.FILE, ObjectType.Layout.IMAGE, - ObjectType.Layout.NOTE -> { + ObjectType.Layout.NOTE, + ObjectType.Layout.BOOKMARK -> { viewModelScope.launch { navigation.emit(AppNavigation.Command.OpenObject(id)) }