From 302e95de28edf1485cc448e4aeecf1163a5c4c45 Mon Sep 17 00:00:00 2001 From: Konstantin Ivanov <54908981+konstantiniiv@users.noreply.github.com> Date: Wed, 26 May 2021 10:15:32 +0200 Subject: [PATCH] Tech | Middleware 0.15.4 (#1493) --- CHANGELOG.md | 4 +- .../features/editor/ClipboardTesting.kt | 8 +- .../features/editor/CreateBlockTesting.kt | 8 +- .../editor/CreateRelationBlockTesting.kt | 12 +- .../features/editor/DeleteBlockTesting.kt | 8 +- .../features/editor/DescriptionTesting.kt | 8 +- .../editor/FeaturedRelationTesting.kt | 8 +- .../anytype/features/editor/LayoutTesting.kt | 29 +--- .../features/editor/ListBlockTesting.kt | 8 +- .../features/editor/MergeBlockTesting.kt | 4 +- .../features/editor/RelationBlockUITesting.kt | 40 ++--- .../features/editor/ScrollAndMoveTesting.kt | 4 +- .../editor/SlashTextWatcherTesting.kt | 38 ++--- .../features/editor/SlashWidgetTesting.kt | 52 ++----- .../features/editor/SplitBlockTesting.kt | 36 ++--- .../dv/ObjectSetGridColumnRenderingTest.kt | 9 +- .../dv/ObjectSetGridFileCellRenderingTest.kt | 9 +- .../ObjectSetGridNumberCellRenderingTest.kt | 29 +--- .../ObjectSetGridObjectCellRenderingTest.kt | 13 +- .../dv/ObjectSetGridPrimitiveRelationTest.kt | 9 +- .../dv/ObjectSetGridTagCellRenderingTest.kt | 9 +- .../features/sets/dv/ObjectSetHeaderTest.kt | 5 +- .../anytypeio/anytype/core_models/Block.kt | 6 +- .../anytypeio/anytype/core_models/Event.kt | 6 +- .../anytypeio/anytype/core_models/PageLink.kt | 6 +- .../anytype/core_models/SmartBlockType.kt | 21 +++ .../domain/dashboard/model/HomeDashboard.kt | 1 - .../domain/page/navigation/GetListPages.kt | 26 +++- .../page/navigation/GetPageInfoWithLinks.kt | 71 +++++---- .../anytype/domain/ext/BlockExtensionTest.kt | 12 +- .../page/navigation/GetListPagesTest.kt | 13 +- .../navigation/GetPageInfoWithLinksTest.kt | 29 ++-- .../middleware/block/BlockMiddleware.kt | 2 +- .../middleware/interactor/Middleware.kt | 22 ++- .../interactor/MiddlewareEventMapper.kt | 5 +- .../anytype/middleware/mappers/Alias.kt | 14 +- .../middleware/mappers/ToCoreModelMappers.kt | 86 +++++------ .../anytype/MiddlewareEventChannelTest.kt | 6 +- .../desktop/HomeDashboardEventConverter.kt | 5 +- .../presentation/mapper/MapperExtension.kt | 3 +- .../presentation/page/PageViewModel.kt | 4 +- .../page/render/DefaultBlockViewRenderer.kt | 4 +- .../anytype/presentation/MockBlockFactory.kt | 5 +- .../MockTypicalDocumentFactory.kt | 8 +- .../home/DashboardDragAndDropTest.kt | 31 +--- .../home/HomeDashboardViewModelTest.kt | 11 +- .../presentation/page/BlockReadModeTest.kt | 4 +- .../page/DefaultBlockViewRendererTest.kt | 33 ++-- .../presentation/page/PageViewModelTest.kt | 112 +++++--------- .../page/editor/EditorAddBlockTest.kt | 8 +- .../editor/EditorBackspaceNestedDeleteTest.kt | 16 +- .../editor/EditorEmptySpaceInteractionTest.kt | 8 +- .../editor/EditorEventSubscriptionTest.kt | 4 +- .../page/editor/EditorFocusTest.kt | 6 +- .../page/editor/EditorGranularChangeTest.kt | 4 +- .../page/editor/EditorListBlockTest.kt | 16 +- .../page/editor/EditorMentionTest.kt | 16 +- .../page/editor/EditorMergeTest.kt | 4 +- .../page/editor/EditorMoveToTest.kt | 8 +- .../page/editor/EditorMultiSelectModeTest.kt | 28 +--- .../EditorQuickStartingScrollAndMoveTest.kt | 12 +- .../page/editor/EditorRelationBlockTest.kt | 4 +- .../page/editor/EditorScrollAndMoveTest.kt | 40 ++--- .../editor/EditorSlashWidgetActionsTest.kt | 4 +- .../editor/EditorSlashWidgetClicksTest.kt | 10 +- .../page/editor/EditorSlashWidgetColorTest.kt | 26 +--- .../page/editor/EditorSlashWidgetMarksTest.kt | 32 +--- .../editor/EditorSlashWidgetStyleTypeTest.kt | 8 +- .../page/editor/EditorStartupTest.kt | 4 +- .../page/editor/EditorTextUpdateTest.kt | 16 +- .../page/editor/EditorTitleAddBlockTest.kt | 40 ++--- .../page/editor/EditorTitleTest.kt | 10 +- .../page/editor/EditorTurnIntoTest.kt | 20 +-- .../page/editor/StyleConfigKtTest.kt | 2 +- protocol/src/main/proto/block.proto | 15 ++ protocol/src/main/proto/changes.proto | 8 +- protocol/src/main/proto/commands.proto | 46 +++--- protocol/src/main/proto/events.proto | 43 +----- protocol/src/main/proto/file.proto | 63 ++++++++ protocol/src/main/proto/localstore.proto | 18 +-- protocol/src/main/proto/models.proto | 143 +++++++++++++++++- protocol/src/main/proto/relation.proto | 123 --------------- 82 files changed, 672 insertions(+), 1029 deletions(-) create mode 100644 core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt create mode 100644 protocol/src/main/proto/block.proto create mode 100644 protocol/src/main/proto/file.proto delete mode 100644 protocol/src/main/proto/relation.proto diff --git a/CHANGELOG.md b/CHANGELOG.md index 86db585286..012b236eeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ ## Version 0.2.0 +## Version 0.1.11 [WIP] + ### Middleware ⚙ -* Updated middleware protocol to `0.15.3` (#1448) +* Updated middleware protocol to `0.15.4` (#1493) ## Version 0.1.9 diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ClipboardTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ClipboardTesting.kt index bc67f13eab..1deb55ac01 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ClipboardTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ClipboardTesting.kt @@ -152,9 +152,7 @@ class ClipboardTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) @@ -417,9 +415,7 @@ class ClipboardTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateBlockTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateBlockTesting.kt index d3c82aa1d9..e8c802a241 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateBlockTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateBlockTesting.kt @@ -142,9 +142,7 @@ class CreateBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) @@ -265,9 +263,7 @@ class CreateBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateRelationBlockTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateRelationBlockTesting.kt index 6c64b6295d..d722f03980 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateRelationBlockTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/CreateRelationBlockTesting.kt @@ -100,9 +100,7 @@ class CreateRelationBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -182,9 +180,7 @@ class CreateRelationBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -267,9 +263,7 @@ class CreateRelationBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DeleteBlockTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DeleteBlockTesting.kt index 38509d7ee5..e1d970ee53 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DeleteBlockTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DeleteBlockTesting.kt @@ -296,9 +296,7 @@ class DeleteBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id) ) @@ -531,9 +529,7 @@ class DeleteBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DescriptionTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DescriptionTesting.kt index 0e7e9c6e99..4fe4f8626f 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DescriptionTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/DescriptionTesting.kt @@ -78,9 +78,7 @@ class DescriptionTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -130,9 +128,7 @@ class DescriptionTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/FeaturedRelationTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/FeaturedRelationTesting.kt index 2174189d66..3f1bcdb590 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/FeaturedRelationTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/FeaturedRelationTesting.kt @@ -146,9 +146,7 @@ class FeaturedRelationTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, block1.id) ) @@ -258,9 +256,7 @@ class FeaturedRelationTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, block1.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/LayoutTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/LayoutTesting.kt index 6624addc19..e05fcfc29e 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/LayoutTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/LayoutTesting.kt @@ -6,6 +6,7 @@ import androidx.test.filters.LargeTest import com.anytypeio.anytype.R import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Layout +import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.domain.cover.CoverType import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider @@ -76,9 +77,7 @@ class LayoutTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, paragraph.id) ) @@ -128,9 +127,7 @@ class LayoutTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, paragraph.id) ) @@ -175,9 +172,7 @@ class LayoutTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, paragraph.id) ) @@ -223,9 +218,7 @@ class LayoutTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, paragraph.id) ) @@ -269,9 +262,7 @@ class LayoutTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, paragraph.id) ) @@ -317,9 +308,7 @@ class LayoutTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, paragraph.id) ) @@ -363,9 +352,7 @@ class LayoutTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, paragraph.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ListBlockTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ListBlockTesting.kt index bb516a0efc..6764a00198 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ListBlockTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ListBlockTesting.kt @@ -113,9 +113,7 @@ class ListBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(a.id) ) @@ -282,9 +280,7 @@ class ListBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/MergeBlockTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/MergeBlockTesting.kt index c2ab1aafc8..e379f87d9c 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/MergeBlockTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/MergeBlockTesting.kt @@ -210,9 +210,7 @@ class MergeBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/RelationBlockUITesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/RelationBlockUITesting.kt index 47ffd67a19..0084a2256a 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/RelationBlockUITesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/RelationBlockUITesting.kt @@ -100,9 +100,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) @@ -232,9 +230,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, block1.id, block2.id, block3.id, block4.id, block5.id) ) @@ -394,9 +390,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, block1.id, block2.id, block3.id, block4.id, block5.id) ) @@ -473,9 +467,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) @@ -562,9 +554,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) @@ -616,9 +606,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, block.id) ) @@ -679,9 +667,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -808,9 +794,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -887,9 +871,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -1021,9 +1003,7 @@ class RelationBlockUITesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, block1.id, block2.id, block3.id, block4.id, block5.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ScrollAndMoveTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ScrollAndMoveTesting.kt index 7078983c6d..3119e079b8 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ScrollAndMoveTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/ScrollAndMoveTesting.kt @@ -92,9 +92,7 @@ class ScrollAndMoveTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashTextWatcherTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashTextWatcherTesting.kt index 49377a94b5..07e2602525 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashTextWatcherTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashTextWatcherTesting.kt @@ -10,7 +10,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_ui.widgets.text.TextInputWidget import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider import com.anytypeio.anytype.features.editor.base.EditorTestSetup import com.anytypeio.anytype.features.editor.base.TestPageFragment @@ -19,7 +18,6 @@ import com.anytypeio.anytype.presentation.page.PageViewModel import com.anytypeio.anytype.ui.page.PageFragment import com.anytypeio.anytype.utils.* import com.bartoszlipinski.disableanimationsrule.DisableAnimationsRule -import kotlinx.android.synthetic.main.fragment_page.* import org.junit.Before import org.junit.Rule import org.junit.Test @@ -88,9 +86,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -130,9 +126,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -174,9 +168,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -216,9 +208,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -259,9 +249,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -303,9 +291,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -345,9 +331,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -389,9 +373,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -448,9 +430,7 @@ class SlashTextWatcherTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, paragraph2.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashWidgetTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashWidgetTesting.kt index 7b7389f1b4..462df741b9 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashWidgetTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SlashWidgetTesting.kt @@ -113,9 +113,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -165,9 +163,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -217,9 +213,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -274,9 +268,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -331,9 +323,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -388,9 +378,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -445,9 +433,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -536,9 +522,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) @@ -632,9 +616,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, paragraph2.id) ) @@ -726,9 +708,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, paragraph2.id) ) @@ -825,9 +805,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, paragraph2.id) ) @@ -923,9 +901,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id, paragraph2.id) ) @@ -998,9 +974,7 @@ class SlashWidgetTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, paragraph.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SplitBlockTesting.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SplitBlockTesting.kt index 32f5743d90..3fc5137231 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SplitBlockTesting.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/SplitBlockTesting.kt @@ -74,9 +74,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -227,9 +225,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -378,9 +374,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -529,9 +523,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -680,9 +672,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -833,9 +823,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -986,9 +974,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -1139,9 +1125,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) @@ -1292,9 +1276,7 @@ class SplitBlockTesting : EditorTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt index 6b1abb172c..4f46832810 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt @@ -4,10 +4,7 @@ import androidx.core.os.bundleOf import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.DVViewerRelation -import com.anytypeio.anytype.core_models.ObjectType -import com.anytypeio.anytype.core_models.Relation +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.mocking.MockDataFactory import com.anytypeio.anytype.ui.sets.ObjectSetFragment import com.anytypeio.anytype.utils.checkHasText @@ -135,9 +132,7 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt index 2a994ebdec..4b0686d405 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt @@ -6,10 +6,7 @@ import androidx.test.espresso.matcher.ViewMatchers import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.DVViewerRelation -import com.anytypeio.anytype.core_models.ObjectType -import com.anytypeio.anytype.core_models.Relation +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider import com.anytypeio.anytype.mocking.MockDataFactory import com.anytypeio.anytype.presentation.relations.ObjectSetConfig @@ -144,9 +141,7 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt index 8d5d1dede5..7d4cc96b9e 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt @@ -4,10 +4,7 @@ import androidx.core.os.bundleOf import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.DVViewerRelation -import com.anytypeio.anytype.core_models.ObjectType -import com.anytypeio.anytype.core_models.Relation +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider import com.anytypeio.anytype.mocking.MockDataFactory import com.anytypeio.anytype.presentation.relations.ObjectSetConfig @@ -108,9 +105,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) @@ -202,9 +197,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) @@ -296,9 +289,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) @@ -390,9 +381,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) @@ -484,9 +473,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) @@ -578,9 +565,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt index 778c616d78..f2723845d0 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt @@ -7,10 +7,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.DVViewerRelation -import com.anytypeio.anytype.core_models.ObjectType -import com.anytypeio.anytype.core_models.Relation +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider import com.anytypeio.anytype.mocking.MockDataFactory import com.anytypeio.anytype.presentation.relations.ObjectSetConfig @@ -143,9 +140,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) @@ -262,9 +257,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt index f7efe9e565..5af89ea496 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt @@ -4,10 +4,7 @@ import androidx.core.os.bundleOf import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.DVViewerRelation -import com.anytypeio.anytype.core_models.ObjectType -import com.anytypeio.anytype.core_models.Relation +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider import com.anytypeio.anytype.mocking.MockDataFactory import com.anytypeio.anytype.presentation.relations.ObjectSetConfig @@ -170,9 +167,7 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt index e1518977f4..560bed410f 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt @@ -6,10 +6,7 @@ import androidx.test.espresso.matcher.ViewMatchers import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.DVViewerRelation -import com.anytypeio.anytype.core_models.ObjectType -import com.anytypeio.anytype.core_models.Relation +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider import com.anytypeio.anytype.mocking.MockDataFactory import com.anytypeio.anytype.presentation.relations.ObjectSetConfig @@ -138,9 +135,7 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt index 14e451b66f..476f911cd3 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt @@ -7,6 +7,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import com.anytypeio.anytype.R import com.anytypeio.anytype.core_models.Block +import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.mocking.MockDataFactory import com.anytypeio.anytype.ui.sets.ObjectSetFragment @@ -68,9 +69,7 @@ class ObjectSetHeaderTest : TestObjectSetSetup() { val root = Block( id = ctx, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.SET - ), + content = Block.Content.Smart(SmartBlockType.SET), children = listOf(header.id, dataview.id) ) diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt index 6dd86a6463..66223d6637 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt @@ -65,11 +65,7 @@ data class Block( /** * Smart block. */ - data class Smart( - val type: Type - ) : Content() { - enum class Type { HOME, PAGE, ARCHIVE, BREADCRUMBS, PROFILE, SET } - } + data class Smart(val type: SmartBlockType = SmartBlockType.PAGE): Content() /** * Textual block. diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Event.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Event.kt index e6ddcabc58..6de8f16026 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Event.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Event.kt @@ -21,13 +21,11 @@ sealed class Event { val root: Id, val details: Block.Details = Block.Details(emptyMap()), val blocks: List, - val type: Type = Type.PAGE, + val type: SmartBlockType = SmartBlockType.PAGE, val objectTypes: List = emptyList(), val objectTypePerObject: Map = emptyMap(), val relations: List = emptyList() - ) : Command() { - enum class Type { PAGE, HOME, PROFILE_PAGE, ARCHIVE, BREADCRUMBS, SET } - } + ) : Command() data class AddBlock( override val context: String, diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/PageLink.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/PageLink.kt index 06348a40f8..5e7a593299 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/PageLink.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/PageLink.kt @@ -11,10 +11,8 @@ data class DocumentInfo( val fields: Block.Fields, val snippet: String?, val hasInboundLinks: Boolean, - val type: Type -) { - enum class Type { PAGE, HOME, PROFILE_PAGE, ARCHIVE, SET, FILE, OBJECT_TYPE, RELATION } -} + val smartBlockType: SmartBlockType +) data class PageLinks(val inbound: List, val outbound: List) diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt new file mode 100644 index 0000000000..35b4485b8a --- /dev/null +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt @@ -0,0 +1,21 @@ +package com.anytypeio.anytype.core_models + +enum class SmartBlockType { + BREADCRUMBS, + PAGE, + PROFILE_PAGE, + HOME, + ARCHIVE, + SET, + BUNDLED_OBJECT_TYPE, + CUSTOM_OBJECT_TYPE, + FILE, + TEMPLATE, + MARKETPLACE_TYPE, + MARKETPLACE_RELATION, + MARKETPLACE_TEMPLATE, + BUNDLED_RELATION, + INDEXED_RELATION, + ANYTYPE_PROFILE, + DATABASE +} \ No newline at end of file diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/dashboard/model/HomeDashboard.kt b/domain/src/main/java/com/anytypeio/anytype/domain/dashboard/model/HomeDashboard.kt index c34f3520fc..054b9850f0 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/dashboard/model/HomeDashboard.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/dashboard/model/HomeDashboard.kt @@ -7,6 +7,5 @@ data class HomeDashboard( val blocks: List, val children: List, val fields: Block.Fields, - val type: Block.Content.Smart.Type, val details: Block.Details = Block.Details(emptyMap()) ) \ No newline at end of file diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetListPages.kt b/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetListPages.kt index 2109a82aa7..9ba8df4169 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetListPages.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetListPages.kt @@ -1,23 +1,33 @@ package com.anytypeio.anytype.domain.page.navigation import com.anytypeio.anytype.core_models.DocumentInfo +import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.domain.base.BaseUseCase import com.anytypeio.anytype.domain.base.Either import com.anytypeio.anytype.domain.block.repo.BlockRepository -open class GetListPages(private val repo: BlockRepository) : - BaseUseCase() { +open class GetListPages( + private val repo: BlockRepository +) : BaseUseCase() { override suspend fun run(params: Unit): Either = safe { val documents = repo.getListPages() val pages = documents.filterNot { document -> document.fields.isArchived == true - || document.type == DocumentInfo.Type.SET - || document.type == DocumentInfo.Type.HOME - || document.type == DocumentInfo.Type.RELATION - || document.type == DocumentInfo.Type.OBJECT_TYPE -// TODO Filter by profile object Anytype, maybe will change in future - || document.id == ANYTYPE_PROFILE_ID + || document.smartBlockType == SmartBlockType.SET + || document.smartBlockType == SmartBlockType.BREADCRUMBS + || document.smartBlockType == SmartBlockType.HOME + || document.smartBlockType == SmartBlockType.BUNDLED_OBJECT_TYPE + || document.smartBlockType == SmartBlockType.CUSTOM_OBJECT_TYPE + || document.smartBlockType == SmartBlockType.MARKETPLACE_TYPE + || document.smartBlockType == SmartBlockType.MARKETPLACE_TEMPLATE + || document.smartBlockType == SmartBlockType.MARKETPLACE_RELATION + || document.smartBlockType == SmartBlockType.FILE + || document.smartBlockType == SmartBlockType.TEMPLATE + || document.smartBlockType == SmartBlockType.BUNDLED_RELATION + || document.smartBlockType == SmartBlockType.INDEXED_RELATION + || document.smartBlockType == SmartBlockType.DATABASE + || document.smartBlockType == SmartBlockType.ANYTYPE_PROFILE } Response(pages) } diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinks.kt b/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinks.kt index 740ad3aad9..1cf9a3f9dc 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinks.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinks.kt @@ -1,7 +1,7 @@ package com.anytypeio.anytype.domain.page.navigation -import com.anytypeio.anytype.core_models.DocumentInfo import com.anytypeio.anytype.core_models.PageInfoWithLinks +import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.domain.base.BaseUseCase import com.anytypeio.anytype.domain.base.Either import com.anytypeio.anytype.domain.block.repo.BlockRepository @@ -12,37 +12,48 @@ class GetPageInfoWithLinks(private val repo: BlockRepository) : override suspend fun run(params: Params): Either = safe { repo.getPageInfoWithLinks( pageId = params.pageId - ) - .let { - Response( - pageInfoWithLinks = it.copy( - links = it.links.copy( - outbound = it.links.outbound.filterNot { doc -> - doc.fields.isArchived == true - || doc.type == DocumentInfo.Type.SET - || doc.type == DocumentInfo.Type.ARCHIVE - || doc.type == DocumentInfo.Type.OBJECT_TYPE - || doc.type == DocumentInfo.Type.RELATION - || doc.type == DocumentInfo.Type.FILE - || doc.type == DocumentInfo.Type.PROFILE_PAGE - // TODO Filter by profile object Anytype, maybe will change in future - || doc.id == GetListPages.ANYTYPE_PROFILE_ID - }, - inbound = it.links.inbound.filterNot { doc -> - doc.fields.isArchived == true - || doc.type == DocumentInfo.Type.SET - || doc.type == DocumentInfo.Type.ARCHIVE - || doc.type == DocumentInfo.Type.OBJECT_TYPE - || doc.type == DocumentInfo.Type.RELATION - || doc.type == DocumentInfo.Type.FILE - || doc.type == DocumentInfo.Type.PROFILE_PAGE - // TODO Filter by profile object Anytype, maybe will change in future - || doc.id == GetListPages.ANYTYPE_PROFILE_ID - } - ) + ).let { + Response( + pageInfoWithLinks = it.copy( + links = it.links.copy( + outbound = it.links.outbound.filterNot { document -> + document.fields.isArchived == true + || document.smartBlockType == SmartBlockType.SET + || document.smartBlockType == SmartBlockType.BREADCRUMBS + || document.smartBlockType == SmartBlockType.HOME + || document.smartBlockType == SmartBlockType.BUNDLED_OBJECT_TYPE + || document.smartBlockType == SmartBlockType.CUSTOM_OBJECT_TYPE + || document.smartBlockType == SmartBlockType.MARKETPLACE_TYPE + || document.smartBlockType == SmartBlockType.MARKETPLACE_TEMPLATE + || document.smartBlockType == SmartBlockType.MARKETPLACE_RELATION + || document.smartBlockType == SmartBlockType.FILE + || document.smartBlockType == SmartBlockType.TEMPLATE + || document.smartBlockType == SmartBlockType.BUNDLED_RELATION + || document.smartBlockType == SmartBlockType.INDEXED_RELATION + || document.smartBlockType == SmartBlockType.DATABASE + || document.smartBlockType == SmartBlockType.ANYTYPE_PROFILE + }, + inbound = it.links.inbound.filterNot { document -> + document.fields.isArchived == true + || document.smartBlockType == SmartBlockType.SET + || document.smartBlockType == SmartBlockType.BREADCRUMBS + || document.smartBlockType == SmartBlockType.HOME + || document.smartBlockType == SmartBlockType.BUNDLED_OBJECT_TYPE + || document.smartBlockType == SmartBlockType.CUSTOM_OBJECT_TYPE + || document.smartBlockType == SmartBlockType.MARKETPLACE_TYPE + || document.smartBlockType == SmartBlockType.MARKETPLACE_TEMPLATE + || document.smartBlockType == SmartBlockType.MARKETPLACE_RELATION + || document.smartBlockType == SmartBlockType.FILE + || document.smartBlockType == SmartBlockType.TEMPLATE + || document.smartBlockType == SmartBlockType.BUNDLED_RELATION + || document.smartBlockType == SmartBlockType.INDEXED_RELATION + || document.smartBlockType == SmartBlockType.DATABASE + || document.smartBlockType == SmartBlockType.ANYTYPE_PROFILE + } ) ) - } + ) + } } data class Params( diff --git a/domain/src/test/java/com/anytypeio/anytype/domain/ext/BlockExtensionTest.kt b/domain/src/test/java/com/anytypeio/anytype/domain/ext/BlockExtensionTest.kt index 76627d158d..b02ded0e9a 100644 --- a/domain/src/test/java/com/anytypeio/anytype/domain/ext/BlockExtensionTest.kt +++ b/domain/src/test/java/com/anytypeio/anytype/domain/ext/BlockExtensionTest.kt @@ -934,9 +934,7 @@ class BlockExtensionTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) @@ -977,9 +975,7 @@ class BlockExtensionTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) @@ -1007,9 +1003,7 @@ class BlockExtensionTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) diff --git a/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetListPagesTest.kt b/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetListPagesTest.kt index a17488082c..e499410a77 100644 --- a/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetListPagesTest.kt +++ b/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetListPagesTest.kt @@ -1,9 +1,10 @@ package com.anytypeio.anytype.domain.page.navigation import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.core_models.CoroutineTestRule import com.anytypeio.anytype.core_models.DocumentInfo +import com.anytypeio.anytype.core_models.SmartBlockType +import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.nhaarman.mockitokotlin2.doReturn import com.nhaarman.mockitokotlin2.stub import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -41,21 +42,21 @@ class GetListPagesTest { fields = Block.Fields(mapOf("name" to "Alex")), snippet = "Snippet1", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "9876", fields = Block.Fields(mapOf("name" to "Mike", "isArchived" to false)), snippet = "Snippet2", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "934", fields = Block.Fields(mapOf("name" to "Leo", "isArchived" to true)), snippet = "Snippet3", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ) ) } @@ -72,7 +73,7 @@ class GetListPagesTest { fields = Block.Fields(mapOf("name" to "Alex")), snippet = "Snippet1", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "9876", @@ -84,7 +85,7 @@ class GetListPagesTest { ), snippet = "Snippet2", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ) ), actual = response.listPages diff --git a/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinksTest.kt b/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinksTest.kt index e14ca3cf3d..bffcb163cd 100644 --- a/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinksTest.kt +++ b/domain/src/test/java/com/anytypeio/anytype/domain/page/navigation/GetPageInfoWithLinksTest.kt @@ -1,12 +1,7 @@ package com.anytypeio.anytype.domain.page.navigation -import com.anytypeio.anytype.core_models.Block +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.domain.block.repo.BlockRepository -import com.anytypeio.anytype.core_models.CoroutineTestRule -import com.anytypeio.anytype.core_models.DocumentInfo -import com.anytypeio.anytype.core_models.MockDataFactory -import com.anytypeio.anytype.core_models.PageInfoWithLinks -import com.anytypeio.anytype.core_models.PageLinks import com.nhaarman.mockitokotlin2.doReturn import com.nhaarman.mockitokotlin2.stub import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -47,7 +42,7 @@ class GetPageInfoWithLinksTest { fields = Block.Fields.empty(), snippet = "Snip", hasInboundLinks = true, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), links = PageLinks( inbound = listOf( @@ -56,21 +51,21 @@ class GetPageInfoWithLinksTest { fields = Block.Fields(mapOf("name" to "Alex")), snippet = "Snippet12", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "13", fields = Block.Fields(mapOf("name" to "Mike", "isArchived" to false)), snippet = "Snippet13", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "14", fields = Block.Fields(mapOf("name" to "Leo", "isArchived" to true)), snippet = "Snippet14", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ) ), outbound = listOf( @@ -79,21 +74,21 @@ class GetPageInfoWithLinksTest { fields = Block.Fields(mapOf("name" to "Teo")), snippet = "Snippet15", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "16", fields = Block.Fields(mapOf("name" to "Thom", "isArchived" to false)), snippet = "Snippet16", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "17", fields = Block.Fields(mapOf("name" to "Andrey", "isArchived" to true)), snippet = "Snippet17", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ) ) ) @@ -114,7 +109,7 @@ class GetPageInfoWithLinksTest { fields = Block.Fields(mapOf("name" to "Teo")), snippet = "Snippet15", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "16", @@ -126,7 +121,7 @@ class GetPageInfoWithLinksTest { ), snippet = "Snippet16", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ) ), actual = outbound @@ -138,7 +133,7 @@ class GetPageInfoWithLinksTest { fields = Block.Fields(mapOf("name" to "Alex")), snippet = "Snippet12", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ), DocumentInfo( id = "13", @@ -150,7 +145,7 @@ class GetPageInfoWithLinksTest { ), snippet = "Snippet13", hasInboundLinks = false, - type = DocumentInfo.Type.PAGE + smartBlockType = SmartBlockType.PAGE ) ), actual = inbound diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/block/BlockMiddleware.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/block/BlockMiddleware.kt index 2b89a27e8f..42cc9b97b7 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/block/BlockMiddleware.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/block/BlockMiddleware.kt @@ -201,7 +201,7 @@ class BlockMiddleware( ): Payload = middleware.setFields(command) override suspend fun getTemplates(): List { - return middleware.getObjectTypes().map { type -> type.toCoreModels() } + return middleware.getObjectTypes().map { it.toCoreModels() } } override suspend fun createTemplate( diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt index 5744c87de6..6b79c4cfc8 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt @@ -7,14 +7,10 @@ import anytype.model.Block import anytype.model.ObjectInfo import anytype.model.ObjectInfoWithLinks import anytype.model.Range -import anytype.relation.ObjectType -import anytype.relation.Relation import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.middleware.BuildConfig import com.anytypeio.anytype.middleware.const.Constants -import com.anytypeio.anytype.middleware.mappers.toCoreModels -import com.anytypeio.anytype.middleware.mappers.toMiddlewareModel -import com.anytypeio.anytype.middleware.mappers.toPayload +import com.anytypeio.anytype.middleware.mappers.* import com.anytypeio.anytype.middleware.model.CreateAccountResponse import com.anytypeio.anytype.middleware.model.CreateWalletResponse import com.anytypeio.anytype.middleware.model.SelectAccountResponse @@ -952,7 +948,7 @@ class Middleware( } @Throws(Exception::class) - fun getObjectTypes(): List { + fun getObjectTypes(): List { val request = Rpc.ObjectType.List.Request() if (BuildConfig.DEBUG) logRequest(request) val response = service.objectTypeList(request) @@ -962,11 +958,11 @@ class Middleware( } @Throws(Exception::class) - fun objectTypeCreate(prototype: com.anytypeio.anytype.core_models.ObjectType.Prototype): ObjectType { + fun objectTypeCreate(prototype: ObjectType.Prototype): MObjectType { val layout = prototype.layout.toMiddlewareModel() - val objectType = ObjectType( + val objectType = MObjectType( name = prototype.name, iconEmoji = prototype.emoji, layout = layout @@ -1044,10 +1040,10 @@ class Middleware( context: String, target: String, name: String, - format: com.anytypeio.anytype.core_models.Relation.Format + format: Relation.Format ): Pair { - val relation = Relation( + val relation = MRelation( name = name, format = format.toMiddlewareModel() ) @@ -1189,7 +1185,7 @@ class Middleware( } @Throws(Exception::class) - fun relationListAvailable(ctx: Id): List { + fun relationListAvailable(ctx: Id): List { val request = Rpc.Object.RelationListAvailable.Request( contextId = ctx ) @@ -1233,7 +1229,7 @@ class Middleware( blockId = dataview, relationKey = relation, recordId = record, - option = Relation.Option(text = name, color = color) + option = MRelationOption(text = name, color = color) ) if (BuildConfig.DEBUG) logRequest(request) val response = service.blockDataViewRecordRelationOptionAdd(request) @@ -1251,7 +1247,7 @@ class Middleware( val request = Rpc.Object.RelationOptionAdd.Request( contextId = ctx, relationKey = relation, - option = Relation.Option(text = name, color = color) + option = MRelationOption(text = name, color = color) ) if (BuildConfig.DEBUG) logRequest(request) val response = service.objectRelationOptionAdd(request) diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/MiddlewareEventMapper.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/MiddlewareEventMapper.kt index 1455a6758c..f939c34ad0 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/MiddlewareEventMapper.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/MiddlewareEventMapper.kt @@ -5,7 +5,6 @@ import com.anytypeio.anytype.core_models.Event import com.anytypeio.anytype.middleware.mappers.toCoreModel import com.anytypeio.anytype.middleware.mappers.toCoreModels import com.anytypeio.anytype.middleware.mappers.toCoreModelsAlign -import com.anytypeio.anytype.middleware.mappers.toCoreModelsEvent fun anytype.Event.Message.toCoreModels( context: String @@ -21,12 +20,12 @@ fun anytype.Event.Message.toCoreModels( objectShow != null -> { val event = objectShow checkNotNull(event) - val type = event.type.toCoreModelsEvent() + val type = event.type.toCoreModel() Event.Command.ShowBlock( context = context, root = event.rootId, blocks = event.blocks.toCoreModels( - types = mapOf(event.rootId to event.type) + types = mapOf(event.rootId to type) ), details = Block.Details( event.details.associate { details -> diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/Alias.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/Alias.kt index 8a51b58095..82afd27e54 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/Alias.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/mappers/Alias.kt @@ -33,9 +33,11 @@ typealias MDVRelation = anytype.model.Block.Content.Dataview.Relation typealias MDVDateFormat = anytype.model.Block.Content.Dataview.Relation.DateFormat typealias MDVTimeFormat = anytype.model.Block.Content.Dataview.Relation.TimeFormat -typealias MObjectType = anytype.relation.ObjectType -typealias MOTypeLayout = anytype.relation.ObjectType.Layout -typealias MRelationFormat = anytype.relation.RelationFormat -typealias MRelationDataSource = anytype.relation.Relation.DataSource -typealias MRelation = anytype.relation.Relation -typealias MRelationOption = anytype.relation.Relation.Option + +typealias MObjectType = anytype.model.ObjectType +typealias MSmartBlockType = anytype.model.SmartBlockType +typealias MOTypeLayout = anytype.model.ObjectType.Layout +typealias MRelationFormat = anytype.model.RelationFormat +typealias MRelationDataSource = anytype.model.Relation.DataSource +typealias MRelation = anytype.model.Relation +typealias MRelationOption = anytype.model.Relation.Option 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 d1bc858148..7f64260a5b 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 @@ -1,11 +1,9 @@ package com.anytypeio.anytype.middleware.mappers import anytype.ResponseEvent -import anytype.SmartBlockType import anytype.model.ObjectInfo import anytype.model.ObjectInfoWithLinks import anytype.model.ObjectLinksInfo -import anytype.relation.RelationFormat import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.middleware.interactor.toCoreModels import timber.log.Timber @@ -89,8 +87,7 @@ fun List.toCoreModels( fields = block.toCoreModelsFields(), children = block.childrenIds, content = Block.Content.Smart( - type = types[block.id]?.toCoreModelsBlock() - ?: throw IllegalStateException("Type missing") + type = types[block.id] ?: throw IllegalStateException("Type missing") ) ) } @@ -202,7 +199,7 @@ fun MBlock.toCoreModelsDataView(): Block.Content.DataView { ) } -fun MBlock.toCoreModelsRelationBlock() : Block.Content.RelationBlock { +fun MBlock.toCoreModelsRelationBlock(): Block.Content.RelationBlock { val content = checkNotNull(relation) return Block.Content.RelationBlock( key = content.key.ifEmpty { null }, @@ -210,26 +207,6 @@ fun MBlock.toCoreModelsRelationBlock() : Block.Content.RelationBlock { ) } -fun SmartBlockType.toCoreModelsBlock(): Block.Content.Smart.Type = when (this) { - SmartBlockType.Page -> Block.Content.Smart.Type.PAGE - SmartBlockType.Home -> Block.Content.Smart.Type.HOME - SmartBlockType.ProfilePage -> Block.Content.Smart.Type.PROFILE - SmartBlockType.Archive -> Block.Content.Smart.Type.ARCHIVE - SmartBlockType.Breadcrumbs -> Block.Content.Smart.Type.BREADCRUMBS - SmartBlockType.Set -> Block.Content.Smart.Type.SET - else -> throw IllegalStateException("Unexpected smart block type: $this") -} - -fun SmartBlockType.toCoreModelsEvent(): Event.Command.ShowBlock.Type = when (this) { - SmartBlockType.Page -> Event.Command.ShowBlock.Type.PAGE - SmartBlockType.Home -> Event.Command.ShowBlock.Type.HOME - SmartBlockType.ProfilePage -> Event.Command.ShowBlock.Type.PROFILE_PAGE - SmartBlockType.Archive -> Event.Command.ShowBlock.Type.ARCHIVE - SmartBlockType.Breadcrumbs -> Event.Command.ShowBlock.Type.BREADCRUMBS - SmartBlockType.Set -> Event.Command.ShowBlock.Type.SET - else -> throw IllegalStateException("Unexpected smart block type: $this") -} - fun MBFileState.toCoreModels(): Block.Content.File.State = when (this) { MBFileState.Empty -> Block.Content.File.State.EMPTY MBFileState.Uploading -> Block.Content.File.State.UPLOADING @@ -435,21 +412,21 @@ fun MRelationDataSource.source(): Relation.Source = when (this) { else -> throw IllegalStateException() } -fun RelationFormat.format(): Relation.Format = when (this) { - RelationFormat.shorttext -> Relation.Format.SHORT_TEXT - RelationFormat.longtext -> Relation.Format.LONG_TEXT - RelationFormat.number -> Relation.Format.NUMBER - RelationFormat.date -> Relation.Format.DATE - RelationFormat.file_ -> Relation.Format.FILE - RelationFormat.checkbox -> Relation.Format.CHECKBOX - RelationFormat.url -> Relation.Format.URL - RelationFormat.email -> Relation.Format.EMAIL - RelationFormat.phone -> Relation.Format.PHONE - RelationFormat.emoji -> Relation.Format.EMOJI - RelationFormat.object_ -> Relation.Format.OBJECT - RelationFormat.status -> Relation.Format.STATUS - RelationFormat.tag -> Relation.Format.TAG - RelationFormat.relations -> Relation.Format.RELATIONS +fun MRelationFormat.format(): Relation.Format = when (this) { + MRelationFormat.shorttext -> Relation.Format.SHORT_TEXT + MRelationFormat.longtext -> Relation.Format.LONG_TEXT + MRelationFormat.number -> Relation.Format.NUMBER + MRelationFormat.date -> Relation.Format.DATE + MRelationFormat.file_ -> Relation.Format.FILE + MRelationFormat.checkbox -> Relation.Format.CHECKBOX + MRelationFormat.url -> Relation.Format.URL + MRelationFormat.email -> Relation.Format.EMAIL + MRelationFormat.phone -> Relation.Format.PHONE + MRelationFormat.emoji -> Relation.Format.EMOJI + MRelationFormat.object_ -> Relation.Format.OBJECT + MRelationFormat.status -> Relation.Format.STATUS + MRelationFormat.tag -> Relation.Format.TAG + MRelationFormat.relations -> Relation.Format.RELATIONS } fun MRelationOption.option(): Relation.Option = Relation.Option( @@ -479,16 +456,25 @@ fun ObjectInfo.toCoreModel(): DocumentInfo = DocumentInfo( fields = details.toCoreModel(), snippet = snippet, hasInboundLinks = hasInboundLinks, - type = objectType.toCoreModel() + smartBlockType = objectType.toCoreModel() ) -fun ObjectInfo.Type.toCoreModel(): DocumentInfo.Type = when (this) { - ObjectInfo.Type.Page -> DocumentInfo.Type.PAGE - ObjectInfo.Type.Home -> DocumentInfo.Type.HOME - ObjectInfo.Type.ProfilePage -> DocumentInfo.Type.PROFILE_PAGE - ObjectInfo.Type.Archive -> DocumentInfo.Type.ARCHIVE - ObjectInfo.Type.Set -> DocumentInfo.Type.SET - ObjectInfo.Type.File -> DocumentInfo.Type.FILE - ObjectInfo.Type.ObjectType -> DocumentInfo.Type.OBJECT_TYPE - ObjectInfo.Type.Relation -> DocumentInfo.Type.RELATION +fun MSmartBlockType.toCoreModel(): SmartBlockType = when (this) { + MSmartBlockType.Breadcrumbs -> SmartBlockType.BREADCRUMBS + MSmartBlockType.Page -> SmartBlockType.PAGE + MSmartBlockType.ProfilePage -> SmartBlockType.PROFILE_PAGE + MSmartBlockType.Home -> SmartBlockType.HOME + MSmartBlockType.Archive -> SmartBlockType.ARCHIVE + MSmartBlockType.Database -> SmartBlockType.DATABASE + MSmartBlockType.Set -> SmartBlockType.SET + MSmartBlockType.STObjectType -> SmartBlockType.CUSTOM_OBJECT_TYPE + MSmartBlockType.File -> SmartBlockType.FILE + MSmartBlockType.Template -> SmartBlockType.TEMPLATE + MSmartBlockType.MarketplaceType -> SmartBlockType.MARKETPLACE_TYPE + MSmartBlockType.MarketplaceRelation -> SmartBlockType.MARKETPLACE_RELATION + MSmartBlockType.MarketplaceTemplate -> SmartBlockType.MARKETPLACE_TEMPLATE + MSmartBlockType.BundledRelation -> SmartBlockType.BUNDLED_RELATION + MSmartBlockType.IndexedRelation -> SmartBlockType.INDEXED_RELATION + MSmartBlockType.BundledObjectType -> SmartBlockType.BUNDLED_OBJECT_TYPE + MSmartBlockType.AnytypeProfile -> SmartBlockType.ANYTYPE_PROFILE } diff --git a/middleware/src/test/java/com/anytypeio/anytype/MiddlewareEventChannelTest.kt b/middleware/src/test/java/com/anytypeio/anytype/MiddlewareEventChannelTest.kt index ce83c44538..290b2639a1 100644 --- a/middleware/src/test/java/com/anytypeio/anytype/MiddlewareEventChannelTest.kt +++ b/middleware/src/test/java/com/anytypeio/anytype/MiddlewareEventChannelTest.kt @@ -1,11 +1,11 @@ package com.anytypeio.anytype -import anytype.SmartBlockType import anytype.model.Block import com.anytypeio.anytype.common.MockDataFactory import com.anytypeio.anytype.core_models.Event import com.anytypeio.anytype.middleware.EventProxy import com.anytypeio.anytype.middleware.interactor.MiddlewareEventChannel +import com.anytypeio.anytype.middleware.mappers.MSmartBlockType import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.runBlocking @@ -38,7 +38,7 @@ class MiddlewareEventChannelTest { val msg = anytype.Event.Object.Show( rootId = context, blocks = emptyList(), - type = SmartBlockType.Page + type = MSmartBlockType.Page ) val message = anytype.Event.Message(objectShow = msg) @@ -103,7 +103,7 @@ class MiddlewareEventChannelTest { val msg = anytype.Event.Object.Show( rootId = context, blocks = emptyList(), - type = SmartBlockType.Page + type = MSmartBlockType.Page ) val message = anytype.Event.Message(objectShow = msg) diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/desktop/HomeDashboardEventConverter.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/desktop/HomeDashboardEventConverter.kt index 4b0cf306b0..15995de84e 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/desktop/HomeDashboardEventConverter.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/desktop/HomeDashboardEventConverter.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.presentation.desktop import com.anytypeio.anytype.core_models.Event +import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.domain.misc.UrlBuilder interface HomeDashboardEventConverter { @@ -19,7 +20,7 @@ interface HomeDashboardEventConverter { builder = builder ) is Event.Command.ShowBlock -> when (event.type) { - Event.Command.ShowBlock.Type.HOME -> { + SmartBlockType.HOME -> { HomeDashboardStateMachine.Event.OnShowDashboard( blocks = event.blocks, context = event.context, @@ -29,7 +30,7 @@ interface HomeDashboardEventConverter { objectTypes = event.objectTypes ) } - Event.Command.ShowBlock.Type.PROFILE_PAGE -> { + SmartBlockType.PROFILE_PAGE -> { HomeDashboardStateMachine.Event.OnShowProfile( blocks = event.blocks, context = event.context, diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/mapper/MapperExtension.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/mapper/MapperExtension.kt index 758fe70562..481b555d5e 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/mapper/MapperExtension.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/mapper/MapperExtension.kt @@ -12,7 +12,6 @@ import com.anytypeio.anytype.presentation.page.editor.model.BlockView import com.anytypeio.anytype.presentation.page.editor.model.UiBlock import com.anytypeio.anytype.presentation.sets.buildGridRow import com.anytypeio.anytype.presentation.sets.model.* -import com.anytypeio.anytype.presentation.sets.model.Viewer import com.anytypeio.anytype.presentation.settings.EditorSettings import timber.log.Timber @@ -273,7 +272,7 @@ fun List.toDashboardViews( when (val content = block.content) { is Block.Content.Smart -> { when (content.type) { - Block.Content.Smart.Type.PROFILE -> { + SmartBlockType.PROFILE_PAGE -> { DashboardView.Profile( id = block.id, name = details.details[block.id]?.name.orEmpty(), diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/page/PageViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/page/PageViewModel.kt index b66801f62b..aa25040ccd 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/page/PageViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/page/PageViewModel.kt @@ -973,7 +973,7 @@ class PageViewModel( val content = root.content check(content is Content.Smart) when (content.type) { - Content.Smart.Type.PROFILE -> { + SmartBlockType.PROFILE_PAGE -> { val details = orchestrator.stores.details.current().details dispatch( command = Command.OpenProfileMenu( @@ -1002,7 +1002,7 @@ class PageViewModel( eventName = POPUP_PROFILE_MENU ) } - Content.Smart.Type.PAGE -> { + SmartBlockType.PAGE -> { val details = orchestrator.stores.details.current().details controlPanelInteractor.onEvent(ControlPanelMachine.Event.OnDocumentMenuClicked) dispatch( diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/page/render/DefaultBlockViewRenderer.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/page/render/DefaultBlockViewRenderer.kt index 4cf2c199ab..fcd0b502f9 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/page/render/DefaultBlockViewRenderer.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/page/render/DefaultBlockViewRenderer.kt @@ -40,7 +40,7 @@ class DefaultBlockViewRenderer( if (anchor == root.id) { root.content.let { cnt -> - if (cnt is Content.Smart && cnt.type == Content.Smart.Type.ARCHIVE) { + if (cnt is Content.Smart && cnt.type == SmartBlockType.ARCHIVE) { result.add( BlockView.Title.Archive( mode = BlockView.Mode.READ, @@ -807,7 +807,7 @@ class DefaultBlockViewRenderer( if (layout == null) { // Retrieving layout based on smart block type: - layout = if (rootContent.type == Content.Smart.Type.PROFILE) + layout = if (rootContent.type == SmartBlockType.PROFILE_PAGE) Layout.PROFILE else { // Falling back to default layout if layout is not defined diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/MockBlockFactory.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/MockBlockFactory.kt index 570ad4d1d3..019e892c40 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/MockBlockFactory.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/MockBlockFactory.kt @@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation import MockDataFactory import com.anytypeio.anytype.core_models.Block +import com.anytypeio.anytype.core_models.SmartBlockType object MockBlockFactory { @@ -13,9 +14,7 @@ object MockBlockFactory { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(child) ), Block( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/MockTypicalDocumentFactory.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/MockTypicalDocumentFactory.kt index ad6addd399..4bda8d653d 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/MockTypicalDocumentFactory.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/MockTypicalDocumentFactory.kt @@ -40,9 +40,7 @@ object MockTypicalDocumentFactory { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(SmartBlockType.PAGE), children = listOf(header.id, a.id) ) return listOf(page, header, title, a) @@ -52,9 +50,7 @@ object MockTypicalDocumentFactory { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PROFILE - ), + content = Block.Content.Smart(SmartBlockType.PROFILE_PAGE), children = listOf(header.id, a.id) ) return listOf(page, header, title, a) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/home/DashboardDragAndDropTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/DashboardDragAndDropTest.kt index 71377a897d..5b9a725df4 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/home/DashboardDragAndDropTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/DashboardDragAndDropTest.kt @@ -1,10 +1,7 @@ package com.anytypeio.anytype.presentation.home import MockDataFactory -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.Event -import com.anytypeio.anytype.core_models.Payload -import com.anytypeio.anytype.core_models.Position +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.core_utils.ext.shift import com.anytypeio.anytype.domain.base.Either import com.anytypeio.anytype.domain.block.interactor.Move @@ -34,9 +31,7 @@ class DashboardDragAndDropTest : DashboardTestSetup() { val profile = Block( id = MockDataFactory.randomUuid(), children = emptyList(), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PROFILE - ), + content = Block.Content.Smart(SmartBlockType.HOME), fields = Block.Fields.empty() ) @@ -74,9 +69,7 @@ class DashboardDragAndDropTest : DashboardTestSetup() { val dashboard = Block( id = config.home, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.HOME - ), + content = Block.Content.Smart(SmartBlockType.HOME), children = pages.map { page -> page.id }, fields = Block.Fields.empty() ) @@ -91,7 +84,7 @@ class DashboardDragAndDropTest : DashboardTestSetup() { root = config.home, context = config.home, blocks = listOf(dashboard) + profile + pages, - type = Event.Command.ShowBlock.Type.HOME + type = SmartBlockType.HOME ) ) ) @@ -184,9 +177,7 @@ class DashboardDragAndDropTest : DashboardTestSetup() { val dashboard = Block( id = config.home, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.HOME - ), + content = Block.Content.Smart(SmartBlockType.HOME), children = pages.map { page -> page.id }, fields = Block.Fields.empty() ) @@ -283,9 +274,7 @@ class DashboardDragAndDropTest : DashboardTestSetup() { val dashboard = Block( id = config.home, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.HOME - ), + content = Block.Content.Smart(SmartBlockType.HOME), children = links.map { page -> page.id }, fields = Block.Fields.empty() ) @@ -382,9 +371,7 @@ class DashboardDragAndDropTest : DashboardTestSetup() { val dashboard = Block( id = config.home, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.HOME - ), + content = Block.Content.Smart(SmartBlockType.HOME), children = links.map { page -> page.id }, fields = Block.Fields.empty() ) @@ -481,9 +468,7 @@ class DashboardDragAndDropTest : DashboardTestSetup() { val dashboard = Block( id = config.home, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.HOME - ), + content = Block.Content.Smart(SmartBlockType.HOME), children = links.map { page -> page.id }, fields = Block.Fields.empty() ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeDashboardViewModelTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeDashboardViewModelTest.kt index 6a3cfaf710..1066d5557b 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeDashboardViewModelTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeDashboardViewModelTest.kt @@ -3,10 +3,7 @@ package com.anytypeio.anytype.presentation.home import MockDataFactory import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.analytics.base.Analytics -import com.anytypeio.anytype.core_models.Block -import com.anytypeio.anytype.core_models.Config -import com.anytypeio.anytype.core_models.Event -import com.anytypeio.anytype.core_models.Payload +import com.anytypeio.anytype.core_models.* import com.anytypeio.anytype.core_models.ext.getChildrenIdsList import com.anytypeio.anytype.domain.auth.interactor.GetProfile import com.anytypeio.anytype.domain.base.Either @@ -215,9 +212,7 @@ class HomeDashboardViewModelTest { val dashboard = Block( id = config.home, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.HOME - ), + content = Block.Content.Smart(SmartBlockType.HOME), children = listOf(page.id), fields = Block.Fields.empty() ) @@ -234,7 +229,7 @@ class HomeDashboardViewModelTest { root = config.home, context = config.home, blocks = listOf(dashboard, page), - type = Event.Command.ShowBlock.Type.HOME + type = SmartBlockType.HOME ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/BlockReadModeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/BlockReadModeTest.kt index b3fb2a7632..01972e8f07 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/BlockReadModeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/BlockReadModeTest.kt @@ -46,9 +46,7 @@ class BlockReadModeTest : PageViewModelTest() { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) + blocks.map { it.id } ) ) + listOf(header, title) + blocks diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/DefaultBlockViewRendererTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/DefaultBlockViewRendererTest.kt index 0d5654196a..d2763afdd3 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/DefaultBlockViewRendererTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/DefaultBlockViewRendererTest.kt @@ -3,6 +3,7 @@ package com.anytypeio.anytype.presentation.page import MockDataFactory import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Id +import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.core_models.ext.asMap import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.core_utils.tools.Counter @@ -132,9 +133,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, paragraph.id, toggle.id), fields = Block.Fields.empty(), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ) + content = Block.Content.Smart() ) val blocks = listOf(page, header, title, paragraph, toggle, checkbox) @@ -253,9 +252,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, paragraph.id, toggle.id), fields = Block.Fields.empty(), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ) + content = Block.Content.Smart() ) val blocks = listOf(page, header, title, paragraph, toggle, checkbox) @@ -361,9 +358,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, paragraph.id), fields = Block.Fields.empty(), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ) + content = Block.Content.Smart() ) val blocks = listOf(page, header, title, paragraph) @@ -445,9 +440,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, paragraph.id), fields = Block.Fields.empty(), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ) + content = Block.Content.Smart() ) val blocks = listOf(page, header, title, paragraph) @@ -540,9 +533,7 @@ class DefaultBlockViewRendererTest { id = pageId, children = listOf(header.id, paragraph.id), fields = fields, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PROFILE - ) + content = Block.Content.Smart(SmartBlockType.PROFILE_PAGE) ) val blocks = listOf(page, header, title, paragraph) @@ -635,9 +626,7 @@ class DefaultBlockViewRendererTest { id = pageId, children = listOf(header.id, paragraph.id), fields = fields, - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ) + content = Block.Content.Smart() ) val blocks = listOf(page, header, title, paragraph) @@ -820,7 +809,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, a.id), fields = fields, - content = Block.Content.Smart(type = Block.Content.Smart.Type.PAGE) + content = Block.Content.Smart() ) val details = mapOf(page.id to fields) @@ -951,7 +940,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, a.id), fields = fields, - content = Block.Content.Smart(type = Block.Content.Smart.Type.PAGE) + content = Block.Content.Smart() ) val details = mapOf(page.id to fields) @@ -1079,7 +1068,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, a.id), fields = fields, - content = Block.Content.Smart(type = Block.Content.Smart.Type.PAGE) + content = Block.Content.Smart() ) val details = mapOf(page.id to fields) @@ -1219,7 +1208,7 @@ class DefaultBlockViewRendererTest { id = MockDataFactory.randomUuid(), children = listOf(header.id, a.id), fields = fields, - content = Block.Content.Smart(type = Block.Content.Smart.Type.PAGE) + content = Block.Content.Smart() ) val details = mapOf(page.id to fields) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/PageViewModelTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/PageViewModelTest.kt index 919fb3ba45..de5283384b 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/PageViewModelTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/PageViewModelTest.kt @@ -286,9 +286,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ), header, @@ -473,9 +471,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ), header, @@ -566,9 +562,7 @@ open class PageViewModelTest { val smart = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(child) ) @@ -630,9 +624,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ), header, @@ -736,9 +728,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ) @@ -892,9 +882,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ) @@ -1052,9 +1040,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(child) ) @@ -1146,9 +1132,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ) @@ -1248,7 +1232,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(child) ) @@ -1329,7 +1313,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(child) ) @@ -1491,9 +1475,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ) @@ -1662,9 +1644,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child.id) ) @@ -1742,9 +1722,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, firstChild.id, secondChild.id) ) @@ -1851,9 +1829,7 @@ open class PageViewModelTest { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child.id) ) @@ -2350,9 +2326,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(child) ), Block( @@ -2484,9 +2458,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(title.id, file.id) ), title, @@ -2547,7 +2519,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -2614,7 +2586,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -2668,7 +2640,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -2726,7 +2698,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -2793,7 +2765,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -2853,7 +2825,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -2913,7 +2885,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -2978,7 +2950,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -3043,9 +3015,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(title.id) ), title @@ -3099,7 +3069,7 @@ open class PageViewModelTest { fields = Block.Fields( map = mapOf("icon" to "") ), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id) ), title @@ -3181,7 +3151,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -3260,7 +3230,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, numbered.id) ), title, @@ -3341,7 +3311,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(title.id, paragraph.id) ), title, @@ -3402,7 +3372,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(paragraph.id) ), paragraph @@ -3520,7 +3490,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(header.id) + paragraphs.map { it.id } ) ) + listOf(header, title) + paragraphs @@ -3694,7 +3664,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(header.id) + paragraphs.map { it.id } ) ) + listOf(header, title) + paragraphs @@ -4038,7 +4008,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(header.id) + paragraphs.map { it.id } ) ) + listOf(header, title) + paragraphs @@ -4153,9 +4123,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) + paragraphs.map { it.id } ) ) + listOf(header, title) + paragraphs @@ -4278,7 +4246,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(header.id) + paragraphs.map { it.id } ) ) + listOf(header, title) + paragraphs @@ -4421,7 +4389,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(header.id) + paragraphs.map { it.id } ) ) + listOf(header, title) + paragraphs @@ -4562,9 +4530,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart( - Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) + paragraphs.map { it.id } ) ) + listOf(header, title) + paragraphs @@ -4697,7 +4663,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = blocks.map { it.id } ) ) + blocks @@ -4879,7 +4845,7 @@ open class PageViewModelTest { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = blocks.map { it.id } ) ) + blocks diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorAddBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorAddBlockTest.kt index 757ca7958d..9a43a9c83f 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorAddBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorAddBlockTest.kt @@ -50,9 +50,7 @@ class EditorAddBlockTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ), block @@ -113,9 +111,7 @@ class EditorAddBlockTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(block.id) ), block diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorBackspaceNestedDeleteTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorBackspaceNestedDeleteTest.kt index 06aac4126d..a23d345d13 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorBackspaceNestedDeleteTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorBackspaceNestedDeleteTest.kt @@ -80,9 +80,7 @@ class EditorBackspaceNestedDeleteTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, parent.id) ) @@ -209,9 +207,7 @@ class EditorBackspaceNestedDeleteTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, parent.id) ) @@ -355,9 +351,7 @@ class EditorBackspaceNestedDeleteTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, parent.id) ) @@ -506,9 +500,7 @@ class EditorBackspaceNestedDeleteTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, parent.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEmptySpaceInteractionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEmptySpaceInteractionTest.kt index ea2b1bae8a..222eb00860 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEmptySpaceInteractionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEmptySpaceInteractionTest.kt @@ -66,9 +66,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -121,9 +119,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEventSubscriptionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEventSubscriptionTest.kt index 7893fd7bd8..ee7b4c49a0 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEventSubscriptionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorEventSubscriptionTest.kt @@ -45,9 +45,7 @@ class EditorEventSubscriptionTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorFocusTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorFocusTest.kt index 20a5c78357..597b444f80 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorFocusTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorFocusTest.kt @@ -66,7 +66,7 @@ class EditorFocusTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ), header, @@ -133,9 +133,7 @@ class EditorFocusTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ), header, diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorGranularChangeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorGranularChangeTest.kt index 3413a9ceb0..6e3b6f0d30 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorGranularChangeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorGranularChangeTest.kt @@ -71,9 +71,7 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, checkbox.id) ), header, diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorListBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorListBlockTest.kt index b3a7ae5cad..8d50c497d0 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorListBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorListBlockTest.kt @@ -290,9 +290,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ), header, @@ -429,9 +427,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ), header, @@ -567,9 +563,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ), header, @@ -706,9 +700,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, child) ), header, diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMentionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMentionTest.kt index 83d9813553..4e47e3345b 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMentionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMentionTest.kt @@ -105,9 +105,7 @@ class EditorMentionTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) @@ -263,9 +261,7 @@ class EditorMentionTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) @@ -431,9 +427,7 @@ class EditorMentionTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) @@ -567,9 +561,7 @@ class EditorMentionTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMergeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMergeTest.kt index c7490c381a..ff56ab030a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMergeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMergeTest.kt @@ -78,9 +78,7 @@ class EditorMergeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, first.id, second.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMoveToTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMoveToTest.kt index 7eb33a8328..81158d3f0f 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMoveToTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMoveToTest.kt @@ -68,9 +68,7 @@ class EditorMoveToTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, link.id) ) @@ -128,9 +126,7 @@ class EditorMoveToTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, txt.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMultiSelectModeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMultiSelectModeTest.kt index 899b8ad6e0..52af2ce667 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMultiSelectModeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorMultiSelectModeTest.kt @@ -76,9 +76,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) @@ -296,9 +294,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) @@ -502,9 +498,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, parent.id) ) @@ -717,9 +711,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, parent.id) ) @@ -926,9 +918,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, parent.id) ) @@ -1015,9 +1005,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) @@ -1090,9 +1078,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorQuickStartingScrollAndMoveTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorQuickStartingScrollAndMoveTest.kt index 6c46192cf2..35071c2810 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorQuickStartingScrollAndMoveTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorQuickStartingScrollAndMoveTest.kt @@ -80,9 +80,7 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) @@ -185,9 +183,7 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) @@ -291,9 +287,7 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorRelationBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorRelationBlockTest.kt index c7a3265c0b..9ffe600c07 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorRelationBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorRelationBlockTest.kt @@ -85,9 +85,7 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorScrollAndMoveTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorScrollAndMoveTest.kt index 6b0898df28..48133aa0f4 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorScrollAndMoveTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorScrollAndMoveTest.kt @@ -77,9 +77,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id, c.id) ) @@ -173,9 +171,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id, c.id) ) @@ -248,9 +244,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id) ) @@ -363,9 +357,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id, c.id) ) @@ -453,9 +445,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id) ) @@ -526,9 +516,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id) ) @@ -599,9 +587,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id) ) @@ -674,9 +660,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(parent.id) ) @@ -771,9 +755,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(parent.id, block.id) ) @@ -902,9 +884,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id, c.id, d.id, e.id, f.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetActionsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetActionsTest.kt index 506b464f9f..e02a133721 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetActionsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetActionsTest.kt @@ -579,9 +579,7 @@ class EditorSlashWidgetActionsTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetClicksTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetClicksTest.kt index be10c2a964..c76fab2f80 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetClicksTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetClicksTest.kt @@ -7,9 +7,9 @@ import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory import com.anytypeio.anytype.presentation.page.editor.model.Types -import com.anytypeio.anytype.presentation.page.editor.slash.SlashWidgetState import com.anytypeio.anytype.presentation.page.editor.slash.SlashEvent import com.anytypeio.anytype.presentation.page.editor.slash.SlashItem +import com.anytypeio.anytype.presentation.page.editor.slash.SlashWidgetState import com.anytypeio.anytype.presentation.relations.DocumentRelationView import com.anytypeio.anytype.presentation.relations.NumberParser import com.anytypeio.anytype.presentation.relations.RelationListViewModel @@ -202,9 +202,7 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -390,9 +388,7 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, a.id, b.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetColorTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetColorTest.kt index 6670b29d36..5c7d9ad06a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetColorTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetColorTest.kt @@ -9,9 +9,9 @@ import com.anytypeio.anytype.domain.block.interactor.UpdateTextColor import com.anytypeio.anytype.domain.editor.Editor import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory import com.anytypeio.anytype.presentation.page.PageViewModel -import com.anytypeio.anytype.presentation.page.editor.slash.SlashWidgetState import com.anytypeio.anytype.presentation.page.editor.slash.SlashEvent import com.anytypeio.anytype.presentation.page.editor.slash.SlashItem +import com.anytypeio.anytype.presentation.page.editor.slash.SlashWidgetState import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import org.junit.Before import org.junit.Rule @@ -65,9 +65,7 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -152,9 +150,7 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -239,9 +235,7 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -449,9 +443,7 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -536,9 +528,7 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -623,9 +613,7 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetMarksTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetMarksTest.kt index e74639d670..ab011a67d8 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetMarksTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetMarksTest.kt @@ -142,9 +142,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id, block3.id) ) @@ -233,9 +231,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id, block3.id) ) @@ -366,9 +362,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id, block3.id) ) @@ -441,9 +435,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id) ) @@ -574,9 +566,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id, block3.id) ) @@ -649,9 +639,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id) ) @@ -782,9 +770,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id, block3.id) ) @@ -857,9 +843,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetStyleTypeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetStyleTypeTest.kt index 5e467fbf98..db84b9d58e 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetStyleTypeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorSlashWidgetStyleTypeTest.kt @@ -72,9 +72,7 @@ class EditorSlashWidgetStyleTypeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id) ) @@ -203,9 +201,7 @@ class EditorSlashWidgetStyleTypeTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id, block2.id, block3.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorStartupTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorStartupTest.kt index 61158fec92..fccd44a87a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorStartupTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorStartupTest.kt @@ -31,9 +31,7 @@ class EditorStartupTest : EditorPresentationTestSetup() { Block( id = "some id", fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = emptyList() ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTextUpdateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTextUpdateTest.kt index 7ec6607263..4c9fd8e3e8 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTextUpdateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTextUpdateTest.kt @@ -72,9 +72,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -148,9 +146,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -223,9 +219,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -299,9 +293,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleAddBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleAddBlockTest.kt index fa4c73b582..fd27330ddd 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleAddBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleAddBlockTest.kt @@ -60,9 +60,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -117,9 +115,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -163,9 +159,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -216,9 +210,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -258,9 +250,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -319,9 +309,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -369,9 +357,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -423,9 +409,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) @@ -466,9 +450,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -520,9 +502,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id, block.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleTest.kt index 460419022a..b2d6f9df7e 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTitleTest.kt @@ -62,9 +62,7 @@ class EditorTitleTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -113,9 +111,7 @@ class EditorTitleTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(header.id) ) @@ -182,7 +178,7 @@ class EditorTitleTest : EditorPresentationTestSetup() { Block( id = root, fields = Block.Fields.empty(), - content = Block.Content.Smart(Block.Content.Smart.Type.PAGE), + content = Block.Content.Smart(), children = listOf(header.id) ), header, diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTurnIntoTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTurnIntoTest.kt index ddc3332088..bcf4ad6655 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTurnIntoTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/EditorTurnIntoTest.kt @@ -63,9 +63,7 @@ class EditorTurnIntoTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(parent.id) ) @@ -127,9 +125,7 @@ class EditorTurnIntoTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(parent.id) ) @@ -188,9 +184,7 @@ class EditorTurnIntoTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(a.id, b.id) ) @@ -300,9 +294,7 @@ class EditorTurnIntoTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(parent.id) ) @@ -397,9 +389,7 @@ class EditorTurnIntoTest : EditorPresentationTestSetup() { val page = Block( id = root, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart( - type = Block.Content.Smart.Type.PAGE - ), + content = Block.Content.Smart(), children = listOf(parent.id) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/StyleConfigKtTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/StyleConfigKtTest.kt index bb5ee36411..36abb5aa8e 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/StyleConfigKtTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/page/editor/StyleConfigKtTest.kt @@ -64,7 +64,7 @@ class StyleConfigKtTest { val given = Block( id = child, fields = Block.Fields(emptyMap()), - content = Block.Content.Smart(type = Block.Content.Smart.Type.HOME), + content = Block.Content.Smart(), children = emptyList() ) diff --git a/protocol/src/main/proto/block.proto b/protocol/src/main/proto/block.proto new file mode 100644 index 0000000000..b3a1bfd498 --- /dev/null +++ b/protocol/src/main/proto/block.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package anytype.storage; +option go_package = "pkg/lib/pb/storage"; + +import "models.proto"; +import "file.proto"; +import "google/protobuf/struct.proto"; + +message SmartBlockSnapshot { + map state = 1; + repeated anytype.model.Block blocks = 2; + google.protobuf.Struct details = 3; + map keysByHash = 4; + int64 clientTime = 5; +} diff --git a/protocol/src/main/proto/changes.proto b/protocol/src/main/proto/changes.proto index 35d48ce66f..c37f9fd251 100644 --- a/protocol/src/main/proto/changes.proto +++ b/protocol/src/main/proto/changes.proto @@ -3,8 +3,6 @@ package anytype; option go_package = "pb"; import "models.proto"; -import "relation.proto"; - import "events.proto"; import "google/protobuf/struct.proto"; @@ -93,12 +91,12 @@ message Change { } message RelationAdd { - anytype.relation.Relation relation = 2; + anytype.model.Relation relation = 2; } message RelationUpdate { message Dict { - repeated anytype.relation.Relation.Option dict = 2; + repeated anytype.model.Relation.Option dict = 2; } message ObjectTypes { @@ -107,7 +105,7 @@ message Change { string key = 1; oneof value { - anytype.relation.RelationFormat format = 2; + anytype.model.RelationFormat format = 2; string name = 3; google.protobuf.Value defaultValue = 4; ObjectTypes objectTypes = 5; diff --git a/protocol/src/main/proto/commands.proto b/protocol/src/main/proto/commands.proto index a956485980..5b789374b5 100644 --- a/protocol/src/main/proto/commands.proto +++ b/protocol/src/main/proto/commands.proto @@ -4,7 +4,6 @@ option go_package = "pb"; import "models.proto"; import "localstore.proto"; -import "relation.proto"; import "events.proto"; import "google/protobuf/struct.proto"; @@ -1122,7 +1121,7 @@ message Rpc { message Request { string contextId = 1; string blockId = 2; - anytype.relation.Relation relation = 3; + anytype.model.Relation relation = 3; } message Response { @@ -1431,14 +1430,14 @@ message Rpc { message Request { string contextId = 1; string blockId = 2; // id of dataview block to add relation - anytype.relation.Relation relation = 3; + anytype.model.Relation relation = 3; } message Response { Error error = 1; ResponseEvent event = 2; string relationKey = 3; // deprecated - anytype.relation.Relation relation = 4; + anytype.model.Relation relation = 4; message Error { Code code = 1; @@ -1457,7 +1456,7 @@ message Rpc { string contextId = 1; string blockId = 2; // id of dataview block to add relation string relationKey = 3; // key of relation to update - anytype.relation.Relation relation = 4; + anytype.model.Relation relation = 4; } message Response { @@ -1506,14 +1505,14 @@ message Rpc { string contextId = 1; string blockId = 2; // id of dataview block to add relation string relationKey = 3; // relation key to add the option - anytype.relation.Relation.Option option = 4; // id of select options will be autogenerated + anytype.model.Relation.Option option = 4; // id of select options will be autogenerated string recordId = 5; // id of record which is used to add an option } message Response { Error error = 1; ResponseEvent event = 2; - anytype.relation.Relation.Option option = 3; + anytype.model.Relation.Option option = 3; message Error { Code code = 1; @@ -1532,7 +1531,7 @@ message Rpc { string contextId = 1; string blockId = 2; // id of dataview block to add relation string relationKey = 3; // relation key to add the option - anytype.relation.Relation.Option option = 4; // id of select options will be autogenerated + anytype.model.Relation.Option option = 4; // id of select options will be autogenerated string recordId = 5; // id of record which is used to update an option } @@ -1586,7 +1585,7 @@ message Rpc { message Response { Error error = 1; - repeated anytype.relation.Relation relations = 2; + repeated anytype.model.Relation relations = 2; message Error { Code code = 1; @@ -2723,7 +2722,7 @@ message Rpc { message Response { Error error = 1; - repeated anytype.relation.ObjectType objectTypes = 2; + repeated anytype.model.ObjectType objectTypes = 2; message Error { Code code = 1; @@ -2741,12 +2740,12 @@ message Rpc { message Create { message Request { - anytype.relation.ObjectType objectType = 1; + anytype.model.ObjectType objectType = 1; } message Response { Error error = 1; - anytype.relation.ObjectType objectType = 2; + anytype.model.ObjectType objectType = 2; message Error { Code code = 1; @@ -2767,12 +2766,12 @@ message Rpc { message Add { message Request { string objectTypeUrl = 1; - repeated anytype.relation.Relation relations = 2; + repeated anytype.model.Relation relations = 2; } message Response { Error error = 1; - repeated anytype.relation.Relation relations = 2; + repeated anytype.model.Relation relations = 2; message Error { Code code = 1; @@ -2816,7 +2815,7 @@ message Rpc { message Update { message Request { string objectTypeUrl = 1; - anytype.relation.Relation relation = 2; + anytype.model.Relation relation = 2; } message Response { @@ -2845,7 +2844,7 @@ message Rpc { message Response { Error error = 1; - repeated anytype.relation.Relation relations = 2; + repeated anytype.model.Relation relations = 2; message Error { Code code = 1; @@ -2868,14 +2867,14 @@ message Rpc { message RelationAdd { message Request { string contextId = 1; - anytype.relation.Relation relation = 2; + anytype.model.Relation relation = 2; } message Response { Error error = 1; ResponseEvent event = 2; string relationKey = 3; // deprecated - anytype.relation.Relation relation = 4; + anytype.model.Relation relation = 4; message Error { Code code = 1; @@ -2893,7 +2892,7 @@ message Rpc { message Request { string contextId = 1; string relationKey = 2; // key of relation to update - anytype.relation.Relation relation = 3; + anytype.model.Relation relation = 3; } message Response { @@ -2940,13 +2939,13 @@ message Rpc { message Request { string contextId = 1; string relationKey = 2; // relation key to add the option - anytype.relation.Relation.Option option = 3; // id of select options will be autogenerated + anytype.model.Relation.Option option = 3; // id of select options will be autogenerated } message Response { Error error = 1; ResponseEvent event = 2; - anytype.relation.Relation.Option option = 3; + anytype.model.Relation.Option option = 3; message Error { Code code = 1; @@ -2964,7 +2963,7 @@ message Rpc { message Request { string contextId = 1; string relationKey = 2; // relation key to add the option - anytype.relation.Relation.Option option = 3; // id of select options will be autogenerated + anytype.model.Relation.Option option = 3; // id of select options will be autogenerated } message Response { @@ -3014,7 +3013,7 @@ message Rpc { } message Response { Error error = 1; - repeated anytype.relation.Relation relations = 2; + repeated anytype.model.Relation relations = 2; message Error { Code code = 1; @@ -3036,6 +3035,7 @@ message Rpc { string fullText = 3; int32 offset = 4; int32 limit = 5; + repeated string objectTypeFilter = 6; } message Response { diff --git a/protocol/src/main/proto/events.proto b/protocol/src/main/proto/events.proto index c43412925b..813057373c 100644 --- a/protocol/src/main/proto/events.proto +++ b/protocol/src/main/proto/events.proto @@ -3,8 +3,6 @@ package anytype; option go_package = "pb"; import "models.proto"; -import "relation.proto"; - import "google/protobuf/struct.proto"; /* @@ -115,12 +113,12 @@ message Event { message Relations { message Set { string id = 1; // context objectId - repeated anytype.relation.Relation relations = 2; + repeated anytype.model.Relation relations = 2; } message Amend { string id = 1; // context objectId - repeated anytype.relation.Relation relations = 2; + repeated anytype.model.Relation relations = 2; } message Remove { @@ -133,7 +131,7 @@ message Event { message Set { string id = 1; // context objectId string relationKey = 2; - anytype.relation.Relation relation = 3; // missing value means relation should be removed + anytype.model.Relation relation = 3; // missing value means relation should be removed } message Remove { string id = 1; // context objectId @@ -149,15 +147,15 @@ message Event { string rootId = 1; // Root block id repeated anytype.model.Block blocks = 2; // dependent simple blocks (descendants) repeated Object.Details.Set details = 3; // details for the current and dependent objects - SmartBlockType type = 4; + model.SmartBlockType type = 4; message RelationWithValuePerObject { string objectId = 1; - repeated anytype.relation.RelationWithValue relations = 2; + repeated anytype.model.RelationWithValue relations = 2; } - repeated anytype.relation.ObjectType objectTypes = 5; // objectTypes contains ONLY to get layouts for the actual and all dependent objects. Relations are currently omitted // todo: switch to other pb model - repeated anytype.relation.Relation relations = 7; // combined relations of object's type + extra relations. If object doesn't has some relation key in the details this means client should hide it and only suggest when adding existing one + repeated anytype.model.ObjectType objectTypes = 5; // objectTypes contains ONLY to get layouts for the actual and all dependent objects. Relations are currently omitted // todo: switch to other pb model + repeated anytype.model.Relation relations = 7; // combined relations of object's type + extra relations. If object doesn't has some relation key in the details this means client should hide it and only suggest when adding existing one anytype.model.Restrictions restrictions = 8; // object restrictions } } @@ -573,7 +571,7 @@ message Event { message RelationSet { string id = 1; // dataview block's id string relationKey = 2; // relation key to update - anytype.relation.Relation relation = 3; + anytype.model.Relation relation = 3; } // sent when the active view's visible records should be replaced @@ -724,31 +722,6 @@ message Event { } } -enum SmartBlockType { - Breadcrumbs = 0; - - Page = 0x10; - ProfilePage = 0x11; - Home = 0x20; - Archive = 0x30; - Database = 0x40; - Set = 0x41; // only have dataview simpleblock - ObjectType = 0x60; // have relations list - - File = 0x100; - - Template = 0x120; - - MarketplaceType = 0x110; - MarketplaceRelation = 0x111; - MarketplaceTemplate = 0x112; - - BundledRelation = 0x200; - IndexedRelation = 0x201; - BundledObjectType = 0x202; - AnytypeProfile = 0x203; -} - message ResponseEvent { repeated Event.Message messages = 1; string contextId = 2; diff --git a/protocol/src/main/proto/file.proto b/protocol/src/main/proto/file.proto new file mode 100644 index 0000000000..37219f604c --- /dev/null +++ b/protocol/src/main/proto/file.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package anytype.storage; +option go_package = "pkg/lib/pb/storage"; + +import "google/protobuf/struct.proto"; + +message Step { + string name = 1; + Link link = 2; +} + +message FileKeys { + map keysByPath = 1; +} + +message FileInfo { + string mill = 1; + string checksum = 2; + string source = 3; + string opts = 4; + string hash = 5; + string key = 6; + string media = 7; + string name = 8; + int64 size = 9; + int64 added = 10; + google.protobuf.Struct meta = 11; + repeated string targets = 12; + EncryptionMode encMode = 13; + string metaHash = 14; + + enum EncryptionMode { + AES_GCM = 0; + AES_CFB = 1; + } +} + +message Directory { + map files = 1; +} + +message DirectoryList { + repeated Directory items = 1; +} + +message Node { + string name = 1; + bool pin = 2; + bool plaintext = 3; + string mill = 4; + map opts = 5; + google.protobuf.Struct json_schema = 6; + map links = 8; +} + +message Link { + string use = 1; + bool pin = 2; + bool plaintext = 3; + string mill = 4; + map opts = 5; + google.protobuf.Struct json_schema = 6; +} diff --git a/protocol/src/main/proto/localstore.proto b/protocol/src/main/proto/localstore.proto index ac874d95b3..8e6fb4bf68 100644 --- a/protocol/src/main/proto/localstore.proto +++ b/protocol/src/main/proto/localstore.proto @@ -3,29 +3,17 @@ package anytype.model; option go_package = "pkg/lib/pb/model"; import "google/protobuf/struct.proto"; -import "relation.proto"; +import "models.proto"; message ObjectInfo { string id = 1; repeated string objectTypeUrls = 2; google.protobuf.Struct details = 3; - anytype.relation.Relations relations = 4; + Relations relations = 4; string snippet = 5; bool hasInboundLinks = 6; - Type objectType = 7; - - enum Type { - Page = 0; - Home = 1; - ProfilePage = 2; - Archive = 3; - - Set = 5; - File = 6; - ObjectType = 7; - Relation = 8; - } + SmartBlockType objectType = 7; } message ObjectDetails { diff --git a/protocol/src/main/proto/models.proto b/protocol/src/main/proto/models.proto index 02604a5264..d9aba87ab9 100644 --- a/protocol/src/main/proto/models.proto +++ b/protocol/src/main/proto/models.proto @@ -2,18 +2,41 @@ syntax = "proto3"; package anytype.model; option go_package = "pkg/lib/pb/model"; -import "relation.proto"; import "google/protobuf/struct.proto"; -// deprecated message SmartBlockSnapshotBase { repeated Block blocks = 1; google.protobuf.Struct details = 2; google.protobuf.Struct fileKeys = 3; - repeated anytype.relation.Relation extraRelations = 4; + repeated Relation extraRelations = 4; repeated string objectTypes = 5; } +enum SmartBlockType { + Breadcrumbs = 0; + + Page = 0x10; + ProfilePage = 0x11; + Home = 0x20; + Archive = 0x30; + Database = 0x40; + Set = 0x41; // only have dataview simpleblock + STObjectType = 0x60; // have relations list + + File = 0x100; + + Template = 0x120; + + MarketplaceType = 0x110; + MarketplaceRelation = 0x111; + MarketplaceTemplate = 0x112; + + BundledRelation = 0x200; + IndexedRelation = 0x201; + BundledObjectType = 0x202; + AnytypeProfile = 0x203; +} + message Block { string id = 1; google.protobuf.Struct fields = 2; @@ -204,7 +227,7 @@ message Block { string source = 1; repeated View views = 2; // index 3 is deprecated, was used for schemaURL in old-format sets - repeated anytype.relation.Relation relations = 4; + repeated model.Relation relations = 4; string activeView = 3; // saved within a session message View { @@ -377,4 +400,116 @@ message Restrictions { } +message ObjectType { + string url = 1; // leave empty in case you want to create the new one + string name = 2; // name of objectType (can be localized for bundled types) + repeated Relation relations = 3; // cannot contain more than one Relation with the same RelationType + Layout layout = 4; + string iconEmoji = 5; // emoji symbol + string description = 6; + bool hidden = 7; + repeated SmartBlockType types = 8; + + enum Layout { + basic = 0; + profile = 1; + todo = 2; + set = 3; + objectType = 4; + relation = 5; + file = 6; + dashboard = 7; + image = 8; + + database = 20; // to be released later + } +} + +message Layout { + ObjectType.Layout id = 1; + string name = 2; + repeated Relation requiredRelations = 3; // relations required for this object type +} + +message RelationWithValue { + Relation relation = 1; + google.protobuf.Value value = 2; +} + +// Relation describe the human-interpreted relation type. It may be something like "Date of creation, format=date" or "Assignee, format=objectId, objectType=person" +message Relation { + // Key under which the value is stored in the map. Must be unique for the object type. + // It usually auto-generated bsonid, but also may be something human-readable in case of prebuilt types. + string key = 1; + + RelationFormat format = 2; // format of the underlying data + string name = 3; // name to show (can be localized for bundled types) + google.protobuf.Value defaultValue = 4; + DataSource dataSource = 5; // where the data is stored + + bool hidden = 6; // internal, not displayed to user (e.g. coverX, coverY) + bool readOnly = 7; // not editable by user + bool multi = 8; // allow multiple values (stored in pb list) + + repeated string objectTypes = 9; // URL of object type, empty to allow link to any object + // index 10, 11 was used in internal-only builds. Can be reused, but may break some test accounts + repeated Option selectDict = 12; // default dictionary with unique values to choose for select/multiSelect format + int32 maxCount = 13; // max number of values can be set for this relation. 0 means no limit. 1 means the value can be stored in non-repeated field + string description = 14; + + // on-store fields, injected only locally + Scope scope = 20; // scope from which this relation have been aggregated + string creator = 21; // creator profile id + + message Option { + string id = 1; // id generated automatically if omitted + string text = 2; + string color = 3; // stored + Scope scope = 4; // on-store contains only local-scope relations. All others injected on-the-fly + + enum Scope { + local = 0; // stored within the object/aggregated from set + relation = 1; // aggregated from all relation of this relation's key + format = 2; // aggregated from all relations of this relation's format + } + } + + enum Scope { + object = 0; // stored within the object + type = 1; // stored within the object type + setOfTheSameType = 2; // aggregated from the dataview of sets of the same object type + objectsOfTheSameType = 3; // aggregated from the dataview of sets of the same object type + library = 4; // aggregated from relations library + } + + enum DataSource { + details = 0; // default, stored inside the object's details + derived = 1; // stored locally, e.g. in badger or generated on the fly + account = 2; // stored in the account DB. means existing only for specific anytype account + } +} + +// RelationFormat describes how the underlying data is stored in the google.protobuf.Value and how it should be validated/sanitized +enum RelationFormat { + longtext = 0; // string + shorttext = 1; // string, usually short enough. May be truncated + number = 2; // double + status = 3; // string (choose one from a list) + tag = 11; // list of string (choose multiple from a list) + date = 4; // int64(pb.Value doesn't have int64) or string + file = 5; // relation can has objects of specific types: file, image, audio, video + checkbox = 6; // boolean + url = 7; // string with sanity check + email = 8; // string with sanity check + phone = 9; // string with sanity check + emoji = 10; // one emoji, can contains multiple utf-8 symbols + + object = 100; // relation can has objectType to specify objectType + relations = 101; // base64-encoded + +} + +message Relations { + repeated Relation relations = 1; +} diff --git a/protocol/src/main/proto/relation.proto b/protocol/src/main/proto/relation.proto deleted file mode 100644 index 9dedd3ee0c..0000000000 --- a/protocol/src/main/proto/relation.proto +++ /dev/null @@ -1,123 +0,0 @@ -syntax = "proto3"; -package anytype.relation; -option go_package = "pkg/lib/pb/relation"; - -import "google/protobuf/struct.proto"; - -message Detail { - string key = 1; - google.protobuf.Value value = 2; -} - -message ObjectType { - string url = 1; // leave empty in case you want to create the new one - string name = 2; // name of objectType (can be localized for bundled types) - repeated Relation relations = 3; // cannot contain more than one Relation with the same RelationType - Layout layout = 4; - string iconEmoji = 5; // emoji symbol - string description = 6; - bool hidden = 7; - - enum Layout { - basic = 0; - profile = 1; - todo = 2; - set = 3; - objectType = 4; - relation = 5; - file = 6; - dashboard = 7; - image = 8; - - database = 20; // to be released later - } -} - -message Layout { - ObjectType.Layout id = 1; - string name = 2; - repeated Relation requiredRelations = 3; // relations required for this object type -} - -message RelationWithValue { - Relation relation = 1; - google.protobuf.Value value = 2; -} - -// Relation describe the human-interpreted relation type. It may be something like "Date of creation, format=date" or "Assignee, format=objectId, objectType=person" -message Relation { - // Key under which the value is stored in the map. Must be unique for the object type. - // It usually auto-generated bsonid, but also may be something human-readable in case of prebuilt types. - string key = 1; - - RelationFormat format = 2; // format of the underlying data - string name = 3; // name to show (can be localized for bundled types) - google.protobuf.Value defaultValue = 4; - DataSource dataSource = 5; // where the data is stored - - bool hidden = 6; // internal, not displayed to user (e.g. coverX, coverY) - bool readOnly = 7; // not editable by user - bool multi = 8; // allow multiple values (stored in pb list) - - repeated string objectTypes = 9; // URL of object type, empty to allow link to any object - // index 10, 11 was used in internal-only builds. Can be reused, but may break some test accounts - repeated Option selectDict = 12; // default dictionary with unique values to choose for select/multiSelect format - int32 maxCount = 13; // max number of values can be set for this relation. 0 means no limit. 1 means the value can be stored in non-repeated field - string description = 14; - - // on-store fields, injected only locally - Scope scope = 20; // scope from which this relation have been aggregated - string creator = 21; // creator profile id - - message Option { - string id = 1; // id generated automatically if omitted - string text = 2; - string color = 3; // stored - Scope scope = 4; // on-store contains only local-scope relations. All others injected on-the-fly - - enum Scope { - local = 0; // stored within the object/aggregated from set - relation = 1; // aggregated from all relation of this relation's key - format = 2; // aggregated from all relations of this relation's format - } - } - - enum Scope { - object = 0; // stored within the object - type = 1; // stored within the object type - setOfTheSameType = 2; // aggregated from the dataview of sets of the same object type - objectsOfTheSameType = 3; // aggregated from the dataview of sets of the same object type - library = 4; // aggregated from relations library - } - - enum DataSource { - details = 0; // default, stored inside the object's details - derived = 1; // stored locally, e.g. in badger or generated on the fly - account = 2; // stored in the account DB. means existing only for specific anytype account - } -} - - -// RelationFormat describes how the underlying data is stored in the google.protobuf.Value and how it should be validated/sanitized -enum RelationFormat { - longtext = 0; // string - shorttext = 1; // string, usually short enough. May be truncated - number = 2; // double - status = 3; // string (choose one from a list) - tag = 11; // list of string (choose multiple from a list) - date = 4; // int64(pb.Value doesn't have int64) or string - file = 5; // relation can has objects of specific types: file, image, audio, video - checkbox = 6; // boolean - url = 7; // string with sanity check - email = 8; // string with sanity check - phone = 9; // string with sanity check - emoji = 10; // one emoji, can contains multiple utf-8 symbols - - object = 100; // relation can has objectType to specify objectType - relations = 101; // base64-encoded - -} - -message Relations { - repeated Relation relations = 1; -}