mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1992 Tech | Objects details refactoring (#1997)
This commit is contained in:
parent
6d37f78dd2
commit
524e15d26e
116 changed files with 2197 additions and 2420 deletions
|
@ -24,6 +24,7 @@ import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
|||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory.text
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.TestUtils.withRecyclerView
|
||||
import com.anytypeio.anytype.ui.editor.EditorFragment
|
||||
|
@ -536,12 +537,11 @@ class DeleteBlockTesting : EditorTestSetup() {
|
|||
|
||||
stubOpenDocument(
|
||||
document = document,
|
||||
details = Block.Details(
|
||||
details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf("name" to title)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.anytypeio.anytype.features.editor.base.EditorTestSetup
|
|||
import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
import com.anytypeio.anytype.test_utils.utils.checkIsRecyclerSize
|
||||
|
@ -119,16 +120,15 @@ class DescriptionTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, description)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"featuredRelations" to listOf(Relations.DESCRIPTION),
|
||||
"description" to description.content<Block.Content.Text>().text
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.anytypeio.anytype.features.editor.base.EditorTestSetup
|
|||
import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasViewGroupChildWithText
|
||||
import com.anytypeio.anytype.test_utils.utils.matchView
|
||||
|
@ -100,9 +101,9 @@ class FeaturedRelationTesting : EditorTestSetup() {
|
|||
val value4 = "https://anytype.io/"
|
||||
val value5 = "team@anytype.io"
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to value1,
|
||||
|
@ -116,7 +117,6 @@ class FeaturedRelationTesting : EditorTestSetup() {
|
|||
relation5.key
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -203,9 +203,9 @@ class FeaturedRelationTesting : EditorTestSetup() {
|
|||
val value4 = "https://anytype.io/"
|
||||
val value5 = "team@anytype.io"
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to value1,
|
||||
|
@ -220,7 +220,6 @@ class FeaturedRelationTesting : EditorTestSetup() {
|
|||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val paragraph = MockBlockFactory.paragraph(text = "Foo")
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.anytypeio.anytype.features.editor.base.EditorTestSetup
|
|||
import com.anytypeio.anytype.presentation.MockBlockContentFactory
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverColor
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
import com.anytypeio.anytype.test_utils.utils.checkIsDisplayed
|
||||
|
@ -79,15 +80,14 @@ class LayoutTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, paragraph)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"layout" to ObjectType.Layout.TODO.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
@ -130,15 +130,14 @@ class LayoutTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, checkedTitle, paragraph)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"layout" to ObjectType.Layout.TODO.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
@ -176,9 +175,9 @@ class LayoutTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, paragraph)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"layout" to ObjectType.Layout.TODO.code.toDouble(),
|
||||
|
@ -186,7 +185,6 @@ class LayoutTesting : EditorTestSetup() {
|
|||
"coverId" to CoverColor.BLUE.code,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
@ -223,15 +221,14 @@ class LayoutTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, paragraph)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"layout" to ObjectType.Layout.PROFILE.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
@ -268,9 +265,9 @@ class LayoutTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, paragraph)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"layout" to ObjectType.Layout.PROFILE.code.toDouble(),
|
||||
|
@ -278,7 +275,6 @@ class LayoutTesting : EditorTestSetup() {
|
|||
"coverId" to CoverColor.BLUE.code,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
@ -315,15 +311,14 @@ class LayoutTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, paragraph)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"layout" to ObjectType.Layout.BASIC.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
@ -360,9 +355,9 @@ class LayoutTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, paragraph)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
"layout" to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
|
@ -370,7 +365,6 @@ class LayoutTesting : EditorTestSetup() {
|
|||
"coverId" to CoverColor.BLUE.code,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
|||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
import com.anytypeio.anytype.test_utils.utils.onItemView
|
||||
|
@ -94,14 +95,14 @@ class MarkupTesting : EditorTestSetup() {
|
|||
|
||||
val document = listOf(page, a)
|
||||
|
||||
val fields = Block.Fields(mapOf(Block.Fields.NAME_KEY to "FooBa"))
|
||||
val fields = mapOf(Block.Fields.NAME_KEY to "FooBa")
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubAnalytics()
|
||||
stubOpenDocument(
|
||||
document = document,
|
||||
details = Block.Details(mapOf(mentionTarget to fields))
|
||||
details = ObjectViewDetails(mapOf(mentionTarget to fields))
|
||||
)
|
||||
stubUpdateText()
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.anytypeio.anytype.features.editor.base.EditorTestSetup
|
|||
import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
import com.anytypeio.anytype.test_utils.utils.onItemView
|
||||
|
@ -106,7 +107,7 @@ class MentionUpdateTesting : EditorTestSetup() {
|
|||
)
|
||||
val document = listOf(page, header, title, block)
|
||||
|
||||
val customDetails = Block.Details()
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
@ -120,7 +121,7 @@ class MentionUpdateTesting : EditorTestSetup() {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = customDetails,
|
||||
details = customDetails.details,
|
||||
blocks = document,
|
||||
objectRestrictions = emptyList()
|
||||
),
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.anytypeio.anytype.core_models.ext.content
|
|||
import com.anytypeio.anytype.features.editor.base.EditorTestSetup
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverColor
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
import com.anytypeio.anytype.test_utils.utils.checkIsDisplayed
|
||||
|
@ -174,11 +175,11 @@ class ProfileTesting : EditorTestSetup() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun givenBlockDetailsWithImage(): Block.Details {
|
||||
private fun givenBlockDetailsWithImage(): ObjectViewDetails {
|
||||
val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
return Block.Details(
|
||||
return ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconImage" to "anyimage",
|
||||
"layout" to ObjectType.Layout.PROFILE.code.toDouble(),
|
||||
|
@ -186,21 +187,19 @@ class ProfileTesting : EditorTestSetup() {
|
|||
"coverId" to CoverColor.BLUE.code,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun givenBlockDetailsWithOutImage(): Block.Details {
|
||||
return Block.Details(
|
||||
private fun givenBlockDetailsWithOutImage(): ObjectViewDetails {
|
||||
return ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"layout" to ObjectType.Layout.PROFILE.code.toDouble(),
|
||||
"coverType" to CoverType.COLOR.code.toDouble(),
|
||||
"coverId" to CoverColor.BLUE.code,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import com.anytypeio.anytype.features.editor.base.EditorTestSetup
|
|||
import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasBackgroundColor
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasNoBackground
|
||||
|
@ -53,14 +54,13 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
private val defaultDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
private val title = Block(
|
||||
|
@ -184,9 +184,9 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
val value4 = "https://anytype.io/"
|
||||
val value5 = "team@anytype.io"
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to value1,
|
||||
|
@ -196,7 +196,6 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
relation5.key to value5,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val paragraph = Block(
|
||||
|
@ -348,9 +347,9 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
val background3 = ThemeColor.BLUE
|
||||
val background4 = ThemeColor.ORANGE
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to value1,
|
||||
|
@ -360,7 +359,6 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
relation5.key to value5,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val paragraph = Block(
|
||||
|
@ -482,15 +480,14 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
selections = listOf(option)
|
||||
)
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to option.id
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val a = Block(
|
||||
|
@ -557,29 +554,28 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
selections = emptyList()
|
||||
)
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to listOf(file1, file2)
|
||||
)
|
||||
),
|
||||
file1 to Block.Fields(
|
||||
,
|
||||
file1 to
|
||||
mapOf(
|
||||
"name" to "Document",
|
||||
"ext" to "pdf",
|
||||
"mime" to "application/pdf"
|
||||
)
|
||||
),
|
||||
file2 to Block.Fields(
|
||||
,
|
||||
file2 to
|
||||
mapOf(
|
||||
"name" to "Image",
|
||||
"ext" to "jpg",
|
||||
"mime" to "image/jpeg"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val a = Block(
|
||||
|
@ -793,9 +789,9 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
val value4 = "https://anytype.io/"
|
||||
val value5 = "team@anytype.io"
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to value1,
|
||||
|
@ -805,7 +801,6 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
relation5.key to value5,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val block1 = Block(
|
||||
|
@ -907,15 +902,14 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
selections = listOf(option1)
|
||||
)
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to option1.id
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val block1 = Block(
|
||||
|
@ -1011,9 +1005,9 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
val value4 = "https://anytype.io/"
|
||||
val value5 = "team@anytype.io"
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to value1,
|
||||
|
@ -1023,7 +1017,6 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
relation5.key to value5,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val paragraph = Block(
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
|||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory.paragraph
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkIsDisplayed
|
||||
import com.anytypeio.anytype.test_utils.utils.checkIsNotDisplayed
|
||||
|
@ -42,13 +43,12 @@ class SlashTextWatcherTesting : EditorTestSetup() {
|
|||
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
private val defaultDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
|||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory.paragraph
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
|
@ -59,14 +60,13 @@ class SlashWidgetTesting : EditorTestSetup() {
|
|||
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
private val defaultDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
private val title = Block(
|
||||
|
@ -413,16 +413,15 @@ class SlashWidgetTesting : EditorTestSetup() {
|
|||
|
||||
val relations = listOf(relation1, relation2)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
|
||||
relation1.key to relation1Value,
|
||||
relation2.key to relation2Value
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.anytypeio.anytype.features.editor.base.EditorTestSetup
|
|||
import com.anytypeio.anytype.features.editor.base.TestEditorFragment
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
import com.anytypeio.anytype.test_utils.utils.checkIsDisplayed
|
||||
|
@ -115,11 +116,10 @@ class SplitTitleTesting : EditorTestSetup() {
|
|||
)
|
||||
val document = listOf(page, header, title, description, featured, block)
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(Relations.FEATURED_RELATIONS to listOf(description.id, relation2.key))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -225,12 +225,11 @@ class SplitTitleTesting : EditorTestSetup() {
|
|||
)
|
||||
val document = listOf(page, header, title, description, featured, block)
|
||||
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(Relations.FEATURED_RELATIONS to listOf(description.id, relation2.key))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
|
|
@ -101,6 +101,7 @@ import com.anytypeio.anytype.presentation.editor.Editor
|
|||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModelFactory
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Interactor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Orchestrator
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Proxy
|
||||
|
@ -532,7 +533,7 @@ open class EditorTestSetup {
|
|||
|
||||
fun stubOpenDocument(
|
||||
document: List<Block>,
|
||||
details: Block.Details = Block.Details(),
|
||||
details: ObjectViewDetails = ObjectViewDetails.EMPTY,
|
||||
relations: List<Relation> = emptyList()
|
||||
) {
|
||||
openPage.stub {
|
||||
|
@ -544,7 +545,7 @@ open class EditorTestSetup {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = details,
|
||||
details = details.details,
|
||||
blocks = document,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.anytypeio.anytype.core_models.Block
|
|||
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasChildViewWithText
|
||||
import com.anytypeio.anytype.test_utils.utils.checkIsDisplayed
|
||||
|
@ -40,14 +41,13 @@ class MentionWidgetTesting : EditorTestSetup() {
|
|||
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
private val defaultDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
private val title = Block(
|
||||
|
|
|
@ -134,7 +134,6 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
||||
details = defaultDetails
|
||||
)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.anytypeio.anytype.core_models.ObjectType
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
|
@ -124,22 +125,19 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() {
|
|||
)
|
||||
)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
details = defaultDetails.details + mapOf(
|
||||
file1Id to Block.Fields(
|
||||
mapOf(
|
||||
file1Id to mapOf(
|
||||
ObjectSetConfig.NAME_KEY to file1Name,
|
||||
ObjectSetConfig.TYPE_KEY to objectType.url,
|
||||
"fileExt" to file1Ext
|
||||
)
|
||||
),
|
||||
file2Id to Block.Fields(
|
||||
),
|
||||
file2Id to
|
||||
mapOf(
|
||||
ObjectSetConfig.NAME_KEY to file2Name,
|
||||
ObjectSetConfig.TYPE_KEY to objectType.url,
|
||||
"fileExt" to file2Ext
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -156,7 +154,6 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
details = details,
|
||||
)
|
||||
|
||||
|
|
|
@ -121,8 +121,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
set = set
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
@ -216,7 +215,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
@ -310,7 +309,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
@ -404,7 +403,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
@ -498,7 +497,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
@ -592,7 +591,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.anytypeio.anytype.core_models.ObjectType
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
|
@ -109,20 +110,19 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
)
|
||||
)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
details = defaultDetails.details + mapOf(
|
||||
object1Id to Block.Fields(
|
||||
object1Id to
|
||||
mapOf(
|
||||
ObjectSetConfig.NAME_KEY to object1Name,
|
||||
"iconEmoji" to "👤"
|
||||
)
|
||||
),
|
||||
object2Id to Block.Fields(
|
||||
,
|
||||
object2Id to
|
||||
mapOf(
|
||||
ObjectSetConfig.NAME_KEY to object2Name,
|
||||
"iconEmoji" to "👤"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -139,7 +139,6 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
details = details
|
||||
)
|
||||
|
||||
|
@ -221,22 +220,20 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
)
|
||||
)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
details = defaultDetails.details + mapOf(
|
||||
object1Id to Block.Fields(
|
||||
object1Id to
|
||||
mapOf(
|
||||
ObjectSetConfig.NAME_KEY to object1Name,
|
||||
ObjectSetConfig.TYPE_KEY to objectType.url,
|
||||
"iconEmoji" to "👤"
|
||||
)
|
||||
),
|
||||
object2Id to Block.Fields(
|
||||
),
|
||||
object2Id to
|
||||
mapOf(
|
||||
ObjectSetConfig.NAME_KEY to object2Name,
|
||||
ObjectSetConfig.TYPE_KEY to objectType.url,
|
||||
"iconEmoji" to "👤"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -253,7 +250,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
|
||||
details = details,
|
||||
)
|
||||
|
||||
|
|
|
@ -169,7 +169,6 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() {
|
|||
val set = listOf(root, header, title, dataview)
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
||||
details = defaultDetails,
|
||||
)
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.anytypeio.anytype.core_models.DVViewerRelation
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
|
@ -120,7 +121,7 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() {
|
|||
)
|
||||
)
|
||||
|
||||
val details = Block.Details()
|
||||
val details = ObjectViewDetails.EMPTY
|
||||
|
||||
val root = Block(
|
||||
id = ctx,
|
||||
|
@ -135,7 +136,6 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
details = details
|
||||
)
|
||||
|
||||
|
|
|
@ -79,8 +79,7 @@ class ObjectSetHeaderTest : TestObjectSetSetup() {
|
|||
stubSubscriptionEventChannel()
|
||||
stubOpenObjectSet(
|
||||
set = set,
|
||||
relations = emptyList(),
|
||||
details = defaultDetails
|
||||
details = defaultDetails.details
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
|
|
@ -10,7 +10,9 @@ import com.anytypeio.anytype.core_models.Event
|
|||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.SearchResult
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.SubscriptionEvent
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.device.providers.AppDefaultDateFormatProviderImpl
|
||||
|
@ -66,6 +68,7 @@ import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
|||
import com.anytypeio.anytype.presentation.common.Action
|
||||
import com.anytypeio.anytype.presentation.common.Delegator
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetPaginator
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
|
@ -216,13 +219,12 @@ abstract class TestObjectSetSetup {
|
|||
children = listOf(title.id)
|
||||
)
|
||||
|
||||
val defaultDetails = Block.Details(
|
||||
val defaultDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
ctx to Block.Fields(
|
||||
mapOf(
|
||||
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
)
|
||||
)
|
||||
ctx to
|
||||
mapOf(
|
||||
Relations.ICON_EMOJI to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -347,8 +349,7 @@ abstract class TestObjectSetSetup {
|
|||
|
||||
fun stubOpenObjectSet(
|
||||
set: List<Block>,
|
||||
details: Block.Details = Block.Details(),
|
||||
relations: List<Relation> = emptyList()
|
||||
details: Map<Id, Struct> = emptyMap<Id, Struct>()
|
||||
) {
|
||||
repo.stub {
|
||||
onBlocking { openObjectSet(ctx, SpaceId(defaultSpace)) } doReturn Result.Success(
|
||||
|
@ -369,8 +370,7 @@ abstract class TestObjectSetSetup {
|
|||
|
||||
fun stubOpenObjectSetWithRecord(
|
||||
set: List<Block>,
|
||||
details: Block.Details = Block.Details(),
|
||||
relations: List<Relation> = emptyList()
|
||||
details: ObjectViewDetails = ObjectViewDetails.EMPTY
|
||||
) {
|
||||
repo.stub {
|
||||
onBlocking { openObjectSet(ctx, SpaceId(defaultSpace)) } doReturn Result.Success(
|
||||
|
@ -380,7 +380,7 @@ abstract class TestObjectSetSetup {
|
|||
Event.Command.ShowObject(
|
||||
context = ctx,
|
||||
root = ctx,
|
||||
details = details,
|
||||
details = details.details,
|
||||
blocks = set,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
|||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.sets.sort.ViewerSortViewModel
|
||||
import com.anytypeio.anytype.presentation.sets.state.ObjectState
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -131,7 +132,8 @@ class ViewerObjectSortTest {
|
|||
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
|
||||
// Launching fragment
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.anytypeio.anytype.di.feature
|
|||
|
||||
import android.content.Context
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
|
||||
|
@ -119,11 +117,10 @@ import com.anytypeio.anytype.presentation.editor.toggle.ToggleStateHolder
|
|||
import com.anytypeio.anytype.presentation.objects.LockedStateProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DefaultObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DefaultObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider.Companion.INTRINSIC_PROVIDER_TYPE
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.RelationListProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationListProvider
|
||||
import com.anytypeio.anytype.presentation.templates.ObjectTypeTemplatesContainer
|
||||
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
||||
import com.anytypeio.anytype.presentation.util.DefaultCopyFileToCacheDirectory
|
||||
|
@ -230,7 +227,7 @@ object EditorSessionModule {
|
|||
@PerScreen
|
||||
fun relationListProvider(
|
||||
storage: Editor.Storage
|
||||
) : RelationListProvider = RelationListProvider.EditorRelationListProvider(
|
||||
) : ObjectRelationListProvider = ObjectRelationListProvider.EditorRelationListProvider(
|
||||
storage = storage
|
||||
)
|
||||
|
||||
|
@ -902,15 +899,6 @@ object EditorUseCaseModule {
|
|||
storage: Editor.Storage
|
||||
): ObjectValueProvider = DefaultObjectValueProvider(storage.details)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideObjectDetailProvider(
|
||||
storage: Editor.Storage
|
||||
): ObjectDetailProvider = object : ObjectDetailProvider {
|
||||
override fun provide(): Map<Id, Block.Fields> = storage.details.current().details
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
|||
import com.anytypeio.anytype.domain.collections.AddObjectToCollection
|
||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||
import com.anytypeio.anytype.domain.dashboard.interactor.SetObjectListIsFavorite
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.DeepLinkResolver
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.multiplayer.GetSpaceInviteLink
|
||||
|
@ -135,7 +134,7 @@ object ObjectMenuModule {
|
|||
dispatcher = dispatcher,
|
||||
updateFields = updateFields,
|
||||
delegator = delegator,
|
||||
menuOptionsProvider = createMenuOptionsProvider(storage, featureToggles),
|
||||
menuOptionsProvider = createMenuOptionsProvider(storage),
|
||||
addObjectToCollection = addObjectToCollection,
|
||||
createTemplateFromObject = createTemplateFromObject,
|
||||
setObjectDetails = setObjectDetails,
|
||||
|
@ -163,11 +162,10 @@ object ObjectMenuModule {
|
|||
)
|
||||
|
||||
@JvmStatic
|
||||
private fun createMenuOptionsProvider(storage: Editor.Storage, featureToggles: FeatureToggles) =
|
||||
private fun createMenuOptionsProvider(storage: Editor.Storage): ObjectMenuOptionsProvider =
|
||||
ObjectMenuOptionsProviderImpl(
|
||||
details = storage.details.stream().map { it.details },
|
||||
restrictions = storage.objectRestrictions.stream(),
|
||||
featureToggles = featureToggles
|
||||
objectViewDetailsFlow = storage.details.stream(),
|
||||
restrictions = storage.objectRestrictions.stream()
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@ -254,7 +252,7 @@ object ObjectSetMenuModule {
|
|||
analytics = analytics,
|
||||
objectState = state,
|
||||
dispatcher = dispatcher,
|
||||
menuOptionsProvider = createMenuOptionsProvider(state, featureToggles),
|
||||
menuOptionsProvider = createMenuOptionsProvider(state),
|
||||
addObjectToCollection = addObjectToCollection,
|
||||
debugGoroutinesShareDownloader = debugGoroutinesShareDownloader,
|
||||
createWidget = createWidget,
|
||||
|
@ -323,18 +321,15 @@ object ObjectSetMenuModule {
|
|||
@JvmStatic
|
||||
private fun createMenuOptionsProvider(
|
||||
state: StateFlow<ObjectState>,
|
||||
featureToggles: FeatureToggles
|
||||
): ObjectMenuOptionsProvider {
|
||||
return when (val currentState = state.value) {
|
||||
is ObjectState.DataView -> ObjectMenuOptionsProviderImpl(
|
||||
details = state.map { currentState.details }.distinctUntilChanged(),
|
||||
objectViewDetailsFlow = state.map { currentState.details }.distinctUntilChanged(),
|
||||
restrictions = state.map { currentState.objectRestrictions }.distinctUntilChanged(),
|
||||
featureToggles = featureToggles
|
||||
)
|
||||
else -> ObjectMenuOptionsProviderImpl(
|
||||
details = emptyFlow(),
|
||||
objectViewDetailsFlow = emptyFlow(),
|
||||
restrictions = emptyFlow(),
|
||||
featureToggles = featureToggles
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
|||
import com.anytypeio.anytype.presentation.objects.LockedStateProvider
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationListViewModelFactory
|
||||
import com.anytypeio.anytype.presentation.relations.RelationListViewModel
|
||||
import com.anytypeio.anytype.presentation.relations.providers.RelationListProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationListProvider
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.ui.relations.ObjectRelationListFragment
|
||||
import dagger.BindsInstance
|
||||
|
@ -47,7 +47,7 @@ object ObjectRelationListModule {
|
|||
fun factory(
|
||||
vmParams: RelationListViewModel.VmParams,
|
||||
lockedStateProvider: LockedStateProvider,
|
||||
relationListProvider: RelationListProvider,
|
||||
objectRelationListProvider: ObjectRelationListProvider,
|
||||
urlBuilder: UrlBuilder,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
updateDetail: UpdateDetail,
|
||||
|
@ -63,7 +63,7 @@ object ObjectRelationListModule {
|
|||
return ObjectRelationListViewModelFactory(
|
||||
vmParams = vmParams,
|
||||
lockedStateProvider = lockedStateProvider,
|
||||
relationListProvider = relationListProvider,
|
||||
objectRelationListProvider = objectRelationListProvider,
|
||||
urlBuilder = urlBuilder,
|
||||
dispatcher = dispatcher,
|
||||
updateDetail = updateDetail,
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.anytypeio.anytype.di.feature
|
|||
|
||||
import android.content.Context
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.primitives.Space
|
||||
|
@ -69,12 +68,11 @@ import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
|||
import com.anytypeio.anytype.presentation.objects.LockedStateProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider.Companion.DATA_VIEW_PROVIDER_TYPE
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider.Companion.INTRINSIC_PROVIDER_TYPE
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.RelationListProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationListProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.SetOrCollectionObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.SetOrCollectionRelationProvider
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
|
@ -421,20 +419,6 @@ object ObjectSetModule {
|
|||
db = db
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideObjectDetailProvider(
|
||||
objectState: MutableStateFlow<ObjectState>,
|
||||
): ObjectDetailProvider = object : ObjectDetailProvider {
|
||||
override fun provide(): Map<Id, Block.Fields> {
|
||||
return when (val state = objectState.value) {
|
||||
is ObjectState.DataView -> state.details
|
||||
else -> emptyMap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
|
@ -572,7 +556,7 @@ object ObjectSetModule {
|
|||
@PerScreen
|
||||
fun dataViewRelationListProvider(
|
||||
objectStateFlow: MutableStateFlow<ObjectState>
|
||||
) : RelationListProvider = RelationListProvider.ObjectSetRelationListProvider(
|
||||
) : ObjectRelationListProvider = ObjectRelationListProvider.ObjectSetRelationListProvider(
|
||||
objectStates = objectStateFlow
|
||||
)
|
||||
|
||||
|
|
|
@ -73,12 +73,6 @@ data class Block(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Document metadata
|
||||
* @property details maps id of the block to its details (contained as fields)
|
||||
*/
|
||||
data class Details(val details: Map<Id, Fields> = emptyMap())
|
||||
|
||||
/**
|
||||
* Block's content.
|
||||
*/
|
||||
|
|
|
@ -22,7 +22,7 @@ sealed class Event {
|
|||
data class ShowObject(
|
||||
override val context: Id,
|
||||
val root: Id,
|
||||
val details: Block.Details = Block.Details(emptyMap()),
|
||||
val details: Map<Id, Struct> = emptyMap(),
|
||||
val blocks: List<Block>,
|
||||
val objectRestrictions: List<ObjectRestriction> = emptyList(),
|
||||
val dataViewRestrictions: List<DataViewRestrictions> = emptyList()
|
||||
|
@ -30,8 +30,7 @@ sealed class Event {
|
|||
|
||||
data class AddBlock(
|
||||
override val context: String,
|
||||
val blocks: List<Block>,
|
||||
val details: Block.Details = Block.Details(emptyMap())
|
||||
val blocks: List<Block>
|
||||
) : Command()
|
||||
|
||||
/**
|
||||
|
@ -128,39 +127,38 @@ sealed class Event {
|
|||
val fields: Block.Fields
|
||||
) : Command()
|
||||
|
||||
|
||||
sealed class Details : Command() {
|
||||
/**
|
||||
* Command to set details (metadata) of the target block.
|
||||
* Command to set details (metadata) of the target Object.
|
||||
* Overwrites existing state.
|
||||
* @property context id of the context
|
||||
* @property target id of the target block, whose details we need to update
|
||||
* @property details details of the target block
|
||||
* @property target id of the target object, whose details we need to update
|
||||
* @property details details of the target object
|
||||
*/
|
||||
data class Set(
|
||||
override val context: Id,
|
||||
val target: Id,
|
||||
val details: Block.Fields
|
||||
val details: Struct
|
||||
) : Details()
|
||||
|
||||
/**
|
||||
* Command to amend details (metadata) of the target block.
|
||||
* Command to amend details (metadata) of the target object.
|
||||
* Amend existing state.
|
||||
* @property context id of the context
|
||||
* @property target id of the target block, whose details we need to update
|
||||
* @property details slide of details of the target block
|
||||
* @property target id of the target object, whose details we need to update
|
||||
* @property details slide of details of the target object
|
||||
*/
|
||||
data class Amend(
|
||||
override val context: Id,
|
||||
val target: Id,
|
||||
val details: Map<Id, Any?>
|
||||
val details: Struct
|
||||
) : Details()
|
||||
|
||||
/**
|
||||
* Command to unset details (metadata) of the target block.
|
||||
* Command to unset details (metadata) of the target object.
|
||||
* Unset existing detail keys.
|
||||
* @property context id of the context
|
||||
* @property target id of the target block, whose details we need to update
|
||||
* @property target id of the target object, whose details we need to update
|
||||
* @property keys
|
||||
*/
|
||||
data class Unset(
|
||||
|
@ -170,7 +168,6 @@ sealed class Event {
|
|||
) : Details()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Command to update file block content
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.anytypeio.anytype.core_models
|
||||
|
||||
data class ObjectViewDetails(val details: Map<Id, Struct>) {
|
||||
companion object {
|
||||
val EMPTY = ObjectViewDetails(emptyMap())
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ sealed class ObjectWrapper {
|
|||
|
||||
val coverType: CoverType
|
||||
get() = when (val value = map[Relations.COVER_TYPE]) {
|
||||
is Double -> CoverType.values().find { type ->
|
||||
is Double -> CoverType.entries.find { type ->
|
||||
type.code == value.toInt()
|
||||
} ?: CoverType.NONE
|
||||
else -> CoverType.NONE
|
||||
|
@ -372,6 +372,18 @@ sealed class ObjectWrapper {
|
|||
|
||||
val globalName: String? by default
|
||||
}
|
||||
|
||||
data class Date(override val map: Struct) : ObjectWrapper() {
|
||||
private val default = map.withDefault { null }
|
||||
val id: Id by default
|
||||
val name: String? by default
|
||||
val timestamp: Double?
|
||||
get() = when (val value = map[Relations.TIMESTAMP]) {
|
||||
is Double -> value
|
||||
is Int -> value.toDouble()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T> Struct.getSingleValue(relation: Key): T? =
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package com.anytypeio.anytype.core_models.ext
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
|
||||
fun Block.Details.process(event: Event.Command.Details) = when (event) {
|
||||
is Event.Command.Details.Set -> set(event.target, event.details)
|
||||
is Event.Command.Details.Amend -> amend(event.target, event.details)
|
||||
is Event.Command.Details.Unset -> unset(event.target, event.keys)
|
||||
}
|
||||
|
||||
fun Block.Details.set(
|
||||
target: Id,
|
||||
fields: Block.Fields
|
||||
): Block.Details = Block.Details(details + mapOf(target to fields))
|
||||
|
||||
fun Map<Id, Block.Fields>.amend(
|
||||
target: Id,
|
||||
slice: Map<Id, Any?>
|
||||
) : Map<Id, Block.Fields> {
|
||||
return toMutableMap().apply {
|
||||
val current = getOrDefault(target, Block.Fields.empty())
|
||||
val new = Block.Fields(current.map + slice)
|
||||
set(target, new)
|
||||
}
|
||||
}
|
||||
|
||||
fun Block.Details.amend(
|
||||
target: Id,
|
||||
slice: Map<Id, Any?>
|
||||
): Block.Details {
|
||||
val updated = details.toMutableMap().apply {
|
||||
val current = getOrDefault(target, Block.Fields.empty())
|
||||
val new = Block.Fields(current.map + slice)
|
||||
set(target, new)
|
||||
}
|
||||
return Block.Details(updated)
|
||||
}
|
||||
|
||||
fun Block.Details.unset(
|
||||
target: Id,
|
||||
keys: List<Id>
|
||||
): Block.Details {
|
||||
val updated = details.toMutableMap().apply {
|
||||
val current = getOrDefault(target, Block.Fields.empty())
|
||||
val new = Block.Fields(
|
||||
current.map.toMutableMap().apply {
|
||||
keys.forEach { key -> remove(key) }
|
||||
}
|
||||
)
|
||||
set(target, new)
|
||||
}
|
||||
return Block.Details(updated)
|
||||
}
|
||||
|
||||
fun Map<Id, Block.Fields>.unset(
|
||||
target: Id,
|
||||
keys: List<Id>
|
||||
) : Map<Id, Block.Fields> {
|
||||
return toMutableMap().apply {
|
||||
val current = getOrDefault(target, Block.Fields.empty())
|
||||
val new = Block.Fields(
|
||||
current.map.toMutableMap().apply {
|
||||
keys.forEach { key -> remove(key) }
|
||||
}
|
||||
)
|
||||
set(target, new)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.anytypeio.anytype.core_models.ext
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Block.Content.Text.Mark
|
||||
import com.anytypeio.anytype.core_models.misc.Overlap
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
|
||||
fun Map<Id, Struct>.process(event: Event.Command.Details) = when (event) {
|
||||
is Event.Command.Details.Set -> set(event.target, event.details.map)
|
||||
fun Map<Id, Struct>.process(event: Event.Command.Details): Map<Id, Struct> = when (event) {
|
||||
is Event.Command.Details.Set -> set(event.target, event.details)
|
||||
is Event.Command.Details.Amend -> amend(event.target, event.details)
|
||||
is Event.Command.Details.Unset -> unset(event.target, event.keys)
|
||||
}
|
||||
|
@ -45,10 +45,37 @@ fun Struct.mapToObjectWrapperType(): ObjectWrapper.Type? =
|
|||
if (containsKey(Relations.ID) && containsKey(Relations.UNIQUE_KEY)) ObjectWrapper.Type(this)
|
||||
else null
|
||||
|
||||
inline fun <reified T> Struct.getValues(key: String): List<T> {
|
||||
return when (val value = getOrDefault(key, emptyList<T>())) {
|
||||
is T -> listOf(value)
|
||||
is List<*> -> value.typeOf()
|
||||
else -> emptyList()
|
||||
}
|
||||
fun Struct?.toObject(): ObjectWrapper.Basic? {
|
||||
if (this == null || !isValidObject()) return null
|
||||
return ObjectWrapper.Basic(this)
|
||||
}
|
||||
|
||||
fun Struct?.mapToOptionObject(): ObjectWrapper.Option? {
|
||||
if (this == null) return null
|
||||
return ObjectWrapper.Option(this)
|
||||
}
|
||||
|
||||
fun Struct?.toFileObject(): ObjectWrapper.File? {
|
||||
if (this == null || !isValidObject()) return null
|
||||
return ObjectWrapper.File(this)
|
||||
}
|
||||
|
||||
|
||||
fun Struct?.toDateObject(): ObjectWrapper.Date? {
|
||||
if (this == null || !isValidObject()) return null
|
||||
return ObjectWrapper.Date(this)
|
||||
}
|
||||
|
||||
fun Struct?.toBookmarkObject(): ObjectWrapper.Bookmark? {
|
||||
if (this == null || !isValidObject()) return null
|
||||
return ObjectWrapper.Bookmark(this)
|
||||
}
|
||||
|
||||
fun Struct?.toInternalFlagsObject(): ObjectWrapper.ObjectInternalFlags? {
|
||||
if (this.isNullOrEmpty()) return null
|
||||
return ObjectWrapper.ObjectInternalFlags(this)
|
||||
}
|
||||
|
||||
fun Struct.isValidObject(): Boolean {
|
||||
return contains(Relations.ID)
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package com.anytypeio.anytype.domain.dashboard.model
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
|
||||
data class HomeDashboard(
|
||||
val id: String,
|
||||
val blocks: List<Block>,
|
||||
val children: List<String>,
|
||||
val fields: Block.Fields,
|
||||
val details: Block.Details = Block.Details(emptyMap())
|
||||
)
|
|
@ -41,7 +41,7 @@ class AddBackLinkToObject(
|
|||
?.children
|
||||
?.last()
|
||||
|
||||
val objectDetails = event.details.details[params.objectToPlaceLink]?.map
|
||||
val objectDetails = event.details[params.objectToPlaceLink]
|
||||
|
||||
require(targetBlock != null) { "Target block is missing" }
|
||||
require(objectDetails != null) { "Object details is missing" }
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.Event
|
|||
import com.anytypeio.anytype.middleware.BuildConfig
|
||||
import com.anytypeio.anytype.middleware.mappers.MWidgetLayout
|
||||
import com.anytypeio.anytype.middleware.mappers.core
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreFieldsModel
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreModel
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreModels
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreModelsAlign
|
||||
|
@ -118,7 +119,7 @@ fun anytype.Event.Message.toCoreModels(
|
|||
Event.Command.UpdateFields(
|
||||
context = context,
|
||||
target = event.id,
|
||||
fields = event.fields.toCoreModel()
|
||||
fields = event.fields.toCoreFieldsModel()
|
||||
)
|
||||
}
|
||||
blockSetFile != null -> {
|
||||
|
|
|
@ -89,11 +89,7 @@ fun MObjectView.toPayload(): Payload {
|
|||
context = rootId,
|
||||
root = rootId,
|
||||
blocks = blocks.toCoreModels(),
|
||||
details = Block.Details(
|
||||
details.associate { details ->
|
||||
details.id to details.details.toCoreModel()
|
||||
}
|
||||
),
|
||||
details = details.associate { d -> d.id to d.details.orEmpty() },
|
||||
objectRestrictions = restrictions?.object_?.map { it.toCoreModel() }.orEmpty(),
|
||||
dataViewRestrictions = restrictions?.dataview?.map { it.toCoreModel() }.orEmpty()
|
||||
)
|
||||
|
@ -299,7 +295,9 @@ fun List<MBlock>.toCoreModels(): List<Block> = mapNotNull { block ->
|
|||
}
|
||||
}
|
||||
|
||||
fun Map<String, *>?.toCoreModel(): Block.Fields = Block.Fields(this?.toMap().orEmpty())
|
||||
fun Map<String, *>?.toCoreFieldsModel(): Block.Fields = Block.Fields(this?.toMap().orEmpty())
|
||||
|
||||
fun Map<String, *>?.toCoreModel(): Map<String, Any?> = this?.toMap().orEmpty()
|
||||
|
||||
fun MBlock.toCoreModelsText(): Block.Content.Text {
|
||||
val content = checkNotNull(text)
|
||||
|
|
|
@ -276,7 +276,7 @@ class MiddlewareEventChannelTest {
|
|||
val icon = Pair("icon", ":package:")
|
||||
val name = Pair("name", "Document I")
|
||||
|
||||
val details = com.anytypeio.anytype.core_models.Block.Fields(map = mutableMapOf(icon, name))
|
||||
val details = mutableMapOf(icon, name)
|
||||
|
||||
val msg = anytype.Event.Object.Details.Set(
|
||||
id = id,
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.anytypeio.anytype.core_models.Payload
|
|||
import com.anytypeio.anytype.core_models.Position
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.TextBlock
|
||||
|
@ -41,7 +40,6 @@ import com.anytypeio.anytype.core_models.ext.content
|
|||
import com.anytypeio.anytype.core_models.ext.descendants
|
||||
import com.anytypeio.anytype.core_models.ext.isAllTextAndNoneCodeBlocks
|
||||
import com.anytypeio.anytype.core_models.ext.isAllTextBlocks
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.ext.parents
|
||||
import com.anytypeio.anytype.core_models.ext.process
|
||||
import com.anytypeio.anytype.core_models.ext.sortByType
|
||||
|
@ -247,15 +245,24 @@ import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
|||
import com.anytypeio.anytype.core_models.SupportedLayouts
|
||||
import com.anytypeio.anytype.core_models.TimeInMillis
|
||||
import com.anytypeio.anytype.core_models.TimeInSeconds
|
||||
import com.anytypeio.anytype.core_models.ext.toObject
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
||||
import com.anytypeio.anytype.presentation.editor.ControlPanelMachine.Event.SAM.*
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Intent.Clipboard.*
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Intent.Clipboard.Copy
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Intent.Clipboard.Paste
|
||||
import com.anytypeio.anytype.presentation.editor.editor.ext.isAllowedToShowTypesWidget
|
||||
import com.anytypeio.anytype.presentation.extension.getBookmarkObject
|
||||
import com.anytypeio.anytype.presentation.extension.getInternalFlagsObject
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeObject
|
||||
import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.OnDatePickerDismiss
|
||||
import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.OnDateSelected
|
||||
import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.OnTodayClick
|
||||
import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.OnTomorrowClick
|
||||
import com.anytypeio.anytype.presentation.extension.getFileDetailsForBlock
|
||||
import com.anytypeio.anytype.presentation.extension.getObjRelationsViews
|
||||
import com.anytypeio.anytype.presentation.extension.getRecommendedRelations
|
||||
import com.anytypeio.anytype.presentation.extension.getUrlForFileContent
|
||||
import com.anytypeio.anytype.presentation.navigation.NavPanelState
|
||||
import com.anytypeio.anytype.presentation.objects.getCreateObjectParams
|
||||
|
@ -264,9 +271,6 @@ import com.anytypeio.anytype.presentation.objects.getProperType
|
|||
import com.anytypeio.anytype.presentation.objects.isTemplatesAllowed
|
||||
import com.anytypeio.anytype.presentation.objects.toViews
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import com.anytypeio.anytype.presentation.relations.getNotIncludedRecommendedRelations
|
||||
import com.anytypeio.anytype.presentation.relations.getObjectRelations
|
||||
import com.anytypeio.anytype.presentation.relations.views
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchViewModel
|
||||
import com.anytypeio.anytype.presentation.sync.SyncStatusWidgetState
|
||||
|
@ -485,7 +489,7 @@ class EditorViewModel(
|
|||
|
||||
override fun onPickedDocImageFromDevice(ctx: Id, path: String) {
|
||||
viewModelScope.launch {
|
||||
val obj = orchestrator.stores.details.getAsObject(ctx)
|
||||
val obj = orchestrator.stores.details.current().getObject(vmParams.ctx)
|
||||
val space = obj?.spaceId
|
||||
if (space != null) {
|
||||
setDocImageIcon(
|
||||
|
@ -526,7 +530,7 @@ class EditorViewModel(
|
|||
success = { hash ->
|
||||
setDocCoverImage(
|
||||
SetDocCoverImage.Params.FromHash(
|
||||
context = context,
|
||||
context = vmParams.ctx,
|
||||
hash = hash
|
||||
)
|
||||
).process(
|
||||
|
@ -602,11 +606,17 @@ class EditorViewModel(
|
|||
events.forEach { event ->
|
||||
when (event) {
|
||||
is Event.Command.ShowObject -> {
|
||||
orchestrator.stores.details.update(event.details)
|
||||
orchestrator.stores.details.update(
|
||||
ObjectViewDetails(
|
||||
details = event.details
|
||||
)
|
||||
)
|
||||
orchestrator.stores.objectRestrictions.update(event.objectRestrictions)
|
||||
}
|
||||
is Event.Command.Details -> {
|
||||
orchestrator.stores.details.apply { update(current().process(event)) }
|
||||
orchestrator.stores.details.apply {
|
||||
update(ObjectViewDetails(details = current().details.process(event)))
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
// do nothing
|
||||
|
@ -617,7 +627,7 @@ class EditorViewModel(
|
|||
if (featureToggles.isLogEditorViewModelEvents) {
|
||||
Timber.d("Blocks after handling events: ${blocks.toPrettyString()}")
|
||||
}
|
||||
return events.flags(context)
|
||||
return events.flags(vmParams.ctx)
|
||||
}
|
||||
|
||||
private fun startProcessingControlPanelViewState() {
|
||||
|
@ -679,7 +689,7 @@ class EditorViewModel(
|
|||
rerenderingBlocks(newBlock)
|
||||
proceedWithUpdatingText(
|
||||
intent = Intent.Text.UpdateText(
|
||||
context = context,
|
||||
context = vmParams.ctx,
|
||||
text = newBlock.content.asText().text,
|
||||
target = targetBlock.id,
|
||||
marks = sortedMarks
|
||||
|
@ -757,7 +767,8 @@ class EditorViewModel(
|
|||
.withLatestFrom(
|
||||
orchestrator.stores.focus.stream(),
|
||||
orchestrator.stores.details.stream()
|
||||
) { models, focus, details ->
|
||||
) { models, focus, objectViewDetails ->
|
||||
val currentObj = objectViewDetails.getObject(vmParams.ctx)
|
||||
val permission = permission.value
|
||||
val root = models.first { it.id == context }
|
||||
if (mode == EditorMode.Locked) {
|
||||
|
@ -781,7 +792,7 @@ class EditorViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
footers.value = getFooterState(root, details)
|
||||
footers.value = getFooterState(root, currentObj)
|
||||
val flags = mutableListOf<BlockViewRenderer.RenderFlag>()
|
||||
Timber.d("Rendering starting...")
|
||||
val doc = models.asMap().render(
|
||||
|
@ -791,7 +802,7 @@ class EditorViewModel(
|
|||
focus = focus,
|
||||
anchor = context,
|
||||
indent = INITIAL_INDENT,
|
||||
details = details,
|
||||
details = objectViewDetails,
|
||||
restrictions = orchestrator.stores.objectRestrictions.current(),
|
||||
selection = currentSelection()
|
||||
) { onRenderFlagFound -> flags.add(onRenderFlagFound) }
|
||||
|
@ -1128,8 +1139,8 @@ class EditorViewModel(
|
|||
}
|
||||
}
|
||||
root.children.size == 2 -> {
|
||||
val layout = event.details.details[root.id]?.layout
|
||||
if (layout == ObjectType.Layout.NOTE.code.toDouble()) {
|
||||
val layout = event.details[root.id].toObject()?.layout
|
||||
if (layout == ObjectType.Layout.NOTE) {
|
||||
val block = event.blocks.firstOrNull { it.content is Content.Text }
|
||||
if (block != null && block.content<Content.Text>().text.isEmpty()) {
|
||||
val focus = Editor.Focus(
|
||||
|
@ -1544,15 +1555,10 @@ class EditorViewModel(
|
|||
}
|
||||
|
||||
private fun proceedWithOpeningObjectMenu() {
|
||||
if (context.isEmpty()) {
|
||||
sendToast("Your object is not initialized. Please, try again later.")
|
||||
return
|
||||
}
|
||||
controlPanelInteractor.onEvent(ControlPanelMachine.Event.OnDocumentMenuClicked)
|
||||
val details = orchestrator.stores.details.current().details
|
||||
val wrapper = ObjectWrapper.Basic(details[context]?.map.orEmpty())
|
||||
val wrapper = orchestrator.stores.details.current().getObject(vmParams.ctx)
|
||||
val isTemplate = isObjectTemplate()
|
||||
val space = wrapper.spaceId
|
||||
val space = wrapper?.spaceId
|
||||
if (space == null) {
|
||||
sendToast("Space not found")
|
||||
return
|
||||
|
@ -1565,7 +1571,7 @@ class EditorViewModel(
|
|||
dispatch(
|
||||
command = Command.OpenDocumentMenu(
|
||||
ctx = context,
|
||||
space = space,
|
||||
space = vmParams.space.id,
|
||||
isArchived = false,
|
||||
isFavorite = false,
|
||||
isLocked = false,
|
||||
|
@ -1578,9 +1584,9 @@ class EditorViewModel(
|
|||
dispatch(
|
||||
command = Command.OpenDocumentMenu(
|
||||
ctx = context,
|
||||
space = space,
|
||||
isArchived = details[context]?.isArchived ?: false,
|
||||
isFavorite = details[context]?.isFavorite ?: false,
|
||||
space = vmParams.space.id,
|
||||
isArchived = wrapper?.isArchived == true,
|
||||
isFavorite = wrapper?.isFavorite == true,
|
||||
isLocked = mode == EditorMode.Locked,
|
||||
isReadOnly = isReadOnly,
|
||||
isTemplate = isObjectTemplate()
|
||||
|
@ -1877,19 +1883,19 @@ class EditorViewModel(
|
|||
is Content.Bookmark -> {
|
||||
excludedActions.add(ActionItemType.Download)
|
||||
if (!isMultiMode) {
|
||||
if (content.targetObjectId != null) {
|
||||
val details = orchestrator.stores.details.current().details
|
||||
val obj = ObjectWrapper.Basic(
|
||||
details[content.targetObjectId]?.map ?: emptyMap()
|
||||
)
|
||||
val isReady = content.state == Content.Bookmark.State.DONE
|
||||
val isActive = obj.isArchived != true && obj.isDeleted != true
|
||||
val idx = targetActions.indexOf(ActionItemType.OpenObject)
|
||||
if (idx == NO_POSITION && isReady && isActive) {
|
||||
targetActions.add(
|
||||
OPEN_OBJECT_POSITION,
|
||||
ActionItemType.OpenObject
|
||||
)
|
||||
val targetObjectId = content.targetObjectId
|
||||
if (targetObjectId != null) {
|
||||
val obj = orchestrator.stores.details.current().getObject(targetObjectId)
|
||||
if (obj != null) {
|
||||
val isReady = content.state == Content.Bookmark.State.DONE
|
||||
val isActive = obj.isArchived != true && obj.isDeleted != true
|
||||
val idx = targetActions.indexOf(ActionItemType.OpenObject)
|
||||
if (idx == NO_POSITION && isReady && isActive) {
|
||||
targetActions.add(
|
||||
OPEN_OBJECT_POSITION,
|
||||
ActionItemType.OpenObject
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3168,12 +3174,9 @@ class EditorViewModel(
|
|||
}
|
||||
is Content.Bookmark -> {
|
||||
val target = content.targetObjectId
|
||||
val details = orchestrator.stores.details.current().details[target]
|
||||
if (target != null) {
|
||||
val obj = ObjectWrapper.Bookmark(details?.map ?: mapOf())
|
||||
if (obj.isArchived != true && obj.isDeleted != true) {
|
||||
proceedWithOpeningObjectByLayout(target = target)
|
||||
} else {
|
||||
val obj = orchestrator.stores.details.current().getBookmarkObject(target)
|
||||
if (obj?.isArchived == true || obj?.isDeleted == true) {
|
||||
val source = obj.source
|
||||
if (!source.isNullOrBlank()) {
|
||||
commands.postValue(
|
||||
|
@ -3184,6 +3187,8 @@ class EditorViewModel(
|
|||
} else {
|
||||
sendToast("Source is missing for this object")
|
||||
}
|
||||
} else {
|
||||
proceedWithOpeningObjectByLayout(target = target)
|
||||
}
|
||||
} else {
|
||||
sendToast("Couldn't find the target of the link")
|
||||
|
@ -3200,15 +3205,9 @@ class EditorViewModel(
|
|||
|
||||
private fun proceedWithOpeningDataViewBlock(dv: Content.DataView) {
|
||||
if (dv.targetObjectId.isNotEmpty()) {
|
||||
val targetSpace = orchestrator.stores.details.current().let { details ->
|
||||
val detail = details.details[dv.targetObjectId]
|
||||
if (detail != null && detail.map.isNotEmpty()) {
|
||||
val wrapper = ObjectWrapper.Basic(detail.map)
|
||||
wrapper.spaceId ?: vmParams.space.id
|
||||
} else {
|
||||
vmParams.space.id
|
||||
}
|
||||
}
|
||||
val targetSpace =
|
||||
orchestrator.stores.details.current().getObject(dv.targetObjectId)?.spaceId
|
||||
?: vmParams.space.id
|
||||
proceedWithOpeningDataViewObject(
|
||||
target = dv.targetObjectId,
|
||||
space = SpaceId(targetSpace)
|
||||
|
@ -3229,9 +3228,8 @@ class EditorViewModel(
|
|||
|
||||
private fun proceedWithOpeningObjectByLayout(target: String) {
|
||||
proceedWithClearingFocus()
|
||||
val details = orchestrator.stores.details.current()
|
||||
val wrapper = ObjectWrapper.Basic(map = details.details[target]?.map ?: emptyMap())
|
||||
if (wrapper.spaceId != vmParams.space.id) {
|
||||
val wrapper = orchestrator.stores.details.current().getObject(target)
|
||||
if (wrapper?.spaceId != vmParams.space.id) {
|
||||
sendToast("Cannot open object from another space from here.")
|
||||
} else {
|
||||
when (wrapper.layout) {
|
||||
|
@ -3288,7 +3286,7 @@ class EditorViewModel(
|
|||
}
|
||||
|
||||
else -> {
|
||||
sendToast("Cannot open object with layout: ${wrapper.layout}")
|
||||
sendToast("Cannot open object with layout: ${wrapper?.layout}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3420,7 +3418,7 @@ class EditorViewModel(
|
|||
|
||||
fun onSetObjectIconClicked() {
|
||||
viewModelScope.launch {
|
||||
val obj = orchestrator.stores.details.getAsObject(context)
|
||||
val obj = orchestrator.stores.details.current().getObject(vmParams.ctx)
|
||||
val space = obj?.spaceId
|
||||
if (space != null) {
|
||||
dispatch(Command.SetObjectIcon(ctx = context, space = space))
|
||||
|
@ -4254,7 +4252,7 @@ class EditorViewModel(
|
|||
val isDetailsAllowed = restrictions.none { it == ObjectRestriction.DETAILS }
|
||||
if (isDetailsAllowed) {
|
||||
controlPanelInteractor.onEvent(ControlPanelMachine.Event.OnDocumentIconClicked)
|
||||
val obj = orchestrator.stores.details.getAsObject(context)
|
||||
val obj = orchestrator.stores.details.current().getObject(vmParams.ctx)
|
||||
val space = obj?.spaceId
|
||||
if (space != null) {
|
||||
dispatch(
|
||||
|
@ -4332,7 +4330,7 @@ class EditorViewModel(
|
|||
|
||||
private fun proceedWithDownloadCurrentObjectAsFile() {
|
||||
|
||||
val fileObject = orchestrator.stores.details.getAsObject(target = context)
|
||||
val fileObject = orchestrator.stores.details.current().getObject(vmParams.ctx)
|
||||
if (fileObject == null) {
|
||||
Timber.e("Object with id $context not found.")
|
||||
return
|
||||
|
@ -5263,24 +5261,21 @@ class EditorViewModel(
|
|||
}
|
||||
|
||||
private fun getRelations(action: (List<SlashRelationView.Item>) -> Unit) {
|
||||
val details = orchestrator.stores.details.current()
|
||||
val objectDetails = details.details[context]?.map ?: emptyMap()
|
||||
val objectWrapper = ObjectWrapper.Basic(objectDetails)
|
||||
val objectType = objectWrapper.getProperType()
|
||||
val objectViewDetails = orchestrator.stores.details.current()
|
||||
|
||||
viewModelScope.launch {
|
||||
val objectRelationViews = getObjectRelationsView(
|
||||
ctx = context,
|
||||
objectDetails = objectDetails,
|
||||
details = details,
|
||||
objectWrapper = objectWrapper
|
||||
val objectRelationViews = objectViewDetails.getObjRelationsViews(
|
||||
ctx = vmParams.ctx,
|
||||
urlBuilder = urlBuilder,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
)
|
||||
|
||||
val recommendedRelationViews = getRecommendedRelations(
|
||||
ctx = context,
|
||||
objectDetails = objectDetails,
|
||||
objectTypeStruct = details.details[objectType]?.map,
|
||||
details = details
|
||||
val recommendedRelationViews = objectViewDetails.getRecommendedRelations(
|
||||
ctx = vmParams.ctx,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser,
|
||||
urlBuilder = urlBuilder
|
||||
)
|
||||
val update =
|
||||
(objectRelationViews + recommendedRelationViews).map { SlashRelationView.Item(it) }
|
||||
|
@ -5289,47 +5284,6 @@ class EditorViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun getObjectRelationsView(
|
||||
ctx: Id,
|
||||
objectDetails: Map<Key, Any?>,
|
||||
details: Block.Details,
|
||||
objectWrapper: ObjectWrapper.Basic
|
||||
): List<ObjectRelationView> {
|
||||
return getObjectRelations(
|
||||
systemRelations = listOf(),
|
||||
storeOfRelations = storeOfRelations,
|
||||
relationKeys = objectDetails.keys
|
||||
).views(
|
||||
context = ctx,
|
||||
details = details,
|
||||
values = objectDetails,
|
||||
urlBuilder = urlBuilder,
|
||||
featured = objectWrapper.featuredRelations,
|
||||
fieldParser = fieldParser
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun getRecommendedRelations(
|
||||
ctx: Id,
|
||||
objectDetails: Map<Key, Any?>,
|
||||
objectTypeStruct: Struct?,
|
||||
details: Block.Details
|
||||
): List<ObjectRelationView> {
|
||||
val objType = objectTypeStruct?.mapToObjectWrapperType()
|
||||
val recommendedRelations = objType?.recommendedRelations ?: emptyList()
|
||||
return getNotIncludedRecommendedRelations(
|
||||
recommendedRelations = recommendedRelations,
|
||||
storeOfRelations = storeOfRelations,
|
||||
relationKeys = objectDetails.keys
|
||||
).views(
|
||||
context = ctx,
|
||||
details = details,
|
||||
values = objectDetails,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
)
|
||||
}
|
||||
|
||||
private fun proceedWithObjectTypes(objectTypes: List<ObjectTypeView>) {
|
||||
onSlashWidgetStateChanged(
|
||||
SlashWidgetState.UpdateItems.empty().copy(
|
||||
|
@ -6261,10 +6215,11 @@ class EditorViewModel(
|
|||
|
||||
fun onMentionClicked(target: String) {
|
||||
if (isObjectTemplate()) return
|
||||
val details = orchestrator.stores.details.current()
|
||||
val objectDetails = details.details[target]?.map ?: return
|
||||
if (objectDetails.isEmpty()) return
|
||||
val obj = ObjectWrapper.Basic(objectDetails)
|
||||
val obj = orchestrator.stores.details.current().getObject(target)
|
||||
if (obj == null) {
|
||||
Timber.w("Details missing for mentioned object")
|
||||
return
|
||||
}
|
||||
proceedWithClearingFocus()
|
||||
proceedWithOpeningObject(obj)
|
||||
}
|
||||
|
@ -6413,7 +6368,7 @@ class EditorViewModel(
|
|||
|
||||
private fun proceedWithGettingObjectTypesForTypesWidget() {
|
||||
viewModelScope.launch {
|
||||
val excludeTypes = orchestrator.stores.details.current().details[context]?.type ?: emptyList()
|
||||
val excludeTypes = orchestrator.stores.details.current().getObject(vmParams.ctx)?.type.orEmpty()
|
||||
val params = GetObjectTypes.Params(
|
||||
sorts = emptyList(),
|
||||
filters = ObjectSearchConstants.filterTypes(
|
||||
|
@ -6454,7 +6409,7 @@ class EditorViewModel(
|
|||
fromFeatured: Boolean
|
||||
) {
|
||||
val list = buildList {
|
||||
val types = orchestrator.stores.details.current().details[context]?.type ?: emptyList()
|
||||
val types = orchestrator.stores.details.current().getObject(vmParams.ctx)?.type.orEmpty()
|
||||
if (types.isNotEmpty()) {
|
||||
addAll(types)
|
||||
}
|
||||
|
@ -6700,9 +6655,9 @@ class EditorViewModel(
|
|||
//endregion
|
||||
|
||||
//region FOOTER
|
||||
private fun getFooterState(root: Block, details: Block.Details): EditorFooter {
|
||||
return when (details.details[root.id]?.layout?.toInt()) {
|
||||
ObjectType.Layout.NOTE.code -> EditorFooter.Note
|
||||
private fun getFooterState(root: Block, currentObj: ObjectWrapper.Basic?): EditorFooter {
|
||||
return when (currentObj?.layout) {
|
||||
ObjectType.Layout.NOTE -> EditorFooter.Note
|
||||
else -> EditorFooter.None
|
||||
}
|
||||
}
|
||||
|
@ -6779,19 +6734,18 @@ class EditorViewModel(
|
|||
}
|
||||
|
||||
private fun getObjectTypeUniqueKeyFromDetails(): Id? {
|
||||
val details = orchestrator.stores.details.current()
|
||||
val currentObject = ObjectWrapper.Basic(details.details[context]?.map ?: emptyMap())
|
||||
val currentObjectTypeId = currentObject.getProperType() ?: return null
|
||||
val currentObjectType = ObjectWrapper.Basic(details.details[currentObjectTypeId]?.map ?: emptyMap())
|
||||
return currentObjectType.uniqueKey
|
||||
val objectViewDetails = orchestrator.stores.details.current()
|
||||
val currentObject = objectViewDetails.getObject(vmParams.ctx)
|
||||
val currentObjectTypeId = currentObject?.getProperType() ?: return null
|
||||
val currentObjectType = objectViewDetails.getTypeObject(currentObjectTypeId)
|
||||
return currentObjectType?.uniqueKey
|
||||
}
|
||||
|
||||
private fun getObjectTypeFromDetails(): ObjectWrapper.Type? {
|
||||
val details = orchestrator.stores.details.current()
|
||||
val currentObject = ObjectWrapper.Basic(details.details[context]?.map ?: emptyMap())
|
||||
val currentObjectTypeId = currentObject.getProperType() ?: return null
|
||||
val struct = details.details[currentObjectTypeId]?.map
|
||||
return struct?.mapToObjectWrapperType()
|
||||
val objectViewDetails = orchestrator.stores.details.current()
|
||||
val currentObject = objectViewDetails.getObject(vmParams.ctx)
|
||||
val currentObjectTypeId = currentObject?.getProperType() ?: return null
|
||||
return objectViewDetails.getTypeObject(currentObjectTypeId)
|
||||
}
|
||||
|
||||
fun isObjectTemplate(): Boolean {
|
||||
|
@ -7434,8 +7388,8 @@ class EditorViewModel(
|
|||
private fun checkRelationIsInObject(
|
||||
view: ObjectRelationView
|
||||
): Boolean {
|
||||
val currentObjectDetails = orchestrator.stores.details.getAsObject(vmParams.ctx)
|
||||
return currentObjectDetails?.map?.keys?.any { it == view.key } ?: false
|
||||
val currentObjectDetails = orchestrator.stores.details.current().getObject(vmParams.ctx)
|
||||
return currentObjectDetails?.map?.keys?.any { it == view.key } == true
|
||||
}
|
||||
|
||||
private suspend fun proceedWithAddingRelationToObject(
|
||||
|
@ -7627,7 +7581,7 @@ class EditorViewModel(
|
|||
if (blocks.isAllowedToShowTypesWidget(
|
||||
objectRestrictions = orchestrator.stores.objectRestrictions.current(),
|
||||
isOwnerOrEditor = permission.value?.isOwnerOrEditor() == true,
|
||||
objectLayout = orchestrator.stores.details.current().details[context]?.layout?.toInt()
|
||||
objectLayout = orchestrator.stores.details.current().getObject(vmParams.ctx)?.layout
|
||||
)
|
||||
) {
|
||||
setTypesWidgetVisibility(true)
|
||||
|
@ -7650,9 +7604,8 @@ class EditorViewModel(
|
|||
}
|
||||
|
||||
private fun getInternalFlagsFromDetails(): List<InternalFlags> {
|
||||
val details = orchestrator.stores.details.current()
|
||||
val obj = ObjectWrapper.ObjectInternalFlags(details.details[context]?.map ?: emptyMap())
|
||||
return obj.internalFlags
|
||||
val obj = orchestrator.stores.details.current().getInternalFlagsObject(vmParams.ctx)
|
||||
return obj?.internalFlags ?: emptyList()
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
@ -7675,11 +7628,11 @@ class EditorViewModel(
|
|||
spaceSyncAndP2PStatusProvider.observe(),
|
||||
orchestrator.stores.details.stream()
|
||||
) { state, details ->
|
||||
state to details.details[context]?.map
|
||||
state to details.getObject(context)
|
||||
}.catch {
|
||||
Timber.e(it, "Error while observing sync status")
|
||||
}.collect { (syncAndP2pState, struct) ->
|
||||
if (!struct.isNullOrEmpty() && !struct.isObjectParticipant()) {
|
||||
}.collect { (syncAndP2pState, obj) ->
|
||||
if (obj != null && obj.layout != ObjectType.Layout.PARTICIPANT) {
|
||||
spaceSyncStatus.value = syncAndP2pState
|
||||
syncStatusWidget.value =
|
||||
syncStatusWidget.value.updateStatus(syncAndP2pState)
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.domain.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
|
@ -57,22 +53,7 @@ interface Store<T> {
|
|||
|
||||
class Screen : State<List<BlockView>>(emptyList())
|
||||
|
||||
class Details : State<Block.Details>(Block.Details()) {
|
||||
suspend fun add(target: Id, fields: Block.Fields) {
|
||||
update(current().copy(details = current().details + mapOf(target to fields)))
|
||||
}
|
||||
fun getAsObject(target: Id) : ObjectWrapper.Basic? {
|
||||
val struct = current().details[target]
|
||||
return if (struct != null && struct.map.isNotEmpty()) {
|
||||
ObjectWrapper.Basic(struct.map)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Relations : State<List<Relation>>(emptyList())
|
||||
class Details : State<ObjectViewDetails>(ObjectViewDetails.EMPTY)
|
||||
class ObjectRestrictions : State<List<ObjectRestriction>>(emptyList())
|
||||
class TextSelection : State<Editor.TextSelection>(Editor.TextSelection.empty())
|
||||
class RelationLinks : State<List<RelationLink>>(emptyList())
|
||||
}
|
|
@ -3,9 +3,10 @@ package com.anytypeio.anytype.presentation.editor.editor.ext
|
|||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Document
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.presentation.editor.ControlPanelMachine
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView.Media.Bookmark.Companion.SEARCH_FIELD_DESCRIPTION_KEY
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView.Media.Bookmark.Companion.SEARCH_FIELD_TITLE_KEY
|
||||
|
@ -1194,16 +1195,16 @@ fun List<BlockView>.update(blockView: BlockView) = this.map {
|
|||
|
||||
fun Document.getLinkAppearanceMenu(
|
||||
blockId: Id,
|
||||
details: Block.Details
|
||||
details: ObjectViewDetails
|
||||
): BlockView.Appearance.Menu? {
|
||||
val block = this.find { it.id == blockId }
|
||||
val content = block?.content
|
||||
return if (block != null && content is Block.Content.Link) {
|
||||
val target = content.asLink().target
|
||||
val obj = ObjectWrapper.Basic(details.details[target]?.map ?: emptyMap())
|
||||
val obj = details.getObject(target)
|
||||
val factory = LinkAppearanceFactory(
|
||||
content = content,
|
||||
layout = obj.layout
|
||||
layout = obj?.layout
|
||||
)
|
||||
return factory.createAppearanceMenuItems()
|
||||
} else {
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.anytypeio.anytype.presentation.editor.editor.ext
|
|||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Block.Content
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.MAX_SNIPPET_SIZE
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.core_models.ext.replaceRangeWithWord
|
||||
|
@ -11,19 +9,22 @@ import com.anytypeio.anytype.core_models.ext.title
|
|||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup
|
||||
import com.anytypeio.anytype.presentation.extension.getDateObject
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.shift
|
||||
import com.anytypeio.anytype.presentation.widgets.collection.ResourceProvider
|
||||
import timber.log.Timber
|
||||
|
||||
fun Block.Content.Text.getTextAndMarks(
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
marks: List<Markup.Mark>,
|
||||
fieldParser: FieldParser,
|
||||
resourceProvider: ResourceProvider
|
||||
): Pair<String, List<Markup.Mark>> {
|
||||
|
||||
if (details.details.isEmpty() || marks.none { it is Markup.Mark.Mention }) {
|
||||
if (marks.none { it is Markup.Mark.Mention }) {
|
||||
return text to marks
|
||||
}
|
||||
var updatedText = text
|
||||
|
@ -40,7 +41,14 @@ fun Block.Content.Text.getTextAndMarks(
|
|||
resourceProvider = resourceProvider
|
||||
)
|
||||
is Markup.Mark.Mention.Deleted -> resourceProvider.getNonExistentObjectTitle()
|
||||
else -> details.details.getProperObjectName(id = mark.param) ?: return@forEach
|
||||
else -> {
|
||||
val obj = details.getObject(mark.param)
|
||||
if (obj != null) {
|
||||
fieldParser.getObjectName(obj)
|
||||
} else {
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
val oldName = updatedText.substring(mark.from, mark.to)
|
||||
val finalName =
|
||||
|
@ -68,38 +76,28 @@ fun Block.Content.Text.getTextAndMarks(
|
|||
|
||||
private fun Block.Content.Text.getFormattedDateMention(
|
||||
mark: Markup.Mark.Mention.Date,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser,
|
||||
resourceProvider: ResourceProvider
|
||||
): String? {
|
||||
val dateObject = details.getDateObject(id = mark.param)
|
||||
return if (BuildConfig.ENABLE_RELATIVE_DATES_IN_MENTIONS) {
|
||||
val dateObject = details.details[mark.param] ?: return null
|
||||
val timestamp = dateObject.timestamp ?: return null
|
||||
val timestamp = dateObject?.timestamp
|
||||
val relativeDate = fieldParser.toDate(timestamp)?.relativeDate
|
||||
resourceProvider.toFormattedString(relativeDate = relativeDate).takeIf { it.isNotEmpty() }
|
||||
} else {
|
||||
details.details[mark.param]?.name
|
||||
}
|
||||
}
|
||||
|
||||
private fun Map<Id, Block.Fields>.getProperObjectName(id: Id?): String? {
|
||||
if (id == null) return null
|
||||
val layoutCode = this[id]?.layout?.toInt()
|
||||
return if (layoutCode == ObjectType.Layout.NOTE.code) {
|
||||
this[id]?.snippet?.replace("\n", " ")?.take(MAX_SNIPPET_SIZE)
|
||||
} else {
|
||||
this[id]?.name
|
||||
dateObject?.name
|
||||
}
|
||||
}
|
||||
|
||||
fun List<Block>.isAllowedToShowTypesWidget(
|
||||
objectRestrictions: List<ObjectRestriction>,
|
||||
isOwnerOrEditor: Boolean,
|
||||
objectLayout: Int?
|
||||
objectLayout: ObjectType.Layout?
|
||||
): Boolean {
|
||||
if (objectRestrictions.any { it == ObjectRestriction.TYPE_CHANGE }) return false
|
||||
if (!isOwnerOrEditor) return false
|
||||
return if (objectLayout == ObjectType.Layout.NOTE.code) {
|
||||
return if (objectLayout == ObjectType.Layout.NOTE) {
|
||||
return true
|
||||
} else {
|
||||
return title()?.content<Content.Text>()?.text?.isEmpty() == true
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.anytypeio.anytype.domain.layout.GetSupportedObjectLayouts
|
|||
import com.anytypeio.anytype.domain.layout.SetObjectLayout
|
||||
import com.anytypeio.anytype.presentation.common.BaseViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsObjectLayoutChangeEvent
|
||||
import com.anytypeio.anytype.presentation.mapper.toObjectLayout
|
||||
import com.anytypeio.anytype.presentation.mapper.toView
|
||||
|
@ -67,7 +68,7 @@ class ObjectLayoutViewModel(
|
|||
private fun proceedWithObjectLayout(ctx: Id) {
|
||||
viewModelScope.launch {
|
||||
storage.details.stream().collect { details ->
|
||||
val code = details.details[ctx]?.layout?.toInt()
|
||||
val code = details.getObject(ctx)?.layout?.code
|
||||
selectedLayout.value = code ?: ObjectType.Layout.BASIC.code
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.anytypeio.anytype.core_models.Block
|
|||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.domain.editor.Editor
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.Editor.Mode as EditorMode
|
||||
|
||||
|
@ -27,7 +28,7 @@ interface BlockViewRenderer {
|
|||
focus: Editor.Focus,
|
||||
anchor: Id,
|
||||
indent: Int,
|
||||
details: Block.Details = Block.Details(emptyMap()),
|
||||
details: ObjectViewDetails,
|
||||
restrictions: List<ObjectRestriction>,
|
||||
selection: Set<Id>,
|
||||
count: Int = 0,
|
||||
|
|
|
@ -20,7 +20,10 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
|||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.ext.getTextAndMarks
|
||||
import com.anytypeio.anytype.presentation.extension.getBookmarkObject
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.Alignment
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView.Appearance.InEditor
|
||||
|
@ -34,8 +37,8 @@ import com.anytypeio.anytype.presentation.mapper.toVideoView
|
|||
import com.anytypeio.anytype.presentation.mapper.toView
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.appearance.LinkAppearanceFactory
|
||||
import com.anytypeio.anytype.presentation.objects.getProperType
|
||||
import com.anytypeio.anytype.presentation.relations.BasicObjectCoverWrapper
|
||||
import com.anytypeio.anytype.presentation.relations.BlockFieldsCoverWrapper
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import com.anytypeio.anytype.presentation.relations.getCover
|
||||
import com.anytypeio.anytype.presentation.relations.linksFeaturedRelation
|
||||
|
@ -63,7 +66,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
focus: Focus,
|
||||
anchor: Id,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
restrictions: List<ObjectRestriction>,
|
||||
selection: Set<Id>,
|
||||
count: Int,
|
||||
|
@ -416,10 +419,9 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
}
|
||||
}
|
||||
Content.Text.Style.DESCRIPTION -> {
|
||||
val detail = details.details.getOrDefault(root.id, Block.Fields.empty())
|
||||
val obj = ObjectWrapper.Basic(detail.map)
|
||||
val featured = obj.featuredRelations
|
||||
if (featured.contains(Relations.DESCRIPTION)) {
|
||||
val obj = details.getObject(id = context)
|
||||
val featured = obj?.featuredRelations
|
||||
if (featured?.contains(Relations.DESCRIPTION) == true) {
|
||||
if (obj.layout == ObjectType.Layout.PARTICIPANT && content.text.isEmpty()) {
|
||||
Timber.d("Skipping description rendering for object with participant layout: text is empty")
|
||||
} else {
|
||||
|
@ -606,9 +608,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
}
|
||||
is Content.Link -> {
|
||||
mCounter = 0
|
||||
val obj = ObjectWrapper.Basic(
|
||||
map = details.details[content.target]?.map ?: emptyMap()
|
||||
)
|
||||
val obj = details.getObject(content.target)
|
||||
val link = toLinks(
|
||||
block = block,
|
||||
content = content,
|
||||
|
@ -798,7 +798,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
content: Content.Text,
|
||||
focus: Focus,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.Text.Paragraph {
|
||||
|
@ -861,7 +861,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
focus: Focus,
|
||||
content: Content.Text,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.Text.Header.Three {
|
||||
|
@ -898,7 +898,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
focus: Focus,
|
||||
content: Content.Text,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.Text.Header.Two {
|
||||
|
@ -935,7 +935,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
focus: Focus,
|
||||
content: Content.Text,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.Text.Header.One {
|
||||
|
@ -972,7 +972,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
content: Content.Text,
|
||||
focus: Focus,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.Text.Checkbox {
|
||||
|
@ -1009,7 +1009,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
content: Content.Text,
|
||||
focus: Focus,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.Text.Bulleted {
|
||||
|
@ -1070,7 +1070,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
focus: Focus,
|
||||
content: Content.Text,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
scheme: NestedDecorationData
|
||||
): BlockView.Text.Highlight {
|
||||
|
@ -1114,7 +1114,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
focus: Focus,
|
||||
content: Content.Text,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
scheme: NestedDecorationData
|
||||
): BlockView.Text.Callout {
|
||||
|
@ -1169,7 +1169,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
indent: Int,
|
||||
focus: Focus,
|
||||
isEmpty: Boolean,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
scheme: NestedDecorationData
|
||||
): BlockView.Text.Toggle {
|
||||
|
@ -1208,7 +1208,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
number: Int,
|
||||
focus: Focus,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.Text.Numbered {
|
||||
|
@ -1247,7 +1247,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
selection: Set<Id>,
|
||||
isPreviousBlockMedia: Boolean,
|
||||
schema: NestedDecorationData,
|
||||
details: Block.Details
|
||||
details: ObjectViewDetails,
|
||||
): BlockView = when (content.state) {
|
||||
Content.Bookmark.State.EMPTY -> {
|
||||
BlockView.MediaPlaceholder.Bookmark(
|
||||
|
@ -1281,10 +1281,14 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
)
|
||||
}
|
||||
Content.Bookmark.State.DONE -> {
|
||||
val obj = ObjectWrapper.Bookmark(
|
||||
details.details[content.targetObjectId]?.map ?: emptyMap()
|
||||
)
|
||||
if (obj.isDeleted == true) {
|
||||
val targetObjectId = content.targetObjectId
|
||||
val obj = if (targetObjectId != null) {
|
||||
details.getBookmarkObject(targetObjectId)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
if (obj == null || obj.isDeleted == true) {
|
||||
linkDeleted(
|
||||
block = block,
|
||||
indent = indent,
|
||||
|
@ -1380,7 +1384,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
selection: Set<Id>,
|
||||
isPreviousBlockMedia: Boolean,
|
||||
schema: NestedDecorationData,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser
|
||||
): BlockView {
|
||||
|
||||
|
@ -1404,11 +1408,11 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
content: Content.Text,
|
||||
root: Block,
|
||||
focus: Focus,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
restrictions: List<ObjectRestriction>
|
||||
): BlockView.Title {
|
||||
|
||||
val currentObject = ObjectWrapper.Basic(details.details[context]?.map.orEmpty())
|
||||
val currentObject = details.getObject(id = context)
|
||||
|
||||
val focusTarget = focus.target
|
||||
|
||||
|
@ -1425,11 +1429,10 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
}
|
||||
|
||||
val rootContent = root.content
|
||||
val rootDetails = details.details[root.id]
|
||||
|
||||
check(rootContent is Content.Smart)
|
||||
|
||||
val coverContainer = BlockFieldsCoverWrapper(rootDetails)
|
||||
val coverContainer = BasicObjectCoverWrapper(currentObject)
|
||||
.getCover(urlBuilder, coverImageHashProvider)
|
||||
|
||||
val blockMode = if (restrictions.contains(ObjectRestriction.DETAILS)) {
|
||||
|
@ -1438,7 +1441,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
if (mode == EditorMode.Edit) Mode.EDIT else Mode.READ
|
||||
}
|
||||
|
||||
return when (currentObject.layout) {
|
||||
return when (currentObject?.layout) {
|
||||
ObjectType.Layout.BASIC -> {
|
||||
BlockView.Title.Basic(
|
||||
mode = blockMode,
|
||||
|
@ -1527,13 +1530,13 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
)
|
||||
}
|
||||
else -> {
|
||||
// Fallback to basic title in case of unexpected layout
|
||||
// Fallback to basic title in case of unexpected layout or when wrapper is null
|
||||
BlockView.Title.Basic(
|
||||
mode = blockMode,
|
||||
id = block.id,
|
||||
text = content.text,
|
||||
emoji = currentObject.iconEmoji?.takeIf { it.isNotBlank() },
|
||||
image = currentObject.iconImage?.takeIf { it.isNotBlank() }?.let {
|
||||
emoji = currentObject?.iconEmoji?.takeIf { it.isNotBlank() },
|
||||
image = currentObject?.iconImage?.takeIf { it.isNotBlank() }?.let {
|
||||
urlBuilder.medium(it)
|
||||
},
|
||||
isFocused = resolveIsFocused(focus, block),
|
||||
|
@ -1544,7 +1547,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
background = block.parseThemeBackgroundColor(),
|
||||
color = block.textColor()
|
||||
).also {
|
||||
Timber.w("Unexpected layout for title: ${currentObject.layout}")
|
||||
Timber.w("Unexpected layout for title: ${currentObject?.layout}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1567,21 +1570,13 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
block: Block,
|
||||
content: Content.Link,
|
||||
indent: Int,
|
||||
obj: ObjectWrapper.Basic,
|
||||
obj: ObjectWrapper.Basic?,
|
||||
mode: EditorMode,
|
||||
selection: Set<Id>,
|
||||
isPreviousBlockMedia: Boolean,
|
||||
parentSchema: NestedDecorationData
|
||||
): BlockView.LinkToObject {
|
||||
if (obj.isEmpty()) {
|
||||
return BlockView.LinkToObject.Loading(
|
||||
id = block.id,
|
||||
indent = indent
|
||||
)
|
||||
}
|
||||
val isDeleted = obj.isDeleted
|
||||
val isArchived = obj.isArchived
|
||||
return if (isDeleted == true) {
|
||||
return if (obj == null || obj.isDeleted == true) {
|
||||
linkDeleted(
|
||||
block = block,
|
||||
indent = indent,
|
||||
|
@ -1590,7 +1585,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
parentSchema = parentSchema
|
||||
)
|
||||
} else {
|
||||
if (isArchived == true) {
|
||||
if (obj.isArchived == true) {
|
||||
linkArchive(
|
||||
block = block,
|
||||
indent = indent,
|
||||
|
@ -1907,7 +1902,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
block: Block,
|
||||
focus: Focus,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
blocks: Map<String, List<Block>>,
|
||||
decorations: List<BlockView.Decoration>
|
||||
|
@ -1974,7 +1969,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
mode: EditorMode,
|
||||
focus: Focus,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>
|
||||
): List<BlockView.Table.Cell> {
|
||||
val cells = mutableListOf<BlockView.Table.Cell>()
|
||||
|
@ -2023,7 +2018,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
block: Block,
|
||||
content: Content.RelationBlock,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
urlBuilder: UrlBuilder,
|
||||
schema: NestedDecorationData,
|
||||
fieldParser: FieldParser
|
||||
|
@ -2039,9 +2034,10 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
} else {
|
||||
val relation = storeOfRelations.getByKey(relationKey)
|
||||
if (relation != null) {
|
||||
val values = details.getObject(ctx)?.map.orEmpty()
|
||||
val view = relation.view(
|
||||
details = details.details,
|
||||
values = details.details[ctx]?.map ?: emptyMap(),
|
||||
details = details,
|
||||
values = values,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
)
|
||||
|
@ -2066,12 +2062,11 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
private suspend fun featured(
|
||||
ctx: Id,
|
||||
block: Block,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser,
|
||||
): BlockView.FeaturedRelation {
|
||||
val map = details.details[ctx]?.map ?: emptyMap()
|
||||
val obj = ObjectWrapper.Basic(map)
|
||||
val featuredKeys = workaroundGlobalNameOrIdentityRelation(obj.featuredRelations, map)
|
||||
val obj = details.getObject(ctx)
|
||||
val featuredKeys = workaroundGlobalNameOrIdentityRelation(obj?.featuredRelations.orEmpty(), obj?.map.orEmpty())
|
||||
val views = mapFeaturedRelations(
|
||||
ctx = ctx,
|
||||
keys = featuredKeys,
|
||||
|
@ -2082,8 +2077,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
return BlockView.FeaturedRelation(
|
||||
id = block.id,
|
||||
relations = views,
|
||||
allowChangingObjectType = !obj.type.contains(BOOKMARK),
|
||||
isTodoLayout = obj.layout == ObjectType.Layout.TODO
|
||||
allowChangingObjectType = obj?.type?.contains(BOOKMARK) != true,
|
||||
isTodoLayout = obj?.layout == ObjectType.Layout.TODO
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2113,13 +2108,13 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
private suspend fun mapFeaturedRelations(
|
||||
ctx: Id,
|
||||
keys: List<Key>,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser
|
||||
): List<ObjectRelationView> = keys.mapNotNull { key ->
|
||||
when (key) {
|
||||
Relations.DESCRIPTION -> null
|
||||
Relations.TYPE -> {
|
||||
val objectTypeId = details.details[ctx]?.type?.firstOrNull()
|
||||
val objectTypeId = details.getObject(ctx)?.getProperType()
|
||||
if (objectTypeId != null) {
|
||||
details.objectTypeRelation(
|
||||
relationKey = key,
|
||||
|
@ -2140,9 +2135,10 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
}
|
||||
else -> {
|
||||
val relation = storeOfRelations.getByKey(key)
|
||||
val values = details.getObject(ctx)?.map.orEmpty()
|
||||
relation?.view(
|
||||
details = details.details,
|
||||
values = details.details[ctx]?.map ?: emptyMap(),
|
||||
details = details,
|
||||
values = values,
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = true,
|
||||
fieldParser = fieldParser
|
||||
|
@ -2177,7 +2173,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
mode: EditorMode,
|
||||
block: Block,
|
||||
content: Content.DataView,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
): BlockView.DataView {
|
||||
|
@ -2208,10 +2204,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
isCollection = isCollection
|
||||
)
|
||||
} else {
|
||||
val targetSet = ObjectWrapper.Basic(
|
||||
map = details.details[content.targetObjectId]?.map ?: emptyMap()
|
||||
)
|
||||
if (targetSet.isDeleted == true) {
|
||||
val targetSet = details.getObject(targetObjectId)
|
||||
if (targetSet == null || targetSet.isDeleted == true) {
|
||||
return BlockView.DataView.Deleted(
|
||||
id = block.id,
|
||||
decorations = decorations,
|
||||
|
@ -2223,7 +2217,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
)
|
||||
}
|
||||
val icon = targetSet.objectIcon(urlBuilder)
|
||||
val isSetNoQuery = targetSet.setOf.all { it.isNullOrBlank() }
|
||||
val isSetNoQuery = targetSet.setOf.all { it.isBlank() }
|
||||
if (isSetNoQuery && !content.isCollection) {
|
||||
return BlockView.DataView.EmptyData(
|
||||
id = block.id,
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
package com.anytypeio.anytype.presentation.extension
|
||||
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.ext.isValidObject
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.ext.mapToOptionObject
|
||||
import com.anytypeio.anytype.core_models.ext.toBookmarkObject
|
||||
import com.anytypeio.anytype.core_models.ext.toDateObject
|
||||
import com.anytypeio.anytype.core_models.ext.toFileObject
|
||||
import com.anytypeio.anytype.core_models.ext.toInternalFlagsObject
|
||||
import com.anytypeio.anytype.core_models.ext.toObject
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.objects.getProperType
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import com.anytypeio.anytype.presentation.relations.getNotIncludedRecommendedRelations
|
||||
import com.anytypeio.anytype.presentation.relations.view
|
||||
|
||||
fun ObjectViewDetails.getStruct(id: Id): Struct? = details[id]
|
||||
fun ObjectViewDetails.containsObject(id: Id): Boolean {
|
||||
return details.containsKey(id) && details[id]?.isValidObject() == true
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getObject(id: Id): ObjectWrapper.Basic? {
|
||||
return details[id]?.toObject()
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getOptionObject(id: Id): ObjectWrapper.Option? {
|
||||
return details[id]?.mapToOptionObject()
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getFileObject(id: Id): ObjectWrapper.File? {
|
||||
return details[id]?.toFileObject()
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getTypeObject(id: Id): ObjectWrapper.Type? {
|
||||
return details[id]?.mapToObjectWrapperType()
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getDateObject(id: Id): ObjectWrapper.Date? {
|
||||
return details[id]?.toDateObject()
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getBookmarkObject(id: Id): ObjectWrapper.Bookmark? {
|
||||
return details[id]?.toBookmarkObject()
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getInternalFlagsObject(id: Id): ObjectWrapper.ObjectInternalFlags? {
|
||||
return details[id]?.toInternalFlagsObject()
|
||||
}
|
||||
|
||||
suspend fun ObjectViewDetails.getObjRelationsViews(
|
||||
ctx: Id,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
fieldParser: FieldParser,
|
||||
urlBuilder: UrlBuilder
|
||||
): List<ObjectRelationView> {
|
||||
val currentObject = getObject(ctx)
|
||||
if (currentObject == null || !currentObject.isValid) return emptyList()
|
||||
val keys = currentObject.map.keys.toList()
|
||||
return storeOfRelations.getByKeys(keys).map {
|
||||
it.view(
|
||||
details = this,
|
||||
values = currentObject.map,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
isFeatured = currentObject.featuredRelations.contains(it.key)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun ObjectViewDetails.getRecommendedRelations(
|
||||
ctx: Id,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
fieldParser: FieldParser,
|
||||
urlBuilder: UrlBuilder
|
||||
): List<ObjectRelationView> {
|
||||
val currentObject = getObject(ctx)
|
||||
if (currentObject == null || !currentObject.isValid) return emptyList()
|
||||
val typeObjectId = currentObject.getProperType()
|
||||
if (typeObjectId == null) return emptyList()
|
||||
val typeObject = getTypeObject(typeObjectId)
|
||||
if (typeObject == null) return emptyList()
|
||||
val recommendedRelations = typeObject.recommendedRelations
|
||||
val notIncludedRecommendedRelations = getNotIncludedRecommendedRelations(
|
||||
relationKeys = currentObject.map.keys,
|
||||
recommendedRelations = recommendedRelations,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
return notIncludedRecommendedRelations.map {
|
||||
it.view(
|
||||
details = this,
|
||||
values = currentObject.map,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
isFeatured = currentObject.featuredRelations.contains(it.key)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun ObjectViewDetails.getTypeForObject(currentObjectId: Id): ObjectWrapper.Type? {
|
||||
val currentObject = getObject(currentObjectId)
|
||||
val type = currentObject?.getProperType()
|
||||
if (type != null) {
|
||||
val objType = getTypeObject(type)
|
||||
if (objType != null) {
|
||||
return objType
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
|
@ -46,13 +46,14 @@ import com.anytypeio.anytype.core_models.Key
|
|||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.TextStyle
|
||||
import com.anytypeio.anytype.core_models.ThemeMode
|
||||
import com.anytypeio.anytype.core_models.WidgetLayout
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.getSingleValue
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
||||
import com.anytypeio.anytype.core_models.primitives.RelationKey
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.core_utils.ext.Mimetype
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
|
@ -65,7 +66,6 @@ import com.anytypeio.anytype.presentation.sets.viewerByIdOrFirst
|
|||
import com.anytypeio.anytype.presentation.widgets.Widget
|
||||
import com.anytypeio.anytype.presentation.widgets.source.BundledWidgetSourceView
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import timber.log.Timber
|
||||
|
||||
fun Block.Prototype.getAnalyticsEvent(
|
||||
eventName: String,
|
||||
|
@ -290,7 +290,7 @@ fun Relation.Format.getPropName() = when (this) {
|
|||
|
||||
fun CoroutineScope.sendAnalyticsObjectShowEvent(
|
||||
ctx: Id,
|
||||
details: Map<Id, Block.Fields>?,
|
||||
details: Map<Id, Struct>,
|
||||
analytics: Analytics,
|
||||
startTime: Long,
|
||||
spaceParams: AnalyticSpaceHelperDelegate.Params
|
||||
|
@ -474,7 +474,7 @@ fun CoroutineScope.sendAnalyticsMoveToBinEvent(
|
|||
|
||||
fun CoroutineScope.sendAnalyticsDuplicateEvent(
|
||||
analytics: Analytics,
|
||||
details: Map<Id, Block.Fields>?,
|
||||
details: Map<Id, Struct>,
|
||||
ctx: Id,
|
||||
startTime: Long,
|
||||
count: Int = 1,
|
||||
|
@ -1933,7 +1933,7 @@ fun CoroutineScope.sendAnalyticsSelectTemplateEvent(
|
|||
|
||||
fun CoroutineScope.sendAnalyticsCreateTemplateEvent(
|
||||
analytics: Analytics,
|
||||
details: Map<Id, Block.Fields>,
|
||||
details: Map<Id, Struct>,
|
||||
ctx: Id,
|
||||
startTime: Long,
|
||||
spaceParams: AnalyticSpaceHelperDelegate.Params
|
||||
|
@ -1980,14 +1980,16 @@ fun CoroutineScope.sendAnalyticsDefaultTemplateEvent(
|
|||
}
|
||||
|
||||
private fun getAnalyticsObjectType(
|
||||
details: Map<Id, Block.Fields>?,
|
||||
details: Map<Id, Struct>,
|
||||
ctx: Id
|
||||
): String? {
|
||||
if (details == null) return null
|
||||
val objTypeId = details[ctx]?.type?.firstOrNull()
|
||||
val typeStruct = details[objTypeId]?.map
|
||||
val objType = typeStruct?.mapToObjectWrapperType()
|
||||
return objType?.sourceObject ?: OBJ_TYPE_CUSTOM
|
||||
val objTypeId = details[ctx]?.getSingleValue<String>(Relations.TYPE)
|
||||
val sourceObject = if (objTypeId != null){
|
||||
details[objTypeId]?.getSingleValue<String>(Relations.SOURCE_OBJECT)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
return sourceObject ?: OBJ_TYPE_CUSTOM
|
||||
}
|
||||
|
||||
fun CoroutineScope.sendAnalyticsCreateLink(
|
||||
|
|
|
@ -105,7 +105,7 @@ fun List<Block>.getFileDetailsForBlock(
|
|||
return null
|
||||
}
|
||||
|
||||
val fileObject = orchestrator.stores.details.getAsObject(target = targetObjectId)
|
||||
val fileObject = orchestrator.stores.details.current().getObject(targetObjectId)
|
||||
if (fileObject == null) {
|
||||
Timber.e("Object with id $targetObjectId not found.")
|
||||
return null
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
|||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.editor.Editor.Mode
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel.Companion.INITIAL_INDENT
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.render.BlockViewRenderer
|
||||
|
@ -502,8 +502,7 @@ class VersionHistoryViewModel(
|
|||
val event = payload.events
|
||||
.filterIsInstance<Event.Command.ShowObject>()
|
||||
.first()
|
||||
val obj =
|
||||
ObjectWrapper.Basic(event.details.details[vmParams.objectId]?.map.orEmpty())
|
||||
val obj = ObjectWrapper.Basic(event.details[vmParams.objectId].orEmpty())
|
||||
val currentState = _previewViewState.value
|
||||
if (currentState !is VersionHistoryPreviewScreen.Hidden) {
|
||||
parseObject(
|
||||
|
@ -535,7 +534,7 @@ class VersionHistoryViewModel(
|
|||
focus = Editor.Focus.empty(),
|
||||
anchor = vmParams.objectId,
|
||||
indent = INITIAL_INDENT,
|
||||
details = event.details,
|
||||
details = ObjectViewDetails(event.details),
|
||||
restrictions = event.objectRestrictions,
|
||||
selection = emptySet()
|
||||
).filterNot { it is BlockView.DataView }
|
||||
|
@ -572,7 +571,7 @@ class VersionHistoryViewModel(
|
|||
focus = Editor.Focus.empty(),
|
||||
anchor = vmParams.objectId,
|
||||
indent = INITIAL_INDENT,
|
||||
details = event.details,
|
||||
details = ObjectViewDetails(event.details),
|
||||
restrictions = event.objectRestrictions,
|
||||
selection = emptySet()
|
||||
)
|
||||
|
|
|
@ -15,7 +15,9 @@ import com.anytypeio.anytype.domain.config.DebugSettings
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.mention.createMentionMarkup
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.Alignment
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
|
@ -41,7 +43,7 @@ fun Block.Content.File.toPictureView(
|
|||
background: ThemeColor,
|
||||
isPreviousBlockMedia: Boolean,
|
||||
decorations: List<BlockView.Decoration>,
|
||||
details: Block.Details = Block.Details(),
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser
|
||||
): BlockView = when (state) {
|
||||
Block.Content.File.State.EMPTY -> BlockView.MediaPlaceholder.Picture(
|
||||
|
@ -64,11 +66,11 @@ fun Block.Content.File.toPictureView(
|
|||
Block.Content.File.State.DONE -> {
|
||||
|
||||
val url = urlBuilder.getUrlForFileContent(this)
|
||||
val currentObject = ObjectWrapper.Basic(details.details[context]?.map.orEmpty())
|
||||
val targetObject = ObjectWrapper.Basic(details.details[targetObjectId]?.map.orEmpty())
|
||||
val currentObject = details.getObject(id = context)
|
||||
val targetObject = details.getObject(id = targetObjectId)
|
||||
|
||||
if (url != null && targetObject.isValid && targetObject.notDeletedNorArchived) {
|
||||
if (currentObject.layout == ObjectType.Layout.IMAGE) {
|
||||
if (url != null && targetObject != null && targetObject.isValid && targetObject.notDeletedNorArchived) {
|
||||
if (currentObject?.layout == ObjectType.Layout.IMAGE) {
|
||||
BlockView.ButtonOpenFile.ImageButton(
|
||||
id = blockId,
|
||||
targetId = targetObjectId
|
||||
|
@ -121,7 +123,7 @@ fun Block.Content.File.toVideoView(
|
|||
background: ThemeColor,
|
||||
isPrevBlockMedia: Boolean,
|
||||
decorations: List<BlockView.Decoration>,
|
||||
details: Block.Details = Block.Details(),
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser
|
||||
): BlockView = when (state) {
|
||||
Block.Content.File.State.EMPTY -> BlockView.MediaPlaceholder.Video(
|
||||
|
@ -144,11 +146,11 @@ fun Block.Content.File.toVideoView(
|
|||
Block.Content.File.State.DONE -> {
|
||||
|
||||
val url = urlBuilder.getUrlForFileContent(this)
|
||||
val currentObject = ObjectWrapper.Basic(details.details[context]?.map.orEmpty())
|
||||
val targetObject = ObjectWrapper.Basic(details.details[targetObjectId]?.map.orEmpty())
|
||||
val currentObject = details.getObject(id = context)
|
||||
val targetObject = details.getObject(id = targetObjectId)
|
||||
|
||||
if (url != null && targetObject.isValid && targetObject.notDeletedNorArchived) {
|
||||
if (currentObject.layout == ObjectType.Layout.VIDEO) {
|
||||
if (url != null && targetObject != null && targetObject.isValid && targetObject.notDeletedNorArchived) {
|
||||
if (currentObject?.layout == ObjectType.Layout.VIDEO) {
|
||||
BlockView.ButtonOpenFile.FileButton(
|
||||
id = blockId,
|
||||
targetId = targetObjectId
|
||||
|
@ -201,7 +203,7 @@ fun Block.Content.File.toFileView(
|
|||
background: ThemeColor,
|
||||
isPrevBlockMedia: Boolean,
|
||||
decorations: List<BlockView.Decoration>,
|
||||
details: Block.Details = Block.Details(),
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser
|
||||
): BlockView = when (state) {
|
||||
Block.Content.File.State.EMPTY -> BlockView.MediaPlaceholder.File(
|
||||
|
@ -224,11 +226,12 @@ fun Block.Content.File.toFileView(
|
|||
Block.Content.File.State.DONE -> {
|
||||
|
||||
val url = urlBuilder.getUrlForFileContent(this)
|
||||
val currentObject = ObjectWrapper.Basic(details.details[context]?.map.orEmpty())
|
||||
val targetObject = ObjectWrapper.Basic(details.details[targetObjectId]?.map.orEmpty())
|
||||
val currentObject = details.getObject(id = context)
|
||||
val targetObject = details.getObject(id = targetObjectId)
|
||||
|
||||
if (url != null && targetObject.isValid && targetObject.notDeletedNorArchived) {
|
||||
if (SupportedLayouts.fileLayouts.contains(currentObject.layout)) {
|
||||
if (url != null && targetObject != null && targetObject.isValid && targetObject.notDeletedNorArchived) {
|
||||
val layout = currentObject?.layout
|
||||
if (layout != null && SupportedLayouts.fileLayouts.contains(layout)) {
|
||||
BlockView.ButtonOpenFile.FileButton(
|
||||
id = blockId,
|
||||
targetId = targetObjectId
|
||||
|
@ -282,7 +285,7 @@ fun Block.Align.toView(): Alignment = when (this) {
|
|||
|
||||
fun Block.Content.Text.marks(
|
||||
urlBuilder: UrlBuilder,
|
||||
details: Block.Details
|
||||
details: ObjectViewDetails
|
||||
): List<Markup.Mark> = marks
|
||||
.filterByRange(text.length)
|
||||
.mapNotNull { mark ->
|
||||
|
@ -345,32 +348,29 @@ fun Block.Content.Text.marks(
|
|||
)
|
||||
}
|
||||
Block.Content.Text.Mark.Type.MENTION -> {
|
||||
|
||||
val wrapper = if (!details.details.containsKey(mark.param)) {
|
||||
val param = mark.param
|
||||
if (param.isNullOrBlank()) {
|
||||
null
|
||||
} else {
|
||||
ObjectWrapper.Basic(map = details.details[mark.param]?.map ?: emptyMap())
|
||||
mark.createMentionMarkup(
|
||||
obj = details.getObject(id = param),
|
||||
urlBuilder = urlBuilder
|
||||
)
|
||||
}
|
||||
|
||||
mark.createMentionMarkup(
|
||||
obj = wrapper,
|
||||
urlBuilder = urlBuilder
|
||||
)
|
||||
}
|
||||
Block.Content.Text.Mark.Type.OBJECT -> {
|
||||
val wrapper = if (!details.details.containsKey(mark.param)) {
|
||||
val param = mark.param
|
||||
if (param.isNullOrBlank()) {
|
||||
null
|
||||
} else {
|
||||
ObjectWrapper.Basic(map = details.details[mark.param]?.map ?: emptyMap())
|
||||
val wrapper = details.getObject(id = param)
|
||||
Markup.Mark.Object(
|
||||
from = mark.range.first,
|
||||
to = mark.range.last,
|
||||
param = param,
|
||||
isArchived = wrapper?.isArchived == true
|
||||
)
|
||||
}
|
||||
val param = mark.param
|
||||
if (param.isNullOrBlank()) null
|
||||
else Markup.Mark.Object(
|
||||
from = mark.range.first,
|
||||
to = mark.range.last,
|
||||
param = param,
|
||||
isArchived = wrapper?.isArchived == true
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.anytypeio.anytype.presentation.objects.menu
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.objects.menu.ObjectMenuOptionsProvider.Options
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
@ -15,20 +14,18 @@ import kotlinx.coroutines.flow.map
|
|||
import timber.log.Timber
|
||||
|
||||
class ObjectMenuOptionsProviderImpl(
|
||||
private val details: Flow<Map<Id, Block.Fields>>,
|
||||
private val restrictions: Flow<List<ObjectRestriction>>,
|
||||
private val featureToggles: FeatureToggles,
|
||||
private val objectViewDetailsFlow: Flow<ObjectViewDetails>,
|
||||
private val restrictions: Flow<List<ObjectRestriction>>
|
||||
) : ObjectMenuOptionsProvider {
|
||||
|
||||
private fun observeLayout(ctx: Id): Flow<ObjectType.Layout?> = details
|
||||
private fun observeLayout(ctx: Id): Flow<ObjectType.Layout?> = objectViewDetailsFlow
|
||||
.filter { details ->
|
||||
details.containsKey(ctx).also { isValuePresent ->
|
||||
details.details.containsKey(ctx).also { isValuePresent ->
|
||||
if (!isValuePresent) Timber.w("Details missing for object: $ctx")
|
||||
}
|
||||
}
|
||||
.map { details ->
|
||||
val fields = requireNotNull(details[ctx])
|
||||
ObjectWrapper.Basic(fields.map).layout
|
||||
details.getObject(ctx)?.layout
|
||||
}
|
||||
|
||||
override fun provide(ctx: Id, isLocked: Boolean, isReadOnly: Boolean): Flow<Options> {
|
||||
|
|
|
@ -8,10 +8,8 @@ import com.anytypeio.anytype.analytics.base.EventsDictionary
|
|||
import com.anytypeio.anytype.analytics.base.sendEvent
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.domain.base.fold
|
||||
|
@ -38,9 +36,11 @@ import com.anytypeio.anytype.presentation.extension.sendAnalyticsDefaultTemplate
|
|||
import com.anytypeio.anytype.presentation.objects.ObjectAction
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts.fileLayouts
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts.systemLayouts
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceAccessType
|
||||
import com.anytypeio.anytype.domain.multiplayer.GetSpaceInviteLink
|
||||
import com.anytypeio.anytype.domain.multiplayer.SpaceViewSubscriptionContainer
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeObject
|
||||
import com.anytypeio.anytype.presentation.objects.getProperType
|
||||
import com.anytypeio.anytype.presentation.objects.isTemplatesAllowed
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.presentation.util.downloader.DebugGoroutinesShareDownloader
|
||||
|
@ -112,8 +112,8 @@ class ObjectMenuViewModel(
|
|||
isReadOnly: Boolean
|
||||
): List<ObjectAction> = buildList {
|
||||
|
||||
val wrapper = ObjectWrapper.Basic(storage.details.current().details[ctx]?.map.orEmpty())
|
||||
val layout = wrapper.layout
|
||||
val wrapper = storage.details.current().getObject(ctx)
|
||||
val layout = wrapper?.layout
|
||||
|
||||
if (isReadOnly) {
|
||||
add(ObjectAction.COPY_LINK)
|
||||
|
@ -152,15 +152,15 @@ class ObjectMenuViewModel(
|
|||
|
||||
add(ObjectAction.UNDO_REDO)
|
||||
|
||||
val details = storage.details.current().details
|
||||
val objTypeId = details[ctx]?.type?.firstOrNull()
|
||||
val typeStruct = details[objTypeId]?.map
|
||||
val objType = typeStruct?.mapToObjectWrapperType()
|
||||
val objTypeId = wrapper?.getProperType()
|
||||
if (objTypeId != null) {
|
||||
val objType = storage.details.current().getTypeObject(objTypeId)
|
||||
if (objType != null) {
|
||||
val isTemplateAllowed = objType.isTemplatesAllowed()
|
||||
if (isTemplateAllowed && !isTemplate) {
|
||||
add(ObjectAction.USE_AS_TEMPLATE)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isTemplate) {
|
||||
add(ObjectAction.LINK_TO)
|
||||
|
@ -340,9 +340,8 @@ class ObjectMenuViewModel(
|
|||
proceedWithSettingAsDefaultTemplate(ctx = ctx)
|
||||
}
|
||||
ObjectAction.CREATE_WIDGET -> {
|
||||
val details = storage.details.current().details[ctx]
|
||||
val wrapper = ObjectWrapper.Basic(details?.map ?: emptyMap())
|
||||
proceedWithCreatingWidget(obj = wrapper)
|
||||
val wrapper = storage.details.current().getObject(ctx)
|
||||
if (wrapper != null) proceedWithCreatingWidget(obj = wrapper)
|
||||
}
|
||||
ObjectAction.MOVE_TO,
|
||||
ObjectAction.MOVE_TO_BIN,
|
||||
|
@ -361,9 +360,8 @@ class ObjectMenuViewModel(
|
|||
|
||||
private fun proceedWithSettingAsDefaultTemplate(ctx: Id) {
|
||||
val startTime = System.currentTimeMillis()
|
||||
val details = storage.details.current().details
|
||||
val objTemplate = ObjectWrapper.Basic(details[ctx]?.map ?: emptyMap())
|
||||
val targetObjectTypeId = objTemplate.targetObjectType ?: return
|
||||
val objTemplate = storage.details.current().getObject(ctx)
|
||||
val targetObjectTypeId = objTemplate?.targetObjectType ?: return
|
||||
viewModelScope.launch {
|
||||
val params = SetObjectDetails.Params(
|
||||
ctx = targetObjectTypeId,
|
||||
|
@ -371,7 +369,7 @@ class ObjectMenuViewModel(
|
|||
)
|
||||
setObjectDetails.async(params).fold(
|
||||
onSuccess = {
|
||||
val objType = details[targetObjectTypeId]?.map?.mapToObjectWrapperType()
|
||||
val objType = storage.details.current().getTypeObject(targetObjectTypeId)
|
||||
sendAnalyticsDefaultTemplateEvent(analytics, objType, startTime)
|
||||
_toasts.emit("The template was set as default")
|
||||
isDismissed.value = true
|
||||
|
@ -413,22 +411,24 @@ class ObjectMenuViewModel(
|
|||
}
|
||||
|
||||
private suspend fun buildOpenTemplateCommand(ctx: Id, space: Id, template: Id) {
|
||||
val details = storage.details.current().details
|
||||
val type = details[ctx]?.type?.firstOrNull()
|
||||
val typeStruct = details[type]?.map
|
||||
val objType = typeStruct?.mapToObjectWrapperType()
|
||||
if (objType != null) {
|
||||
val objTypeKey = objType.uniqueKey
|
||||
val command = Command.OpenTemplate(
|
||||
templateId = template,
|
||||
typeId = objType.id,
|
||||
typeKey = objTypeKey,
|
||||
typeName = objType.name.orEmpty(),
|
||||
space = space
|
||||
)
|
||||
commands.emit(command)
|
||||
val type = storage.details.current().getObject(ctx)?.getProperType()
|
||||
if (type != null) {
|
||||
val objType = storage.details.current().getTypeObject(type)
|
||||
if (objType != null) {
|
||||
val objTypeKey = objType.uniqueKey
|
||||
val command = Command.OpenTemplate(
|
||||
templateId = template,
|
||||
typeId = objType.id,
|
||||
typeKey = objTypeKey,
|
||||
typeName = objType.name.orEmpty(),
|
||||
space = space
|
||||
)
|
||||
commands.emit(command)
|
||||
} else {
|
||||
Timber.e("Error while opening template from object, type:$type hasn't key")
|
||||
}
|
||||
} else {
|
||||
Timber.e("Error while opening template from object, type:$type hasn't key")
|
||||
Timber.e("Error while opening template from object, object hasn't type")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ package com.anytypeio.anytype.presentation.objects.menu
|
|||
import android.net.Uri
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.WidgetLayout
|
||||
import com.anytypeio.anytype.core_models.isDataView
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceAccessType
|
||||
|
@ -354,7 +354,7 @@ abstract class ObjectMenuViewModelBase(
|
|||
}
|
||||
}
|
||||
|
||||
fun proceedWithDuplication(ctx: Id, space: Id, details: Map<Id, Block.Fields>?) {
|
||||
fun proceedWithDuplication(ctx: Id, space: Id, details: Map<Id, Struct>) {
|
||||
Timber.d("proceedWithDuplication, ctx:[$ctx]")
|
||||
val startTime = System.currentTimeMillis()
|
||||
viewModelScope.launch {
|
||||
|
|
|
@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
|
@ -25,6 +24,7 @@ import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
|||
import com.anytypeio.anytype.presentation.common.Action
|
||||
import com.anytypeio.anytype.presentation.common.Delegator
|
||||
import com.anytypeio.anytype.presentation.common.PayloadDelegator
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectAction
|
||||
import com.anytypeio.anytype.presentation.sets.dataViewState
|
||||
import com.anytypeio.anytype.presentation.sets.state.ObjectState
|
||||
|
@ -208,6 +208,7 @@ class ObjectSetMenuViewModel(
|
|||
}
|
||||
|
||||
override fun onActionClicked(ctx: Id, space: Id, action: ObjectAction) {
|
||||
val state = objectState.value.dataViewState() ?: return
|
||||
when (action) {
|
||||
ObjectAction.DELETE -> {
|
||||
proceedWithUpdatingArchivedStatus(ctx = ctx, isArchived = true)
|
||||
|
@ -228,13 +229,12 @@ class ObjectSetMenuViewModel(
|
|||
proceedWithDuplication(
|
||||
ctx = ctx,
|
||||
space = space,
|
||||
details = objectState.value.dataViewState()?.details
|
||||
details = state.details.details
|
||||
)
|
||||
}
|
||||
ObjectAction.CREATE_WIDGET -> {
|
||||
val details = objectState.value.dataViewState()?.details?.get(ctx)
|
||||
val wrapper = ObjectWrapper.Basic(details?.map ?: emptyMap())
|
||||
proceedWithCreatingWidget(obj = wrapper)
|
||||
val wrapper = state.details.getObject(ctx)
|
||||
if (wrapper != null) proceedWithCreatingWidget(obj = wrapper)
|
||||
}
|
||||
ObjectAction.COPY_LINK -> {
|
||||
viewModelScope.launch {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.anytypeio.anytype.presentation.relations
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.CoverType
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
|
@ -133,19 +132,6 @@ interface CoverWrapper {
|
|||
val coverId: String?
|
||||
}
|
||||
|
||||
class BlockFieldsCoverWrapper(val fields: Block.Fields?) : CoverWrapper {
|
||||
|
||||
override val coverType: CoverType
|
||||
get() {
|
||||
val value = fields?.coverType?.toInt() ?: return CoverType.NONE
|
||||
return CoverType.values().find { type ->
|
||||
type.code == value
|
||||
} ?: CoverType.NONE
|
||||
}
|
||||
|
||||
override val coverId = fields?.coverId
|
||||
}
|
||||
|
||||
class BasicObjectCoverWrapper(val obj: ObjectWrapper.Basic?) : CoverWrapper {
|
||||
override val coverType = obj?.coverType ?: CoverType.NONE
|
||||
override val coverId = obj?.coverId
|
||||
|
|
|
@ -15,12 +15,12 @@ import com.anytypeio.anytype.domain.relations.RemoveFromFeaturedRelations
|
|||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.objects.LockedStateProvider
|
||||
import com.anytypeio.anytype.presentation.relations.RelationListViewModel.VmParams
|
||||
import com.anytypeio.anytype.presentation.relations.providers.RelationListProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationListProvider
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
||||
class ObjectRelationListViewModelFactory(
|
||||
private val vmParams: VmParams,
|
||||
private val relationListProvider: RelationListProvider,
|
||||
private val objectRelationListProvider: ObjectRelationListProvider,
|
||||
private val lockedStateProvider: LockedStateProvider,
|
||||
private val urlBuilder: UrlBuilder,
|
||||
private val dispatcher: Dispatcher<Payload>,
|
||||
|
@ -39,7 +39,7 @@ class ObjectRelationListViewModelFactory(
|
|||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return RelationListViewModel(
|
||||
vmParams = vmParams,
|
||||
relationListProvider = relationListProvider,
|
||||
objectRelationListProvider = objectRelationListProvider,
|
||||
lockedStateProvider = lockedStateProvider,
|
||||
urlBuilder = urlBuilder,
|
||||
dispatcher = dispatcher,
|
||||
|
|
|
@ -27,12 +27,13 @@ import com.anytypeio.anytype.core_utils.ext.TOMORROW
|
|||
import com.anytypeio.anytype.core_utils.ext.YESTERDAY
|
||||
import com.anytypeio.anytype.core_utils.ext.orNull
|
||||
import com.anytypeio.anytype.core_utils.ext.typeOf
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.extension.isValueRequired
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
|
@ -202,19 +203,18 @@ fun title(
|
|||
ctx: Id,
|
||||
coverImageHashProvider: CoverImageHashProvider,
|
||||
urlBuilder: UrlBuilder,
|
||||
details: Map<Id, Block.Fields>
|
||||
details: ObjectViewDetails
|
||||
): BlockView.Title.Basic {
|
||||
val wrapper = ObjectWrapper.Basic(details[ctx]?.map ?: emptyMap())
|
||||
val objectDetails = details[ctx]
|
||||
val coverContainer = BlockFieldsCoverWrapper(objectDetails).getCover(
|
||||
val wrapper = details.getObject(ctx)
|
||||
val coverContainer = BasicObjectCoverWrapper(wrapper).getCover(
|
||||
urlBuilder = urlBuilder,
|
||||
coverImageHashProvider = coverImageHashProvider
|
||||
)
|
||||
return BlockView.Title.Basic(
|
||||
id = title.id,
|
||||
text = wrapper.name.orEmpty(),
|
||||
emoji = wrapper.iconEmoji.orNull(),
|
||||
image = wrapper.iconImage?.takeIf { it.isNotBlank() }?.let { urlBuilder.medium(it) },
|
||||
text = wrapper?.name.orEmpty(),
|
||||
emoji = wrapper?.iconEmoji.orNull(),
|
||||
image = wrapper?.iconImage?.takeIf { it.isNotBlank() }?.let { urlBuilder.medium(it) },
|
||||
coverImage = coverContainer.coverImage,
|
||||
coverColor = coverContainer.coverColor,
|
||||
coverGradient = coverContainer.coverGradient
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.anytypeio.anytype.core_utils.const.DateConst
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getOptionObject
|
||||
import com.anytypeio.anytype.presentation.extension.hasValue
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.sets.*
|
||||
|
@ -14,14 +16,14 @@ import com.anytypeio.anytype.presentation.sets.model.Viewer
|
|||
import java.util.*
|
||||
|
||||
fun List<ObjectWrapper.Relation>.views(
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
featured: List<Id> = emptyList(),
|
||||
fieldParser: FieldParser
|
||||
): List<ObjectRelationView> = mapNotNull { relation ->
|
||||
relation.view(
|
||||
details = details.details,
|
||||
details = details,
|
||||
values = values,
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = featured.contains(relation.key),
|
||||
|
@ -32,7 +34,7 @@ fun List<ObjectWrapper.Relation>.views(
|
|||
fun Key.isSystemKey() : Boolean = Relations.systemRelationKeys.contains(this)
|
||||
|
||||
fun ObjectWrapper.Relation.view(
|
||||
details: Map<Id, Block.Fields>,
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
isFeatured: Boolean = false,
|
||||
|
@ -86,24 +88,11 @@ fun ObjectWrapper.Relation.view(
|
|||
}
|
||||
RelationFormat.STATUS -> {
|
||||
val options = buildList {
|
||||
when(val value = values[relation.key]) {
|
||||
is Id -> {
|
||||
val status = details[value]
|
||||
if (status != null && status.map.isNotEmpty()) {
|
||||
add(
|
||||
ObjectWrapper.Option(status.map)
|
||||
)
|
||||
}
|
||||
}
|
||||
is List<*> -> {
|
||||
value.forEach { id ->
|
||||
val status = details[id]
|
||||
if (status != null && status.map.isNotEmpty()) {
|
||||
add(
|
||||
ObjectWrapper.Option(status.map)
|
||||
)
|
||||
}
|
||||
}
|
||||
val statusValue = values.getSingleValue<String>(relation.key)
|
||||
if (statusValue != null) {
|
||||
val status = details.getOptionObject(statusValue)
|
||||
if (status != null) {
|
||||
add(status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,25 +112,9 @@ fun ObjectWrapper.Relation.view(
|
|||
}
|
||||
RelationFormat.TAG -> {
|
||||
val options = buildList {
|
||||
when(val value = values[relation.key]) {
|
||||
is Id -> {
|
||||
val status = details[value]
|
||||
if (status != null && status.map.isNotEmpty()) {
|
||||
add(
|
||||
ObjectWrapper.Option(status.map)
|
||||
)
|
||||
}
|
||||
}
|
||||
is List<*> -> {
|
||||
value.forEach { id ->
|
||||
val status = details[id]
|
||||
if (status != null && status.map.isNotEmpty()) {
|
||||
add(
|
||||
ObjectWrapper.Option(status.map)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
values[relation.key].values<String>().forEach { id ->
|
||||
val status = details.getOptionObject(id)
|
||||
if (status != null) add(status)
|
||||
}
|
||||
}
|
||||
val tags = values.buildTagViews(
|
||||
|
@ -235,7 +208,7 @@ fun ColumnView.getDateRelationFormat(): String {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of distinct [ObjectWrapper.Relation] relations of Object using the given relation links filtered by system relations.
|
||||
* Retrieves a list of distinct [ObjectWrapper.Relation] relations of Object using the given relation keys filtered by system relations.
|
||||
*
|
||||
* @param relationKeys The list of object details keys
|
||||
* @param systemRelations The list of keys of the system relations. Final list will be filtered by this list.
|
||||
|
|
|
@ -7,14 +7,12 @@ import com.anytypeio.anytype.analytics.base.EventsDictionary.objectRelationFeatu
|
|||
import com.anytypeio.anytype.analytics.base.EventsDictionary.objectRelationUnfeature
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary.relationsScreenShow
|
||||
import com.anytypeio.anytype.analytics.base.sendEvent
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.TimeInMillis
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_utils.diff.DefaultObjectDiffIdentifier
|
||||
import com.anytypeio.anytype.domain.base.fold
|
||||
|
@ -29,11 +27,15 @@ import com.anytypeio.anytype.domain.relations.RemoveFromFeaturedRelations
|
|||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.common.BaseViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getStruct
|
||||
import com.anytypeio.anytype.presentation.extension.getObjRelationsViews
|
||||
import com.anytypeio.anytype.presentation.extension.getRecommendedRelations
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeForObject
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsRelationEvent
|
||||
import com.anytypeio.anytype.presentation.objects.LockedStateProvider
|
||||
import com.anytypeio.anytype.presentation.objects.getProperType
|
||||
import com.anytypeio.anytype.presentation.relations.model.RelationOperationError
|
||||
import com.anytypeio.anytype.presentation.relations.providers.RelationListProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationListProvider
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
@ -44,7 +46,7 @@ import timber.log.Timber
|
|||
|
||||
class RelationListViewModel(
|
||||
private val vmParams: VmParams,
|
||||
private val relationListProvider: RelationListProvider,
|
||||
private val objectRelationListProvider: ObjectRelationListProvider,
|
||||
private val lockedStateProvider: LockedStateProvider,
|
||||
private val urlBuilder: UrlBuilder,
|
||||
private val dispatcher: Dispatcher<Payload>,
|
||||
|
@ -79,7 +81,7 @@ class RelationListViewModel(
|
|||
jobs += viewModelScope.launch {
|
||||
combine(
|
||||
storeOfRelations.trackChanges(),
|
||||
relationListProvider.details
|
||||
objectRelationListProvider.details
|
||||
) { _, details ->
|
||||
constructViews(ctx, details)
|
||||
}.collect { views.value = it }
|
||||
|
@ -88,88 +90,46 @@ class RelationListViewModel(
|
|||
|
||||
private suspend fun constructViews(
|
||||
ctx: Id,
|
||||
details: Block.Details
|
||||
details: ObjectViewDetails
|
||||
): List<Model> {
|
||||
|
||||
val objectDetails = details.details[ctx]?.map ?: emptyMap()
|
||||
val objectWrapper = ObjectWrapper.Basic(objectDetails)
|
||||
val objectTypeId = objectWrapper.getProperType()
|
||||
val objectTypeWrapper = details.details[objectTypeId]?.map?.mapToObjectWrapperType()
|
||||
if (objectTypeWrapper == null) {
|
||||
Timber.e("Couldn't find valid object type for id: $objectTypeId")
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val objectRelationViews = getObjectRelationsView(
|
||||
val objectRelationViews = details.getObjRelationsViews(
|
||||
ctx = ctx,
|
||||
objectDetails = objectDetails,
|
||||
details = details,
|
||||
objectWrapper = objectWrapper
|
||||
)
|
||||
|
||||
val recommendedRelationViews = getRecommendedRelations(
|
||||
ctx = ctx,
|
||||
objectDetails = objectDetails,
|
||||
objectTypeWrapper = objectTypeWrapper,
|
||||
details = details
|
||||
)
|
||||
|
||||
return buildFinalList(objectRelationViews, recommendedRelationViews, objectTypeWrapper)
|
||||
}
|
||||
|
||||
private suspend fun getObjectRelationsView(
|
||||
ctx: Id,
|
||||
objectDetails: Map<Key, Any?>,
|
||||
details: Block.Details,
|
||||
objectWrapper: ObjectWrapper.Basic
|
||||
): List<Model.Item> {
|
||||
return getObjectRelations(
|
||||
systemRelations = listOf(),
|
||||
relationKeys = objectDetails.keys,
|
||||
storeOfRelations = storeOfRelations
|
||||
).views(
|
||||
context = ctx,
|
||||
details = details,
|
||||
values = objectDetails,
|
||||
urlBuilder = urlBuilder,
|
||||
featured = objectWrapper.featuredRelations,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser,
|
||||
urlBuilder = urlBuilder
|
||||
).map { view ->
|
||||
Model.Item(
|
||||
view = view,
|
||||
isRemovable = isPossibleToRemoveRelation(view)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getRecommendedRelations(
|
||||
ctx: Id,
|
||||
objectDetails: Map<Key, Any?>,
|
||||
objectTypeWrapper: ObjectWrapper.Type,
|
||||
details: Block.Details
|
||||
): List<Model.Item> {
|
||||
return getNotIncludedRecommendedRelations(
|
||||
relationKeys = objectDetails.keys,
|
||||
recommendedRelations = objectTypeWrapper.recommendedRelations,
|
||||
storeOfRelations = storeOfRelations
|
||||
).views(
|
||||
context = ctx,
|
||||
details = details,
|
||||
values = objectDetails,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
val recommendedRelationViews = details.getRecommendedRelations(
|
||||
ctx = ctx,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser,
|
||||
urlBuilder = urlBuilder
|
||||
).map { view ->
|
||||
Model.Item(
|
||||
view = view,
|
||||
isRecommended = true
|
||||
)
|
||||
}
|
||||
|
||||
val objectWrapperType = details.getTypeForObject(currentObjectId = ctx)
|
||||
|
||||
return buildFinalList(
|
||||
objectRelations = objectRelationViews,
|
||||
recommendedRelations = recommendedRelationViews,
|
||||
objectTypeWrapper = objectWrapperType
|
||||
)
|
||||
}
|
||||
|
||||
private fun buildFinalList(
|
||||
objectRelations: List<Model.Item>,
|
||||
recommendedRelations: List<Model.Item>,
|
||||
objectTypeWrapper: ObjectWrapper.Type
|
||||
objectTypeWrapper: ObjectWrapper.Type?
|
||||
): MutableList<Model> {
|
||||
return mutableListOf<Model>().apply {
|
||||
val (isFeatured, other) = objectRelations.partition { it.view.featured }
|
||||
|
@ -182,7 +142,7 @@ class RelationListViewModel(
|
|||
addAll(other)
|
||||
}
|
||||
if (recommendedRelations.isNotEmpty()) {
|
||||
add(Model.Section.TypeFrom(objectTypeWrapper.name.orEmpty()))
|
||||
add(Model.Section.TypeFrom(objectTypeWrapper?.name.orEmpty()))
|
||||
addAll(recommendedRelations)
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +187,7 @@ class RelationListViewModel(
|
|||
}
|
||||
|
||||
private fun checkRelationIsInObject(view: ObjectRelationView): Boolean {
|
||||
val objectRelations = relationListProvider.getDetails().details[vmParams.objectId]?.map?.keys
|
||||
val objectRelations = objectRelationListProvider.getDetails().getStruct(vmParams.objectId)?.keys
|
||||
return objectRelations?.any { it == view.key } == true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package com.anytypeio.anytype.presentation.relations
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_utils.ext.typeOf
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.getOptionObject
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeObject
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.sets.buildFileViews
|
||||
import com.anytypeio.anytype.presentation.sets.buildRelationValueObjectViews
|
||||
|
@ -18,7 +20,7 @@ import com.anytypeio.anytype.presentation.sets.model.TagView
|
|||
|
||||
fun List<ObjectWrapper.Relation>.views(
|
||||
context: Id,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
featured: List<Id> = emptyList(),
|
||||
|
@ -36,7 +38,7 @@ fun List<ObjectWrapper.Relation>.views(
|
|||
|
||||
fun ObjectWrapper.Relation.view(
|
||||
context: Id,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
isFeatured: Boolean = false,
|
||||
|
@ -51,7 +53,7 @@ fun ObjectWrapper.Relation.view(
|
|||
RelationFormat.OBJECT -> {
|
||||
val objects = values.buildRelationValueObjectViews(
|
||||
relationKey = relation.key,
|
||||
details = details.details,
|
||||
details = details,
|
||||
builder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
)
|
||||
|
@ -68,7 +70,7 @@ fun ObjectWrapper.Relation.view(
|
|||
RelationFormat.FILE -> {
|
||||
val files = values.buildFileViews(
|
||||
relationKey = relation.key,
|
||||
details = details.details
|
||||
details = details
|
||||
)
|
||||
ObjectRelationView.File(
|
||||
id = relation.id,
|
||||
|
@ -156,15 +158,14 @@ fun ObjectWrapper.Relation.view(
|
|||
fun statusRelation(
|
||||
context: Id,
|
||||
relationDetails: ObjectWrapper.Relation,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
isFeatured: Boolean
|
||||
): ObjectRelationView? {
|
||||
val objectDetails = details.details[context]?.map ?: return null
|
||||
val objectDetails = details.getObject(context)?.map ?: return null
|
||||
val optionId = StatusParser.parse(objectDetails[relationDetails.key])
|
||||
val statuses = buildList {
|
||||
if (optionId != null) {
|
||||
val map = details.details[optionId]?.map ?: return null
|
||||
val optionDetails = ObjectWrapper.Basic(map)
|
||||
val optionDetails = details.getObject(optionId) ?: return null
|
||||
if (optionDetails.isDeleted != true) {
|
||||
add(
|
||||
StatusView(
|
||||
|
@ -190,20 +191,19 @@ fun statusRelation(
|
|||
fun tagRelation(
|
||||
context: Id,
|
||||
relationDetails: ObjectWrapper.Relation,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
isFeatured: Boolean
|
||||
): ObjectRelationView? {
|
||||
val objectDetails = details.details[context]?.map ?: return null
|
||||
val objectDetails = details.getObject(context)?.map ?: return null
|
||||
val tagViews = mutableListOf<TagView>()
|
||||
val tagIds = TagParser.parse(objectDetails[relationDetails.key])
|
||||
tagIds.forEach { id ->
|
||||
val map = details.details[id]?.map ?: emptyMap()
|
||||
val optionDetails = ObjectWrapper.Basic(map)
|
||||
if (optionDetails.isDeleted != true) {
|
||||
val optionDetails = details.getOptionObject(id)
|
||||
if (optionDetails != null && optionDetails.isDeleted != true) {
|
||||
val tagView = TagView(
|
||||
id = id,
|
||||
tag = optionDetails.name.orEmpty(),
|
||||
color = optionDetails.relationOptionColor.orEmpty()
|
||||
color = optionDetails.color
|
||||
)
|
||||
tagViews.add(tagView)
|
||||
}
|
||||
|
@ -219,13 +219,12 @@ fun tagRelation(
|
|||
)
|
||||
}
|
||||
|
||||
fun Block.Details.objectTypeRelation(
|
||||
fun ObjectViewDetails.objectTypeRelation(
|
||||
relationKey: Key,
|
||||
isFeatured: Boolean,
|
||||
objectTypeId: Id
|
||||
): ObjectRelationView {
|
||||
val typeStruct = details[objectTypeId]?.map
|
||||
val objectType = typeStruct?.mapToObjectWrapperType()
|
||||
val objectType = getTypeObject(objectTypeId)
|
||||
return if (objectType == null || objectType.isDeleted == true) {
|
||||
ObjectRelationView.ObjectType.Deleted(
|
||||
id = objectTypeId,
|
||||
|
@ -247,7 +246,7 @@ fun Block.Details.objectTypeRelation(
|
|||
}
|
||||
}
|
||||
|
||||
fun Block.Details.linksFeaturedRelation(
|
||||
fun ObjectViewDetails.linksFeaturedRelation(
|
||||
relations: List<ObjectWrapper.Relation>,
|
||||
relationKey: Key,
|
||||
ctx: Id,
|
||||
|
@ -256,8 +255,8 @@ fun Block.Details.linksFeaturedRelation(
|
|||
return when (relationKey) {
|
||||
Relations.BACKLINKS -> {
|
||||
val relation = relations.firstOrNull { it.key == relationKey } ?: return null
|
||||
val objectDetails = ObjectWrapper.Basic(details[ctx]?.map ?: return null)
|
||||
val backlinks = objectDetails.backlinks.filter {
|
||||
val objectWrapper = getObject(ctx) ?: return null
|
||||
val backlinks = objectWrapper.backlinks.filter {
|
||||
details.containsKey(it)
|
||||
}
|
||||
if (backlinks.isEmpty()) {
|
||||
|
@ -277,8 +276,8 @@ fun Block.Details.linksFeaturedRelation(
|
|||
}
|
||||
Relations.LINKS -> {
|
||||
val relation = relations.firstOrNull { it.key == relationKey } ?: return null
|
||||
val objectDetails = ObjectWrapper.Basic(details[ctx]?.map ?: return null)
|
||||
val links = objectDetails.links.filter {
|
||||
val objectWrapper = getObject(ctx) ?: return null
|
||||
val links = objectWrapper.links.filter {
|
||||
details.containsKey(it)
|
||||
}
|
||||
if (links.isEmpty()) {
|
||||
|
|
|
@ -87,7 +87,7 @@ class SetOrCollectionRelationProvider(
|
|||
}.flatMapLatest { state ->
|
||||
when (state) {
|
||||
is ObjectState.DataView.Collection -> {
|
||||
val objectKeys = state.details[id]?.map?.keys.orEmpty()
|
||||
val objectKeys = state.details.details[id]?.keys.orEmpty()
|
||||
flow {
|
||||
objectKeys.mapNotNull {
|
||||
storeOfRelations.getByKey(it)
|
||||
|
@ -95,7 +95,7 @@ class SetOrCollectionRelationProvider(
|
|||
}
|
||||
}
|
||||
is ObjectState.DataView.Set -> {
|
||||
val objectKeys = state.details[id]?.map?.keys.orEmpty()
|
||||
val objectKeys = state.details.details[id]?.keys.orEmpty()
|
||||
flow {
|
||||
objectKeys.mapNotNull {
|
||||
storeOfRelations.getByKey(it)
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation.relations.providers
|
|||
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.presentation.extension.getStruct
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.state.ObjectState
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
@ -43,10 +44,9 @@ class DataViewObjectValueProvider(
|
|||
state: ObjectState,
|
||||
target: Id
|
||||
) : Struct = when (state) {
|
||||
is ObjectState.DataView.Collection -> state.details[target]?.map ?: emptyMap()
|
||||
is ObjectState.DataView.Set -> state.details[target]?.map ?: emptyMap()
|
||||
is ObjectState.ErrorLayout -> emptyMap()
|
||||
is ObjectState.Init -> emptyMap()
|
||||
is ObjectState.DataView.Collection -> state.details.getStruct(target).orEmpty()
|
||||
is ObjectState.DataView.Set -> state.details.getStruct(target).orEmpty()
|
||||
else -> emptyMap()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,9 @@ class SetOrCollectionObjectValueProvider(
|
|||
state: ObjectState,
|
||||
target: Id
|
||||
) : Struct = when (state) {
|
||||
is ObjectState.DataView.Collection -> state.details[target]?.map ?: emptyMap()
|
||||
is ObjectState.DataView.Set -> state.details[target]?.map ?: emptyMap()
|
||||
is ObjectState.ErrorLayout -> emptyMap()
|
||||
is ObjectState.Init -> emptyMap()
|
||||
is ObjectState.DataView.Collection -> state.details.getStruct(target).orEmpty()
|
||||
is ObjectState.DataView.Set -> state.details.getStruct(target).orEmpty()
|
||||
else -> emptyMap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class DefaultObjectRelationProvider(
|
|||
) { _, details ->
|
||||
details
|
||||
}.flatMapLatest { details ->
|
||||
val objectKeys = details.details[id]?.map?.keys ?: emptyList()
|
||||
val objectKeys = details.details[id]?.keys.orEmpty()
|
||||
flow {
|
||||
objectKeys.mapNotNull {
|
||||
storeOfRelations.getByKey(it)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.anytypeio.anytype.presentation.relations.providers
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Store
|
||||
import kotlin.collections.orEmpty
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
|
@ -11,12 +11,12 @@ class DefaultObjectValueProvider(
|
|||
private val details: Store.Details
|
||||
) : ObjectValueProvider {
|
||||
override suspend fun get(ctx: Id, target: Id): Struct {
|
||||
return details.current().details.getOrDefault(target, Block.Fields.empty()).map
|
||||
return details.current().details[target].orEmpty()
|
||||
}
|
||||
|
||||
override suspend fun subscribe(ctx: Id, target: Id): Flow<Struct> {
|
||||
return details.stream().map { details ->
|
||||
details.details.getOrDefault(target, Block.Fields.empty()).map
|
||||
details.details[target].orEmpty()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package com.anytypeio.anytype.presentation.relations.providers
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
|
||||
interface ObjectDetailProvider {
|
||||
fun provide() : Map<Id, Block.Fields>
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.anytypeio.anytype.presentation.relations.providers
|
||||
|
||||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.sets.state.ObjectState
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
interface ObjectRelationListProvider {
|
||||
|
||||
val details: Flow<ObjectViewDetails>
|
||||
|
||||
fun getDetails(): ObjectViewDetails
|
||||
|
||||
class EditorRelationListProvider(
|
||||
private val storage: Editor.Storage
|
||||
) : ObjectRelationListProvider {
|
||||
override val details: Flow<ObjectViewDetails>
|
||||
get() = storage.details.stream()
|
||||
|
||||
override fun getDetails() = storage.details.current()
|
||||
}
|
||||
|
||||
class ObjectSetRelationListProvider(
|
||||
private val objectStates: StateFlow<ObjectState>
|
||||
) : ObjectRelationListProvider {
|
||||
|
||||
override val details = objectStates.map { state ->
|
||||
mapDetails(state)
|
||||
}
|
||||
|
||||
override fun getDetails(): ObjectViewDetails = mapDetails(objectStates.value)
|
||||
|
||||
private fun mapDetails(state: ObjectState) = when (state) {
|
||||
is ObjectState.DataView.Collection -> {
|
||||
state.details
|
||||
}
|
||||
|
||||
is ObjectState.DataView.Set -> {
|
||||
state.details
|
||||
}
|
||||
|
||||
else -> ObjectViewDetails.EMPTY
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package com.anytypeio.anytype.presentation.relations.providers
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.sets.state.ObjectState
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
interface RelationListProvider {
|
||||
|
||||
val details: Flow<Block.Details>
|
||||
|
||||
fun getDetails(): Block.Details
|
||||
|
||||
class EditorRelationListProvider(
|
||||
private val storage: Editor.Storage
|
||||
) : RelationListProvider {
|
||||
override val details: Flow<Block.Details>
|
||||
get() = storage.details.stream()
|
||||
|
||||
override fun getDetails() = storage.details.current()
|
||||
}
|
||||
|
||||
class ObjectSetRelationListProvider(
|
||||
private val objectStates: StateFlow<ObjectState>
|
||||
) : RelationListProvider {
|
||||
|
||||
override val details = objectStates.map { state -> mapDetails(state) }
|
||||
|
||||
override fun getDetails(): Block.Details = mapDetails(objectStates.value)
|
||||
|
||||
private fun mapDetails(state: ObjectState) = when (state) {
|
||||
is ObjectState.DataView.Collection -> {
|
||||
Block.Details(state.details)
|
||||
}
|
||||
is ObjectState.DataView.Set -> {
|
||||
Block.Details(state.details)
|
||||
}
|
||||
else -> Block.Details(emptyMap())
|
||||
}
|
||||
|
||||
private fun mapLinks(state: ObjectState) = when (state) {
|
||||
is ObjectState.DataView.Collection -> {
|
||||
state.details.keys
|
||||
}
|
||||
is ObjectState.DataView.Set -> {
|
||||
state.details.keys
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,9 +64,9 @@ class ObjectSetCreateBookmarkRecordViewModel(
|
|||
is ObjectState.DataView.Set -> {
|
||||
val setOf = state.getSetOfValue(state.root)
|
||||
if (state.isSetByRelation(setOf)) {
|
||||
val sourceDetails = state.details[setOf.firstOrNull()]
|
||||
if (sourceDetails != null && sourceDetails.map.isNotEmpty()) {
|
||||
val sourceObject = ObjectWrapper.Relation(sourceDetails.map)
|
||||
val sourceDetails = state.details.details[setOf.firstOrNull()]
|
||||
if (sourceDetails != null && sourceDetails.isNotEmpty()) {
|
||||
val sourceObject = ObjectWrapper.Relation(sourceDetails)
|
||||
val viewer = state.viewerByIdOrFirst(session.currentViewerId.value) ?: return
|
||||
val details = viewer.resolveSetByRelationPrefilledObjectData(
|
||||
objSetByRelation = sourceObject,
|
||||
|
|
|
@ -27,7 +27,6 @@ import com.anytypeio.anytype.core_models.ext.DAYS_IN_WEEK
|
|||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_models.ext.EMPTY_STRING_VALUE
|
||||
import com.anytypeio.anytype.core_models.ext.SECONDS_IN_DAY
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.ext.title
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
|
@ -41,8 +40,12 @@ import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
|||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.getProperType
|
||||
import com.anytypeio.anytype.presentation.relations.BasicObjectCoverWrapper
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig.ID_KEY
|
||||
|
@ -70,12 +73,13 @@ fun ObjectState.DataView.featuredRelations(
|
|||
val block = blocks.find { it.content is Block.Content.FeaturedRelations }
|
||||
if (block != null) {
|
||||
val views = mutableListOf<ObjectRelationView>()
|
||||
val ids = details[ctx]?.featuredRelations ?: emptyList()
|
||||
val currentObject = details.getObject(ctx)
|
||||
val ids = currentObject?.featuredRelations
|
||||
views.addAll(
|
||||
mapFeaturedRelations(
|
||||
ctx = ctx,
|
||||
keys = ids,
|
||||
details = Block.Details(details),
|
||||
details = details,
|
||||
relations = relations,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
|
@ -98,10 +102,8 @@ fun ObjectState.DataView.header(
|
|||
): SetOrCollectionHeaderState {
|
||||
val title = blocks.title()
|
||||
return if (title != null) {
|
||||
val wrapper = ObjectWrapper.Basic(
|
||||
map = details[ctx]?.map ?: emptyMap()
|
||||
)
|
||||
val featured = wrapper.featuredRelations
|
||||
val wrapper = details.getObject(ctx)
|
||||
val featured = wrapper?.featuredRelations
|
||||
SetOrCollectionHeaderState.Default(
|
||||
title = title(
|
||||
ctx = ctx,
|
||||
|
@ -110,7 +112,7 @@ fun ObjectState.DataView.header(
|
|||
details = details,
|
||||
coverImageHashProvider = coverImageHashProvider,
|
||||
),
|
||||
description = if (featured.contains(Relations.DESCRIPTION)) {
|
||||
description = if (featured?.contains(Relations.DESCRIPTION) == true) {
|
||||
SetOrCollectionHeaderState.Description.Default(
|
||||
description = wrapper.description.orEmpty()
|
||||
)
|
||||
|
@ -126,94 +128,102 @@ fun ObjectState.DataView.header(
|
|||
|
||||
private fun ObjectState.DataView.mapFeaturedRelations(
|
||||
ctx: Id,
|
||||
keys: List<String>,
|
||||
details: Block.Details,
|
||||
keys: List<String>?,
|
||||
details: ObjectViewDetails,
|
||||
relations: List<ObjectWrapper.Relation>,
|
||||
urlBuilder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
): List<ObjectRelationView> = keys.mapNotNull { key ->
|
||||
when (key) {
|
||||
Relations.DESCRIPTION -> null
|
||||
Relations.TYPE -> {
|
||||
): List<ObjectRelationView> {
|
||||
val currentObject = details.getObject(ctx) ?: return emptyList()
|
||||
val featuredRelationsIds = currentObject.featuredRelations
|
||||
return featuredRelationsIds.mapNotNull { key ->
|
||||
when (key) {
|
||||
Relations.DESCRIPTION -> null
|
||||
Relations.TYPE -> {
|
||||
val currentObjectType = currentObject.getProperType()
|
||||
if (currentObjectType != null) {
|
||||
val wrapper = details.getTypeObject(currentObjectType)
|
||||
if (wrapper != null) {
|
||||
val isDeleted = wrapper.isDeleted == true
|
||||
if (isDeleted) {
|
||||
ObjectRelationView.ObjectType.Deleted(
|
||||
id = wrapper.id,
|
||||
key = key,
|
||||
featured = true,
|
||||
readOnly = false,
|
||||
system = key.isSystemKey()
|
||||
)
|
||||
} else {
|
||||
ObjectRelationView.ObjectType.Base(
|
||||
id = wrapper.id,
|
||||
key = key,
|
||||
name = wrapper.name.orEmpty(),
|
||||
featured = true,
|
||||
readOnly = false,
|
||||
type = wrapper.id,
|
||||
system = key.isSystemKey()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
Relations.SET_OF -> {
|
||||
|
||||
val type = ObjectWrapper.Basic(details.details[ctx]?.map.orEmpty()).type.firstOrNull()
|
||||
val typeMap = type?.let { details.details[it]?.map }
|
||||
val source = currentObject.setOf.firstOrNull()
|
||||
|
||||
val isTypeMapValid = !typeMap.isNullOrEmpty()
|
||||
val wrapper = if (isTypeMapValid) typeMap?.mapToObjectWrapperType() else null
|
||||
val wrapper = if (source != null) {
|
||||
details.getObject(source)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val isDeleted = wrapper == null || wrapper.isDeleted == true
|
||||
val isValid = wrapper?.isValid == true
|
||||
val isDeleted = wrapper?.isDeleted == true
|
||||
val isReadOnly = wrapper?.relationReadonlyValue == true
|
||||
|
||||
if (wrapper != null && !isDeleted) {
|
||||
ObjectRelationView.ObjectType.Base(
|
||||
id = wrapper.id,
|
||||
val sources = if (isValid && !isDeleted) {
|
||||
listOf(wrapper.toObjectViewDefault(urlBuilder = urlBuilder, fieldParser = fieldParser))
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
|
||||
ObjectRelationView.Source(
|
||||
id = currentObject.id,
|
||||
key = key,
|
||||
name = wrapper.name.orEmpty(),
|
||||
name = Relations.RELATION_NAME_EMPTY,
|
||||
featured = true,
|
||||
readOnly = false,
|
||||
type = wrapper.id,
|
||||
system = key.isSystemKey()
|
||||
)
|
||||
} else {
|
||||
ObjectRelationView.ObjectType.Deleted(
|
||||
id = type.orEmpty(),
|
||||
key = key,
|
||||
featured = true,
|
||||
readOnly = false,
|
||||
readOnly = isReadOnly,
|
||||
sources = sources,
|
||||
system = key.isSystemKey()
|
||||
)
|
||||
}
|
||||
}
|
||||
Relations.SET_OF -> {
|
||||
|
||||
val source = ObjectWrapper.Basic(details.details[ctx]?.map.orEmpty()).setOf.firstOrNull()
|
||||
val sourceMap = source?.let { details.details[it]?.map }
|
||||
|
||||
val isSourceMapValid = !sourceMap.isNullOrEmpty()
|
||||
val wrapper = if (isSourceMapValid) ObjectWrapper.Basic(sourceMap) else null
|
||||
|
||||
val isValid = wrapper?.isValid == true
|
||||
val isDeleted = wrapper?.isDeleted == true
|
||||
val isReadOnly = wrapper?.relationReadonlyValue == true
|
||||
|
||||
val sources = if (isValid && !isDeleted) {
|
||||
listOf(wrapper.toObjectViewDefault(urlBuilder = urlBuilder, fieldParser = fieldParser))
|
||||
} else {
|
||||
emptyList()
|
||||
Relations.BACKLINKS, Relations.LINKS -> {
|
||||
details.linksFeaturedRelation(
|
||||
relations = relations,
|
||||
ctx = ctx,
|
||||
relationKey = key,
|
||||
isFeatured = true
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
val relation = relations.firstOrNull { it.key == key }
|
||||
relation?.view(
|
||||
details = details,
|
||||
values = currentObject.map,
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = true,
|
||||
fieldParser = fieldParser
|
||||
)
|
||||
}
|
||||
|
||||
ObjectRelationView.Source(
|
||||
id = details.details[ctx]?.id.orEmpty(),
|
||||
key = key,
|
||||
name = Relations.RELATION_NAME_EMPTY,
|
||||
featured = true,
|
||||
readOnly = isReadOnly,
|
||||
sources = sources,
|
||||
system = key.isSystemKey()
|
||||
)
|
||||
}
|
||||
Relations.BACKLINKS, Relations.LINKS -> {
|
||||
details.linksFeaturedRelation(
|
||||
relations = relations,
|
||||
ctx = ctx,
|
||||
relationKey = key,
|
||||
isFeatured = true
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
val relation = relations.firstOrNull { it.key == key }
|
||||
relation?.view(
|
||||
details = details.details,
|
||||
values = details.details[ctx]?.map ?: emptyMap(),
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = true,
|
||||
fieldParser = fieldParser
|
||||
)
|
||||
}
|
||||
}
|
||||
.sortedByDescending { it.key == Relations.SET_OF }
|
||||
.sortedByDescending { it.key == Relations.TYPE }
|
||||
}
|
||||
.sortedByDescending { it.key == Relations.SET_OF }
|
||||
.sortedByDescending { it.key == Relations.TYPE }
|
||||
|
||||
fun List<DVRecord>.update(new: List<DVRecord>): List<DVRecord> {
|
||||
val update = new.associateBy { rec -> rec[ID_KEY] as String }
|
||||
|
@ -400,7 +410,7 @@ fun List<DVViewerRelation>.updateViewerRelations(updates: List<DVViewerRelationU
|
|||
}
|
||||
|
||||
fun ObjectState.DataView.Set.getSetOfValue(ctx: Id): List<Id> {
|
||||
return ObjectWrapper.Basic(details[ctx]?.map.orEmpty()).setOf
|
||||
return details.getObject(ctx)?.setOf.orEmpty()
|
||||
}
|
||||
|
||||
fun ObjectState.DataView.filterOutDeletedAndMissingObjects(query: List<Id>): List<Id> {
|
||||
|
@ -409,15 +419,13 @@ fun ObjectState.DataView.filterOutDeletedAndMissingObjects(query: List<Id>): Lis
|
|||
|
||||
fun ObjectState.DataView.Set.isSetByRelation(setOfValue: List<Id>): Boolean {
|
||||
if (setOfValue.isEmpty()) return false
|
||||
val objectDetails = details[setOfValue.first()]?.map.orEmpty()
|
||||
val wrapper = ObjectWrapper.Basic(objectDetails)
|
||||
return wrapper.layout == ObjectType.Layout.RELATION
|
||||
val wrapper = details.getObject(setOfValue.first())
|
||||
return wrapper?.layout == ObjectType.Layout.RELATION
|
||||
}
|
||||
|
||||
private fun ObjectState.DataView.isValidObject(objectId: Id): Boolean {
|
||||
val objectDetails = details[objectId] ?: return false
|
||||
val objectWrapper = ObjectWrapper.Basic(objectDetails.map)
|
||||
return objectWrapper.isDeleted != true
|
||||
val objectWrapper = details.getObject(objectId)
|
||||
return objectWrapper?.isValid == true && objectWrapper.isDeleted != true
|
||||
}
|
||||
|
||||
fun DVViewer.updateFields(fields: DVViewerFields?): DVViewer {
|
||||
|
@ -549,7 +557,7 @@ suspend fun ObjectState.DataView.getActiveViewTypeAndTemplate(
|
|||
Timber.d("Set by type setOf param is null or empty, not possible to get Type and Template")
|
||||
Pair(null, null)
|
||||
} else {
|
||||
val defaultSetObjectType = details[setOf]?.map?.mapToObjectWrapperType()
|
||||
val defaultSetObjectType = details.getTypeObject(setOf)
|
||||
if (activeView.defaultTemplate.isNullOrEmpty()) {
|
||||
val defaultTemplateId = defaultSetObjectType?.defaultTemplateId
|
||||
Pair(defaultSetObjectType, defaultTemplateId)
|
||||
|
|
|
@ -76,6 +76,7 @@ import com.anytypeio.anytype.presentation.navigation.AppNavigation
|
|||
import com.anytypeio.anytype.presentation.navigation.SupportNavigation
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts
|
||||
import com.anytypeio.anytype.core_models.TimeInMillis
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.navigation.NavPanelState
|
||||
import com.anytypeio.anytype.presentation.objects.getCreateObjectParams
|
||||
import com.anytypeio.anytype.presentation.objects.isCreateObjectAllowed
|
||||
|
@ -104,7 +105,6 @@ import com.anytypeio.anytype.presentation.templates.TemplateView
|
|||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUI
|
||||
import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction
|
||||
import com.anytypeio.anytype.presentation.widgets.collection.CollectionViewModel.Command.OpenShareScreen
|
||||
import com.anytypeio.anytype.presentation.widgets.enterEditing
|
||||
import com.anytypeio.anytype.presentation.widgets.exitEditing
|
||||
import com.anytypeio.anytype.presentation.widgets.hideMoreMenu
|
||||
|
@ -1017,9 +1017,7 @@ class ObjectSetViewModel(
|
|||
if (isRestrictionPresent(DataViewRestriction.CREATE_OBJECT)) {
|
||||
toast(NOT_ALLOWED)
|
||||
} else {
|
||||
val setObject = ObjectWrapper.Basic(
|
||||
currentState.details[vmParams.ctx]?.map ?: emptyMap()
|
||||
)
|
||||
val setObject = currentState.details.getObject(vmParams.ctx)
|
||||
val viewer = currentState.viewerByIdOrFirst(session.currentViewerId.value)
|
||||
if (viewer == null) {
|
||||
Timber.e("onCreateNewDataViewObject, Viewer is empty")
|
||||
|
@ -1034,13 +1032,12 @@ class ObjectSetViewModel(
|
|||
|
||||
val objectTypeUniqueKey = defaultObjectType?.uniqueKey
|
||||
|
||||
val sourceId = setObject.setOf.singleOrNull()
|
||||
if (objectTypeUniqueKey == null) {
|
||||
val sourceId = setObject?.setOf?.singleOrNull()
|
||||
if (sourceId == null || objectTypeUniqueKey == null) {
|
||||
toast("Unable to define a source for a new object.")
|
||||
} else {
|
||||
val sourceDetails = currentState.details[sourceId]
|
||||
if (sourceDetails != null && sourceDetails.map.isNotEmpty()) {
|
||||
val wrapper = ObjectWrapper.Basic(sourceDetails.map)
|
||||
val wrapper = currentState.details.getObject(sourceId)
|
||||
if (wrapper != null) {
|
||||
when (wrapper.layout) {
|
||||
ObjectType.Layout.OBJECT_TYPE -> {
|
||||
val uniqueKey = wrapper.getValue<Key>(Relations.UNIQUE_KEY)
|
||||
|
@ -1088,7 +1085,7 @@ class ObjectSetViewModel(
|
|||
storeOfRelations = storeOfRelations,
|
||||
dateProvider = dateProvider,
|
||||
dataViewRelationLinks = currentState.dataViewContent.relationLinks,
|
||||
objSetByRelation = ObjectWrapper.Relation(sourceDetails.map)
|
||||
objSetByRelation = ObjectWrapper.Relation(wrapper.map)
|
||||
)
|
||||
proceedWithCreatingDataViewObject(
|
||||
CreateDataViewObject.Params.SetByRelation(
|
||||
|
@ -1244,8 +1241,7 @@ class ObjectSetViewModel(
|
|||
fun onMenuClicked() {
|
||||
Timber.d("onMenuClicked, ")
|
||||
val state = stateReducer.state.value.dataViewState() ?: return
|
||||
val struct = state.details[vmParams.ctx]?.map ?: return
|
||||
val wrapper = ObjectWrapper.Basic(struct)
|
||||
val wrapper = state.details.getObject(vmParams.ctx) ?: return
|
||||
Timber.d("Wrapper: $wrapper")
|
||||
val space = wrapper.spaceId
|
||||
if (space != null) {
|
||||
|
@ -1253,8 +1249,8 @@ class ObjectSetViewModel(
|
|||
ObjectSetCommand.Modal.Menu(
|
||||
ctx = vmParams.ctx,
|
||||
space = space,
|
||||
isArchived = state.details[vmParams.ctx]?.isArchived ?: false,
|
||||
isFavorite = state.details[vmParams.ctx]?.isFavorite ?: false,
|
||||
isArchived = wrapper.isArchived == true,
|
||||
isFavorite = wrapper.isFavorite == true,
|
||||
isReadOnly = !isOwnerOrEditor
|
||||
)
|
||||
)
|
||||
|
@ -1268,9 +1264,8 @@ class ObjectSetViewModel(
|
|||
fun onObjectIconClicked() {
|
||||
Timber.d("onIconClicked, ")
|
||||
val state = stateReducer.state.value.dataViewState() ?: return
|
||||
val struct = state.details[vmParams.ctx]
|
||||
val wrapper = ObjectWrapper.Basic(struct?.map.orEmpty())
|
||||
val space = wrapper.spaceId
|
||||
val wrapper = state.details.getObject(vmParams.ctx)
|
||||
val space = wrapper?.spaceId
|
||||
if (space != null) {
|
||||
dispatch(
|
||||
ObjectSetCommand.Modal.OpenIconActionMenu(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.anytypeio.anytype.presentation.sets
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
|
@ -14,6 +13,9 @@ import com.anytypeio.anytype.presentation.mapper.objectIcon
|
|||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getFileObject
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.relations.getDateRelationFormat
|
||||
import com.anytypeio.anytype.presentation.sets.model.CellView
|
||||
import com.anytypeio.anytype.presentation.sets.model.ColumnView
|
||||
|
@ -254,20 +256,18 @@ suspend fun List<ColumnView>.buildGridRow(
|
|||
|
||||
fun Struct.buildFileViews(
|
||||
relationKey: Id,
|
||||
details: Map<Id, Block.Fields>
|
||||
details: ObjectViewDetails,
|
||||
): List<FileView> {
|
||||
val files = mutableListOf<FileView>()
|
||||
val ids = getOrDefault(relationKey, null) ?: return emptyList()
|
||||
if (ids is Id) {
|
||||
val map = details[ids]?.map ?: return emptyList()
|
||||
val file = ObjectWrapper.File(map)
|
||||
if (file.map.isEmpty() || file.isDeleted == true || file.isArchived == true) return emptyList()
|
||||
val file = details.getFileObject(ids)
|
||||
if (file == null || file.map.isEmpty() || file.isDeleted == true || file.isArchived == true) return emptyList()
|
||||
files.add(file.toView())
|
||||
} else if (ids is List<*>) {
|
||||
ids.filterIsInstance<Id>().forEach { id ->
|
||||
val map = details[id]?.map ?: return@forEach
|
||||
val file = ObjectWrapper.File(map)
|
||||
if (file.map.isEmpty() || file.isDeleted == true || file.isArchived == true) return@forEach
|
||||
val file = details.getFileObject(id)
|
||||
if (file == null || file.map.isEmpty() || file.isDeleted == true || file.isArchived == true) return@forEach
|
||||
files.add(file.toView())
|
||||
}
|
||||
}
|
||||
|
@ -290,21 +290,21 @@ private fun ObjectWrapper.File.toView() : FileView {
|
|||
|
||||
fun Struct.buildRelationValueObjectViews(
|
||||
relationKey: Id,
|
||||
details: Map<Id, Block.Fields>,
|
||||
details: ObjectViewDetails,
|
||||
builder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
): List<ObjectView> {
|
||||
val objects = mutableListOf<ObjectView>()
|
||||
val value = this.getOrDefault(relationKey, null)
|
||||
if (value is Id) {
|
||||
val wrapper = ObjectWrapper.Basic(details[value]?.map.orEmpty())
|
||||
if (wrapper.isValid) {
|
||||
val wrapper = details.getObject(value)
|
||||
if (wrapper != null) {
|
||||
objects.add(wrapper.toObjectView(urlBuilder = builder, fieldParser = fieldParser))
|
||||
}
|
||||
} else if (value is List<*>) {
|
||||
value.typeOf<Id>().forEach { id ->
|
||||
val wrapper = ObjectWrapper.Basic(details[id]?.map.orEmpty())
|
||||
if (wrapper.isValid) {
|
||||
val wrapper = details.getObject(id)
|
||||
if (wrapper != null) {
|
||||
objects.add(wrapper.toObjectView(urlBuilder = builder, fieldParser = fieldParser))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,12 @@ import com.anytypeio.anytype.core_models.Event
|
|||
import com.anytypeio.anytype.core_models.Event.Command
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.ext.amend
|
||||
import com.anytypeio.anytype.core_models.ext.unset
|
||||
import com.anytypeio.anytype.core_models.getSingleValue
|
||||
import com.anytypeio.anytype.core_utils.ext.replace
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.sets.updateFields
|
||||
import com.anytypeio.anytype.presentation.sets.updateFilters
|
||||
import com.anytypeio.anytype.presentation.sets.updateSorts
|
||||
|
@ -116,17 +119,18 @@ class DefaultObjectStateReducer : ObjectStateReducer {
|
|||
* @see Command.ShowObject
|
||||
*/
|
||||
private fun handleShowObject(event: Command.ShowObject): ObjectState {
|
||||
val objectState = when (val layout = event.details.details[event.root]?.layout?.toInt()) {
|
||||
val objectState = when (val layout = event.details[event.root]?.getSingleValue<Double>(
|
||||
Relations.LAYOUT)?.toInt()) {
|
||||
ObjectType.Layout.COLLECTION.code -> ObjectState.DataView.Collection(
|
||||
root = event.root,
|
||||
blocks = event.blocks,
|
||||
details = event.details.details,
|
||||
details = ObjectViewDetails(event.details),
|
||||
dataViewRestrictions = event.dataViewRestrictions
|
||||
)
|
||||
ObjectType.Layout.SET.code -> ObjectState.DataView.Set(
|
||||
root = event.root,
|
||||
blocks = event.blocks,
|
||||
details = event.details.details,
|
||||
details = ObjectViewDetails(event.details),
|
||||
dataViewRestrictions = event.dataViewRestrictions
|
||||
)
|
||||
else -> {
|
||||
|
@ -368,16 +372,24 @@ class DefaultObjectStateReducer : ObjectStateReducer {
|
|||
event: Command.Details.Set
|
||||
): ObjectState {
|
||||
return when (state) {
|
||||
is ObjectState.DataView.Collection -> state.copy(
|
||||
details = state.details.toMutableMap().apply {
|
||||
put(event.target, event.details)
|
||||
}
|
||||
)
|
||||
is ObjectState.DataView.Set -> state.copy(
|
||||
details = state.details.toMutableMap().apply {
|
||||
put(event.target, event.details)
|
||||
}
|
||||
)
|
||||
is ObjectState.DataView.Collection -> {
|
||||
state.copy(
|
||||
details = ObjectViewDetails(
|
||||
details = state.details.details.toMutableMap().apply {
|
||||
put(event.target, event.details)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
is ObjectState.DataView.Set -> {
|
||||
state.copy(
|
||||
details = ObjectViewDetails(
|
||||
details = state.details.details.toMutableMap().apply {
|
||||
put(event.target, event.details)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> state
|
||||
}
|
||||
}
|
||||
|
@ -391,15 +403,19 @@ class DefaultObjectStateReducer : ObjectStateReducer {
|
|||
): ObjectState {
|
||||
return when (state) {
|
||||
is ObjectState.DataView.Collection -> state.copy(
|
||||
details = state.details.amend(
|
||||
target = event.target,
|
||||
slice = event.details
|
||||
details = state.details.copy(
|
||||
details = state.details.details.amend(
|
||||
target = event.target,
|
||||
slice = event.details
|
||||
)
|
||||
)
|
||||
)
|
||||
is ObjectState.DataView.Set -> state.copy(
|
||||
details = state.details.amend(
|
||||
target = event.target,
|
||||
slice = event.details
|
||||
details = state.details.copy(
|
||||
details = state.details.details.amend(
|
||||
target = event.target,
|
||||
slice = event.details
|
||||
)
|
||||
)
|
||||
)
|
||||
else -> state
|
||||
|
@ -415,15 +431,19 @@ class DefaultObjectStateReducer : ObjectStateReducer {
|
|||
): ObjectState {
|
||||
return when (state) {
|
||||
is ObjectState.DataView.Collection -> state.copy(
|
||||
details = state.details.unset(
|
||||
target = event.target,
|
||||
keys = event.keys
|
||||
details = state.details.copy(
|
||||
details = state.details.details.unset(
|
||||
target = event.target,
|
||||
keys = event.keys
|
||||
)
|
||||
)
|
||||
)
|
||||
is ObjectState.DataView.Set -> state.copy(
|
||||
details = state.details.unset(
|
||||
target = event.target,
|
||||
keys = event.keys
|
||||
details = state.details.copy(
|
||||
details = state.details.details.unset(
|
||||
target = event.target,
|
||||
keys = event.keys
|
||||
)
|
||||
)
|
||||
)
|
||||
else -> state
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.anytypeio.anytype.core_models.Id
|
|||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.restrictions.DataViewRestrictions
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
|
||||
sealed class ObjectState {
|
||||
|
||||
|
@ -17,7 +18,7 @@ sealed class ObjectState {
|
|||
|
||||
abstract val root: Id
|
||||
abstract val blocks: List<Block>
|
||||
abstract val details: Map<Id, Block.Fields>
|
||||
abstract val details: ObjectViewDetails
|
||||
abstract val objectRestrictions: List<ObjectRestriction>
|
||||
abstract val dataViewRestrictions: List<DataViewRestrictions>
|
||||
|
||||
|
@ -28,7 +29,7 @@ sealed class ObjectState {
|
|||
data class Set(
|
||||
override val root: Id,
|
||||
override val blocks: List<Block> = emptyList(),
|
||||
override val details: Map<Id, Block.Fields> = emptyMap(),
|
||||
override val details: ObjectViewDetails = ObjectViewDetails.EMPTY,
|
||||
override val objectRestrictions: List<ObjectRestriction> = emptyList(),
|
||||
override val dataViewRestrictions: List<DataViewRestrictions> = emptyList(),
|
||||
) : DataView() {
|
||||
|
@ -42,7 +43,7 @@ sealed class ObjectState {
|
|||
data class Collection(
|
||||
override val root: Id,
|
||||
override val blocks: List<Block> = emptyList(),
|
||||
override val details: Map<Id, Block.Fields> = emptyMap(),
|
||||
override val details: ObjectViewDetails = ObjectViewDetails.EMPTY,
|
||||
override val objectRestrictions: List<ObjectRestriction> = emptyList(),
|
||||
override val dataViewRestrictions: List<DataViewRestrictions> = emptyList(),
|
||||
) : DataView() {
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.anytypeio.anytype.core_models.ext.asMap
|
|||
import com.anytypeio.anytype.presentation.common.BaseViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.render.BlockViewRenderer
|
||||
import com.anytypeio.anytype.presentation.editor.render.DefaultBlockViewRenderer
|
||||
|
@ -70,8 +71,8 @@ class TemplateBlankViewModel(
|
|||
)
|
||||
val featuredRelations = listOf(Relations.TYPE)
|
||||
val page = listOf(rootBlock, headerBlock, blockTitle, featuredRelationsBlock)
|
||||
val objectDetails = Block.Fields(
|
||||
mapOf(
|
||||
val objectDetails = mapOf(
|
||||
DEFAULT_TEMPLATE_ID_BLANK to mapOf(
|
||||
Relations.ID to DEFAULT_TEMPLATE_ID_BLANK,
|
||||
Relations.LAYOUT to layout,
|
||||
Relations.TYPE to typeId,
|
||||
|
@ -80,8 +81,8 @@ class TemplateBlankViewModel(
|
|||
)
|
||||
)
|
||||
|
||||
val typeDetails = Block.Fields(
|
||||
mapOf(
|
||||
val typeDetails = mapOf(
|
||||
typeId to mapOf(
|
||||
Relations.ID to typeId,
|
||||
Relations.UNIQUE_KEY to ObjectTypeIds.TEMPLATE,
|
||||
Relations.NAME to TEMPLATE_TYPE_NAME,
|
||||
|
@ -90,7 +91,8 @@ class TemplateBlankViewModel(
|
|||
)
|
||||
|
||||
val customDetails =
|
||||
Block.Details(mapOf(DEFAULT_TEMPLATE_ID_BLANK to objectDetails, typeId to typeDetails))
|
||||
ObjectViewDetails(
|
||||
details = mapOf(DEFAULT_TEMPLATE_ID_BLANK to objectDetails, typeId to typeDetails))
|
||||
|
||||
viewModelScope.launch {
|
||||
state.value = page.asMap().render(
|
||||
|
|
|
@ -3,17 +3,16 @@ package com.anytypeio.anytype.presentation.collections
|
|||
import android.util.Log
|
||||
import app.cash.turbine.test
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.DVViewerRelation
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Relations.ID
|
||||
import com.anytypeio.anytype.core_models.Relations.LAYOUT
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParserImpl
|
||||
import com.anytypeio.anytype.core_models.DVViewerRelation
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.relations.model.DefaultObjectRelationValueView
|
||||
import com.anytypeio.anytype.presentation.sets.DataViewViewState
|
||||
|
@ -77,11 +76,13 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
||||
val rootObject = ObjectWrapper.Basic(
|
||||
map = mapOf(
|
||||
ID to root,
|
||||
Relations.NAME to objectCollection.details.details[root]?.name,
|
||||
LAYOUT to COLLECTION_LAYOUT
|
||||
val objectViewDetails = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.NAME to objectCollection.details.getObject(root)?.name!!,
|
||||
LAYOUT to COLLECTION_LAYOUT
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -91,7 +92,7 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
objectCollection.title,
|
||||
objectCollection.dataView
|
||||
),
|
||||
details = objectCollection.details
|
||||
details = objectViewDetails
|
||||
)
|
||||
|
||||
// TESTING
|
||||
|
@ -192,9 +193,7 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
objectCollection.title,
|
||||
objectCollection.dataView
|
||||
),
|
||||
details = mapOf(
|
||||
rootObject.id to Block.Fields(rootObject.map)
|
||||
),
|
||||
details = objectViewDetails,
|
||||
objectRestrictions = listOf(),
|
||||
dataViewRestrictions = listOf()
|
||||
),
|
||||
|
@ -202,11 +201,12 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
//Add new relation from marketplace to object and view
|
||||
val eventObjectDetailsSet = Event.Command.Details.Set(
|
||||
val eventObjectDetailsSet = Event.Command.Details.Amend(
|
||||
context = root,
|
||||
target = relationId4,
|
||||
details = Block.Fields(relationObject4.map)
|
||||
target = root,
|
||||
details = mapOf(relationKey4 to "")
|
||||
)
|
||||
|
||||
val eventDataViewRelationSet = Event.Command.DataView.SetRelation(
|
||||
context = root,
|
||||
dv = objectCollection.dataView.id,
|
||||
|
@ -282,9 +282,12 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
objectCollection.title,
|
||||
expectedDataView
|
||||
),
|
||||
details = mapOf(
|
||||
rootObject.id to Block.Fields(rootObject.map),
|
||||
relationObject4.id to Block.Fields(relationObject4.map)
|
||||
details = objectViewDetails.copy(
|
||||
details = objectViewDetails.details.toMutableMap().apply {
|
||||
this[root] = this[root]!!.toMutableMap().apply {
|
||||
put(relationKey4, "")
|
||||
}
|
||||
}
|
||||
),
|
||||
objectRestrictions = listOf(),
|
||||
dataViewRestrictions = listOf()
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.anytypeio.anytype.core_models.StubObject
|
|||
import com.anytypeio.anytype.core_models.StubRelationLink
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.core_models.StubTitle
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.sets.subscription.DefaultDataViewSubscription
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import net.bytebuddy.utility.RandomString
|
||||
|
@ -242,14 +243,12 @@ class MockCollection(
|
|||
|
||||
val subscriptionId = DefaultDataViewSubscription.getDataViewSubscriptionId(context)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.NAME to MockDataFactory.randomString(),
|
||||
Relations.LAYOUT to ObjectType.Layout.COLLECTION.code.toDouble()
|
||||
)
|
||||
root to mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.NAME to MockDataFactory.randomString(),
|
||||
Relations.LAYOUT to ObjectType.Layout.COLLECTION.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.anytypeio.anytype.core_models.StubObject
|
|||
import com.anytypeio.anytype.core_models.StubRelationLink
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.core_models.StubTitle
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.sets.subscription.DefaultDataViewSubscription
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import net.bytebuddy.utility.RandomString
|
||||
|
@ -189,18 +190,16 @@ class MockSet(
|
|||
)
|
||||
|
||||
// SET OBJECT DETAILS
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to listOf(setOf)
|
||||
)
|
||||
),
|
||||
setOf to Block.Fields(
|
||||
map = mapOf(
|
||||
setOf to mapOf(
|
||||
Relations.ID to setOf,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.UNIQUE_KEY to setOfKey,
|
||||
|
@ -208,13 +207,12 @@ class MockSet(
|
|||
Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
Relations.LAYOUT to ObjectType.Layout.OBJECT_TYPE.code.toDouble(),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val detailsEmptySetOf = Block.Details(
|
||||
val detailsEmptySetOf = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
|
@ -222,41 +220,37 @@ class MockSet(
|
|||
Relations.SET_OF to listOf<String>()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val detailsSetByRelation = Block.Details(
|
||||
val detailsSetByRelation = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to relationObject3.id
|
||||
)
|
||||
),
|
||||
relationObject3.id to Block.Fields(
|
||||
),
|
||||
relationObject3.id to
|
||||
mapOf(
|
||||
Relations.ID to relationObject3.id,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.RELATION_KEY to relationObject3.key,
|
||||
Relations.LAYOUT to ObjectType.Layout.RELATION.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun detailsSetByRelation(relationSetBy: ObjectWrapper.Relation) = Block.Details(
|
||||
fun detailsSetByRelation(relationSetBy: ObjectWrapper.Relation) = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to relationSetBy.id
|
||||
)
|
||||
),
|
||||
relationSetBy.id to Block.Fields(
|
||||
relationSetBy.id to
|
||||
mapOf(
|
||||
Relations.ID to relationSetBy.id,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
|
@ -264,7 +258,7 @@ class MockSet(
|
|||
Relations.UNIQUE_KEY to relationSetBy.uniqueKey,
|
||||
Relations.LAYOUT to ObjectType.Layout.RELATION.code.toDouble(),
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.anytypeio.anytype.core_models.primitives.TypeKey
|
|||
import com.anytypeio.anytype.core_models.restrictions.DataViewRestriction
|
||||
import com.anytypeio.anytype.core_models.restrictions.DataViewRestrictions
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts
|
||||
import com.anytypeio.anytype.core_models.getSingleValue
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParserImpl
|
||||
import com.anytypeio.anytype.presentation.sets.DataViewViewState
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModel
|
||||
|
@ -76,7 +77,9 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
assertIs<ObjectState.DataView.Collection>(stateFlow.awaitItem())
|
||||
|
||||
assertEquals(
|
||||
expected = mockObjectCollection.details.details[mockObjectCollection.root]?.name,
|
||||
expected = mockObjectCollection.details.details[mockObjectCollection.root]?.getSingleValue(
|
||||
Relations.NAME
|
||||
),
|
||||
actual = (headerFlow.awaitItem() as SetOrCollectionHeaderState.Default).title.text
|
||||
)
|
||||
viewerFlow.expectNoEvents()
|
||||
|
|
|
@ -3,14 +3,13 @@ package com.anytypeio.anytype.presentation.collections
|
|||
import app.cash.turbine.test
|
||||
import app.cash.turbine.testIn
|
||||
import app.cash.turbine.turbineScope
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubObject
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParserImpl
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||
import com.anytypeio.anytype.presentation.sets.DataViewViewState
|
||||
|
@ -60,14 +59,13 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
||||
val objectDetails = Block.Details(
|
||||
val objectDetails = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
stubOpenObject(
|
||||
|
@ -280,26 +278,23 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
)
|
||||
|
||||
val detailsDeletedSetOf = Block.Details(
|
||||
val detailsDeletedSetOf = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to listOf(typeDeleted1.id, type2.id, typeDeleted3.id)
|
||||
)
|
||||
),
|
||||
typeDeleted1.id to Block.Fields(
|
||||
typeDeleted1.id to
|
||||
mapOf(
|
||||
Relations.ID to typeDeleted1.id,
|
||||
Relations.IS_DELETED to true
|
||||
)
|
||||
),
|
||||
type2.id to Block.Fields(
|
||||
type2.id to
|
||||
mapOf(
|
||||
Relations.ID to type2.id,
|
||||
Relations.TYPE to ObjectTypeIds.OBJECT_TYPE
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -375,21 +370,19 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
)
|
||||
|
||||
val detailsDeletedSetOf = Block.Details(
|
||||
val detailsDeletedSetOf = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to listOf(typeDeleted1.id, typeDeleted3.id)
|
||||
)
|
||||
),
|
||||
typeDeleted1.id to Block.Fields(
|
||||
typeDeleted1.id to
|
||||
mapOf(
|
||||
Relations.ID to typeDeleted1.id,
|
||||
Relations.IS_DELETED to true
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.anytypeio.anytype.core_models.StubTitle
|
|||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.EditorPresentationTestSetup
|
||||
import com.anytypeio.anytype.presentation.editor.editor.ViewState
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
|
@ -118,15 +119,15 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
children = listOf(header.id, block.id, dv.id),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
val objectDetails = Block.Fields(
|
||||
val objectDetails =
|
||||
mapOf(
|
||||
Relations.ID to targetObjectId,
|
||||
Relations.TYPE to ObjectTypeIds.SET,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to listOf("")
|
||||
)
|
||||
)
|
||||
|
||||
val detailsList = Block.Details(details = mapOf(targetObjectId to objectDetails))
|
||||
val detailsList = ObjectViewDetails(details = mapOf(targetObjectId to objectDetails))
|
||||
|
||||
stubOpenDocument(document = listOf(page, header, title, block, dv), details = detailsList)
|
||||
stubInterceptEvents(params = params)
|
||||
|
@ -181,15 +182,15 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
children = listOf(header.id, block.id, dv.id),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
val objectDetails = Block.Fields(
|
||||
val objectDetails =
|
||||
mapOf(
|
||||
Relations.ID to targetObjectId,
|
||||
Relations.TYPE to ObjectTypeIds.SET,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to emptyList<String>()
|
||||
)
|
||||
)
|
||||
|
||||
val detailsList = Block.Details(details = mapOf(targetObjectId to objectDetails))
|
||||
val detailsList = ObjectViewDetails(details = mapOf(targetObjectId to objectDetails))
|
||||
|
||||
stubOpenDocument(document = listOf(page, header, title, block, dv), details = detailsList)
|
||||
stubInterceptEvents(params = params)
|
||||
|
@ -244,15 +245,15 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
children = listOf(header.id, block.id, dv.id),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
val objectDetails = Block.Fields(
|
||||
val objectDetails =
|
||||
mapOf(
|
||||
Relations.ID to targetObjectId,
|
||||
Relations.TYPE to ObjectTypeIds.SET,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to listOf<String>("", " ", RandomString.make())
|
||||
)
|
||||
)
|
||||
|
||||
val detailsList = Block.Details(details = mapOf(targetObjectId to objectDetails))
|
||||
val detailsList = ObjectViewDetails(details = mapOf(targetObjectId to objectDetails))
|
||||
|
||||
stubOpenDocument(document = listOf(page, header, title, block, dv), details = detailsList)
|
||||
stubInterceptEvents(params = params)
|
||||
|
@ -307,14 +308,14 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
children = listOf(header.id, block.id, dv.id),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
val objectDetails = Block.Fields(
|
||||
val objectDetails =
|
||||
mapOf(
|
||||
Relations.ID to targetObjectId,
|
||||
Relations.TYPE to ObjectTypeIds.COLLECTION,
|
||||
Relations.LAYOUT to ObjectType.Layout.COLLECTION.code.toDouble()
|
||||
)
|
||||
)
|
||||
|
||||
val detailsList = Block.Details(details = mapOf(targetObjectId to objectDetails))
|
||||
val detailsList = ObjectViewDetails(details = mapOf(targetObjectId to objectDetails))
|
||||
|
||||
stubOpenDocument(document = listOf(page, header, title, block, dv), details = detailsList)
|
||||
stubInterceptEvents(params = params)
|
||||
|
@ -444,7 +445,18 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
}
|
||||
|
||||
stubOpenDocument(document = listOf(page, header, title, block, dv))
|
||||
stubOpenDocument(
|
||||
document = listOf(page, header, title, block, dv),
|
||||
details = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
targetObjectId to mapOf(
|
||||
Relations.ID to targetObjectId,
|
||||
Relations.UNIQUE_KEY to targetObjectId,
|
||||
Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
stubInterceptEvents(
|
||||
params = params,
|
||||
flow = events
|
||||
|
|
|
@ -19,7 +19,6 @@ import com.anytypeio.anytype.core_models.ext.asMap
|
|||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.core_models.ext.parseThemeTextColor
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.core_utils.const.DetailsKeys
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
import com.anytypeio.anytype.domain.debugging.Logger
|
||||
import com.anytypeio.anytype.domain.editor.Editor
|
||||
|
@ -37,6 +36,7 @@ import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubLinkConten
|
|||
import com.anytypeio.anytype.presentation.MockBlockFactory.link
|
||||
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup.Companion.NON_EXISTENT_OBJECT_MENTION_NAME
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.Alignment
|
||||
|
@ -73,7 +73,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor: Id,
|
||||
focus: Editor.Focus,
|
||||
indent: Int,
|
||||
details: Block.Details,
|
||||
details: ObjectViewDetails,
|
||||
schema: NestedDecorationData = emptyList()
|
||||
): List<BlockView> = blocks.render(
|
||||
context = root.id,
|
||||
|
@ -228,7 +228,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(paragraph.id),
|
||||
indent = 0,
|
||||
details = Block.Details()
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(paragraph.id),
|
||||
indent = 0,
|
||||
details = Block.Details()
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(paragraph.id),
|
||||
indent = 0,
|
||||
details = Block.Details()
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -566,7 +566,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(paragraph.id),
|
||||
indent = 0,
|
||||
details = Block.Details()
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -634,20 +634,18 @@ class DefaultBlockViewRendererTest {
|
|||
val name = MockDataFactory.randomString()
|
||||
val imageName = MockDataFactory.randomString()
|
||||
val pageId = MockDataFactory.randomUuid()
|
||||
val fields = Block.Fields(
|
||||
map = mapOf(
|
||||
Relations.ID to pageId,
|
||||
Relations.NAME to name,
|
||||
Relations.ICON_IMAGE to imageName,
|
||||
Relations.LAYOUT to ObjectType.Layout.PROFILE.code.toDouble()
|
||||
)
|
||||
val struct = mapOf(
|
||||
Relations.ID to pageId,
|
||||
Relations.NAME to name,
|
||||
Relations.ICON_IMAGE to imageName,
|
||||
Relations.LAYOUT to Layout.PROFILE.code.toDouble()
|
||||
)
|
||||
val details = mapOf(pageId to fields)
|
||||
val details = mapOf(pageId to struct)
|
||||
|
||||
val page = Block(
|
||||
id = pageId,
|
||||
children = listOf(header.id, paragraph.id),
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -666,7 +664,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(paragraph.id),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails(details)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -734,19 +732,16 @@ class DefaultBlockViewRendererTest {
|
|||
val name = MockDataFactory.randomString()
|
||||
val imageName = MockDataFactory.randomString()
|
||||
val pageId = MockDataFactory.randomUuid()
|
||||
val fields = Block.Fields(
|
||||
map = mapOf(
|
||||
"name" to name,
|
||||
"iconImage" to imageName
|
||||
)
|
||||
val struct = mapOf(
|
||||
Relations.ID to pageId,
|
||||
"name" to name,
|
||||
"iconImage" to imageName
|
||||
)
|
||||
val details = mapOf(pageId to fields)
|
||||
val details = mapOf(pageId to struct)
|
||||
|
||||
val page = Block(
|
||||
val page = StubSmartBlock(
|
||||
id = pageId,
|
||||
children = listOf(header.id, paragraph.id),
|
||||
fields = fields,
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
val blocks = listOf(page, header, title, paragraph)
|
||||
|
@ -764,7 +759,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(paragraph.id),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails(details)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -853,17 +848,11 @@ class DefaultBlockViewRendererTest {
|
|||
fields = Block.Fields.empty()
|
||||
)
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
|
||||
val page = Block(
|
||||
val page = StubSmartBlock(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
children = listOf(header.id, a.id),
|
||||
fields = fields,
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
val details = mapOf(page.id to fields)
|
||||
|
||||
val blocks = listOf(page, header, title, a, b, c)
|
||||
|
||||
val map = blocks.asMap()
|
||||
|
@ -879,7 +868,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1008,17 +997,11 @@ class DefaultBlockViewRendererTest {
|
|||
fields = Block.Fields.empty()
|
||||
)
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
|
||||
val page = Block(
|
||||
val page = StubSmartBlock(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
children = listOf(header.id, a.id),
|
||||
fields = fields,
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
val details = mapOf(page.id to fields)
|
||||
|
||||
val blocks = listOf(page, header, title, a, b, c)
|
||||
|
||||
val map = blocks.asMap()
|
||||
|
@ -1034,7 +1017,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1160,12 +1143,12 @@ class DefaultBlockViewRendererTest {
|
|||
fields = Block.Fields.empty()
|
||||
)
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
val fields = mapOf<Id, Any?>()
|
||||
|
||||
val page = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
children = listOf(header.id, a.id),
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -1186,7 +1169,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails(details)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1276,12 +1259,12 @@ class DefaultBlockViewRendererTest {
|
|||
children = listOf(title.id)
|
||||
)
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
val fields = mapOf<Id, Any?>()
|
||||
|
||||
val page = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
children = listOf(header.id),
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -1303,7 +1286,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details),
|
||||
details = ObjectViewDetails(details),
|
||||
|
||||
)
|
||||
}
|
||||
|
@ -1344,12 +1327,12 @@ class DefaultBlockViewRendererTest {
|
|||
children = listOf(title.id)
|
||||
)
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
val fields = mapOf<Id, Any?>()
|
||||
|
||||
val page = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
children = listOf(header.id),
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -1371,7 +1354,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails(details)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1467,19 +1450,18 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
|
||||
val randomEmoji1 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Block.Fields.NAME_KEY to mentionTextUpdated1,
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji1
|
||||
Relations.ID to mentionTarget1,
|
||||
Relations.NAME to mentionTextUpdated1,
|
||||
Relations.ICON_EMOJI to randomEmoji1
|
||||
)
|
||||
)
|
||||
|
||||
val randomEmoji2 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated2 = Block.Fields(
|
||||
mapOf(
|
||||
Block.Fields.NAME_KEY to mentionTextUpdated2,
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji2
|
||||
)
|
||||
val fieldsUpdated2 = mapOf(
|
||||
Relations.ID to mentionTarget2,
|
||||
Relations.NAME to mentionTextUpdated2,
|
||||
Relations.ICON_EMOJI to randomEmoji2
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
|
@ -1502,7 +1484,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1652,20 +1634,20 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
|
||||
val randomEmoji1 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Block.Fields.NAME_KEY to mentionTextUpdated1,
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji1
|
||||
Relations.ID to mentionTarget1,
|
||||
Relations.NAME to mentionTextUpdated1,
|
||||
Relations.ICON_EMOJI to randomEmoji1
|
||||
)
|
||||
)
|
||||
|
||||
val randomEmoji2 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated2 = Block.Fields(
|
||||
val fieldsUpdated2 =
|
||||
mapOf(
|
||||
Block.Fields.NAME_KEY to mentionTextUpdated2,
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji2
|
||||
Relations.ID to mentionTarget2,
|
||||
Relations.NAME to mentionTextUpdated2,
|
||||
Relations.ICON_EMOJI to randomEmoji2
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget1 to fieldsUpdated1,
|
||||
|
@ -1687,7 +1669,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1837,22 +1819,22 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
|
||||
val randomEmoji1 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Relations.ID to mentionTarget1,
|
||||
"name" to "XmN34",
|
||||
"snippet" to mentionTextUpdated1,
|
||||
"layout" to 9.0
|
||||
)
|
||||
)
|
||||
|
||||
val randomEmoji2 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated2 = Block.Fields(
|
||||
val fieldsUpdated2 =
|
||||
mapOf(
|
||||
Relations.ID to mentionTarget2,
|
||||
"name" to mentionTextUpdated2,
|
||||
"iconEmoji" to randomEmoji2,
|
||||
"layout" to 0.0
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget1 to fieldsUpdated1,
|
||||
|
@ -1874,7 +1856,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2019,18 +2001,18 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
|
||||
val randomEmoji1 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji1
|
||||
Relations.ID to mentionTarget1,
|
||||
Relations.ICON_EMOJI to randomEmoji1
|
||||
)
|
||||
)
|
||||
|
||||
val randomEmoji2 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated2 = Block.Fields(
|
||||
val fieldsUpdated2 =
|
||||
mapOf(
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji2
|
||||
Relations.ID to mentionTarget2,
|
||||
Relations.ICON_EMOJI to randomEmoji2
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget1 to fieldsUpdated1,
|
||||
|
@ -2052,7 +2034,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2188,18 +2170,16 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
|
||||
val randomEmoji1 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji1
|
||||
Relations.ICON_EMOJI to randomEmoji1
|
||||
)
|
||||
)
|
||||
|
||||
val randomEmoji2 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated2 = Block.Fields(
|
||||
val fieldsUpdated2 =
|
||||
mapOf(
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji2
|
||||
Relations.ICON_EMOJI to randomEmoji2
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget1 to fieldsUpdated1,
|
||||
|
@ -2221,7 +2201,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2320,7 +2300,10 @@ class DefaultBlockViewRendererTest {
|
|||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
val fieldsUpdated1 = Block.Fields(mapOf(Relations.NAME to mentionText2))
|
||||
val fieldsUpdated1 = mapOf(
|
||||
Relations.ID to mentionTarget1,
|
||||
Relations.NAME to mentionText2
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(mentionTarget1 to fieldsUpdated1)
|
||||
|
||||
|
@ -2339,7 +2322,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2462,21 +2445,21 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
|
||||
val randomEmoji1 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Block.Fields.NAME_KEY to mentionTextUpdated1,
|
||||
Relations.ID to mentionTarget1,
|
||||
Relations.NAME to mentionTextUpdated1,
|
||||
Relations.IS_DELETED to true,
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji1
|
||||
Relations.ICON_EMOJI to randomEmoji1
|
||||
)
|
||||
)
|
||||
|
||||
val randomEmoji2 = DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random()
|
||||
val fieldsUpdated2 = Block.Fields(
|
||||
val fieldsUpdated2 =
|
||||
mapOf(
|
||||
Block.Fields.NAME_KEY to mentionTextUpdated2,
|
||||
DetailsKeys.ICON_EMOJI to randomEmoji2
|
||||
Relations.ID to mentionTarget2,
|
||||
Relations.NAME to mentionTextUpdated2,
|
||||
Relations.ICON_EMOJI to randomEmoji2
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget1 to fieldsUpdated1,
|
||||
|
@ -2498,7 +2481,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2598,10 +2581,11 @@ class DefaultBlockViewRendererTest {
|
|||
val snippet = MockDataFactory.randomString()
|
||||
val name = MockDataFactory.randomString()
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
target to Block.Fields(
|
||||
target to
|
||||
mapOf(
|
||||
Relations.ID to page.id,
|
||||
"name" to name,
|
||||
"description" to "",
|
||||
"snippet" to snippet,
|
||||
|
@ -2609,7 +2593,6 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
wrapper = BlockViewRenderWrapper(
|
||||
blocks = map,
|
||||
|
@ -2729,12 +2712,12 @@ class DefaultBlockViewRendererTest {
|
|||
fields = Block.Fields.empty()
|
||||
)
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
val fields = mapOf<Id, Any?>()
|
||||
|
||||
val page = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
children = listOf(header.id, a.id),
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -2755,7 +2738,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails(details)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2960,8 +2943,6 @@ class DefaultBlockViewRendererTest {
|
|||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
val details = mapOf(page.id to Block.Fields.empty())
|
||||
|
||||
val blocks = listOf(page, header, title, a1, a2, a3, a4, b1, b2, b3)
|
||||
|
||||
val map = blocks.asMap()
|
||||
|
@ -2977,7 +2958,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -3214,7 +3195,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -3348,7 +3329,7 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
}
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
val fields = mapOf<Id, Any?>()
|
||||
|
||||
|
||||
val div1 = Block(
|
||||
|
@ -3390,7 +3371,7 @@ class DefaultBlockViewRendererTest {
|
|||
val page = Block(
|
||||
id = "root",
|
||||
children = listOf(header.id) + listOf(div1.id, div2.id, div3.id, div4.id),
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -3411,7 +3392,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -3478,7 +3459,7 @@ class DefaultBlockViewRendererTest {
|
|||
)
|
||||
}
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
val fields = mapOf<Id, Any?>()
|
||||
|
||||
|
||||
val div1 = Block(
|
||||
|
@ -3525,7 +3506,7 @@ class DefaultBlockViewRendererTest {
|
|||
div3.id,
|
||||
div4.id
|
||||
) + numbered.subList(20, 25).map { it.id },
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -3546,7 +3527,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -3662,7 +3643,7 @@ class DefaultBlockViewRendererTest {
|
|||
fields = Block.Fields.empty()
|
||||
)
|
||||
|
||||
val fields = Block.Fields.empty()
|
||||
val fields = mapOf<Id, Any?>()
|
||||
|
||||
|
||||
val div1 = Block(
|
||||
|
@ -3711,7 +3692,7 @@ class DefaultBlockViewRendererTest {
|
|||
div1.id,
|
||||
div2.id
|
||||
) + listOf(afterDiv2Num1.id, afterDiv2Num2.id),
|
||||
fields = fields,
|
||||
fields = Block.Fields.empty(),
|
||||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
|
@ -3744,7 +3725,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4010,7 +3991,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4246,7 +4227,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4345,7 +4326,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4460,7 +4441,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4610,7 +4591,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4782,7 +4763,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4908,15 +4889,15 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(
|
||||
details = ObjectViewDetails(
|
||||
mapOf(
|
||||
bookmarkObjectId to Block.Fields(
|
||||
mapOf(
|
||||
Relations.NAME to bookmarkTitle,
|
||||
Relations.DESCRIPTION to bookmarkDescription,
|
||||
Relations.SOURCE to bookmarkUrl
|
||||
)
|
||||
)
|
||||
bookmarkObjectId to
|
||||
mapOf(
|
||||
Relations.ID to page.id,
|
||||
Relations.NAME to bookmarkTitle,
|
||||
Relations.DESCRIPTION to bookmarkDescription,
|
||||
Relations.SOURCE to bookmarkUrl
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -4987,7 +4968,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details()
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5051,7 +5032,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details()
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5112,7 +5093,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5171,7 +5152,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5249,7 +5230,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5348,7 +5329,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5426,7 +5407,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails.EMPTY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5539,14 +5520,13 @@ class DefaultBlockViewRendererTest {
|
|||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Relations.ID to mentionTarget1,
|
||||
Relations.NAME to mentionTextUpdated1,
|
||||
Relations.TIMESTAMP to 1733775232,
|
||||
Relations.LAYOUT to Layout.DATE.code.toDouble()
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget1 to fieldsUpdated1,
|
||||
|
@ -5567,7 +5547,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5680,14 +5660,13 @@ class DefaultBlockViewRendererTest {
|
|||
content = Block.Content.Smart
|
||||
)
|
||||
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Relations.ID to mentionTarget1,
|
||||
Relations.NAME to mentionTextUpdated1,
|
||||
Relations.TIMESTAMP to 1733775232,
|
||||
Relations.LAYOUT to Layout.DATE.code.toDouble()
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget1 to fieldsUpdated1,
|
||||
|
@ -5708,7 +5687,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.id(a.id),
|
||||
indent = 0,
|
||||
details = Block.Details(detailsAmend)
|
||||
details = ObjectViewDetails(detailsAmend)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5778,14 +5757,13 @@ class DefaultBlockViewRendererTest {
|
|||
val page = StubSmartBlock(id = currentObjectId, children = listOf(paragraph.id, file.id))
|
||||
|
||||
val details = mapOf(
|
||||
page.id to Block.Fields(
|
||||
page.id to
|
||||
mapOf(
|
||||
Relations.ID to currentObjectId,
|
||||
Relations.NAME to "file-name",
|
||||
Relations.LAYOUT to layout.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val blocks = listOf(page, paragraph, file)
|
||||
|
||||
|
@ -5802,7 +5780,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails(details)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5846,14 +5824,13 @@ class DefaultBlockViewRendererTest {
|
|||
val page = StubSmartBlock(id = currentObjectId, children = listOf(paragraph.id, file.id))
|
||||
|
||||
val details = mapOf(
|
||||
page.id to Block.Fields(
|
||||
page.id to
|
||||
mapOf(
|
||||
Relations.ID to currentObjectId,
|
||||
Relations.NAME to "image-name",
|
||||
Relations.LAYOUT to ObjectType.Layout.IMAGE.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val blocks = listOf(page, paragraph, file)
|
||||
|
||||
|
@ -5870,7 +5847,7 @@ class DefaultBlockViewRendererTest {
|
|||
anchor = page.id,
|
||||
focus = Editor.Focus.empty(),
|
||||
indent = 0,
|
||||
details = Block.Details(details)
|
||||
details = ObjectViewDetails(details)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.anytypeio.anytype.core_models.NetworkModeConfig
|
|||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Position
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.StubFile
|
||||
import com.anytypeio.anytype.core_models.StubNumbered
|
||||
import com.anytypeio.anytype.core_models.StubObject
|
||||
|
@ -24,7 +23,6 @@ import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
|||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.core_utils.common.EventWrapper
|
||||
import com.anytypeio.anytype.core_utils.ext.Mimetype
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ClearLastOpenedObject
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.base.Result
|
||||
|
@ -106,6 +104,7 @@ import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
|||
import com.anytypeio.anytype.presentation.common.Action
|
||||
import com.anytypeio.anytype.presentation.common.Delegator
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.presentation.editor.editor.BlockDimensions
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Command
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Interactor
|
||||
|
@ -2573,7 +2572,7 @@ open class EditorViewModelTest {
|
|||
fileExt = ".pdf"
|
||||
)
|
||||
|
||||
val objectDetails = Block.Fields(targetObject.map)
|
||||
val objectDetails = targetObject.map
|
||||
|
||||
val page = listOf(
|
||||
Block(
|
||||
|
@ -2594,9 +2593,7 @@ open class EditorViewModelTest {
|
|||
root = root,
|
||||
blocks = page,
|
||||
context = root,
|
||||
details = Block.Details(mapOf(
|
||||
targetObjectId to objectDetails
|
||||
))
|
||||
details = mapOf(targetObjectId to objectDetails)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -3591,8 +3588,7 @@ open class EditorViewModelTest {
|
|||
|
||||
private fun givenOpenDocument(
|
||||
document: List<Block> = emptyList(),
|
||||
details: Block.Details = Block.Details(),
|
||||
relations: List<Relation> = emptyList(),
|
||||
details: ObjectViewDetails = ObjectViewDetails.EMPTY,
|
||||
objectRestrictions: List<ObjectRestriction> = emptyList()
|
||||
) {
|
||||
openPage.stub {
|
||||
|
@ -3604,7 +3600,7 @@ open class EditorViewModelTest {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = details,
|
||||
details = details.details,
|
||||
blocks = document,
|
||||
objectRestrictions = objectRestrictions
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
|
@ -19,13 +20,11 @@ import com.anytypeio.anytype.core_models.StubRelationObject
|
|||
import com.anytypeio.anytype.core_models.StubTitle
|
||||
import com.anytypeio.anytype.core_models.StubToggle
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.block.interactor.MergeBlocks
|
||||
import com.anytypeio.anytype.domain.block.interactor.UnlinkBlocks
|
||||
import com.anytypeio.anytype.domain.block.interactor.UpdateText
|
||||
import com.anytypeio.anytype.domain.block.interactor.UpdateTextStyle
|
||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
|
||||
|
@ -40,8 +39,6 @@ import org.junit.Before
|
|||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.stub
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verifyBlocking
|
||||
import org.mockito.kotlin.verifyNoInteractions
|
||||
|
@ -1333,16 +1330,16 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
format = Relation.Format.NUMBER
|
||||
)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.FEATURED_RELATIONS to listOf(
|
||||
relation.key,
|
||||
Relations.DESCRIPTION
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1362,7 +1359,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = document,
|
||||
details = details,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
stubUpdateText()
|
||||
stubGetTemplates()
|
||||
|
@ -1418,8 +1415,11 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
val paragraph = StubParagraph()
|
||||
val relation = StubRelationObject(format = Relation.Format.NUMBER)
|
||||
|
||||
val details = Block.Details(
|
||||
mapOf(root to Block.Fields(mapOf(Relations.FEATURED_RELATIONS to listOf(relation.key))))
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(root to mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.FEATURED_RELATIONS to listOf(relation.key)
|
||||
))
|
||||
)
|
||||
|
||||
val header = StubHeader(
|
||||
|
@ -1438,7 +1438,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = document,
|
||||
details = details,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
stubUpdateText()
|
||||
stubGetTemplates()
|
||||
|
@ -1559,14 +1559,13 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
format = RelationFormat.NUMBER
|
||||
)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.FEATURED_RELATIONS to listOf(
|
||||
relationKey,
|
||||
Relations.DESCRIPTION
|
||||
)
|
||||
root to mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.FEATURED_RELATIONS to listOf(
|
||||
relationKey,
|
||||
Relations.DESCRIPTION
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -1588,7 +1587,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = document,
|
||||
details = details,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
stubUpdateText()
|
||||
stubInterceptThreadStatus()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubFile
|
||||
import com.anytypeio.anytype.core_models.StubObject
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.presentation.util.DefaultCoroutineTestRule
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
|
@ -50,9 +50,9 @@ class EditorErrorMessageTest : EditorPresentationTestSetup() {
|
|||
targetObjectId = fileObjectId
|
||||
)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
fileObjectId to Block.Fields(
|
||||
fileObjectId to
|
||||
mapOf(
|
||||
Relations.ID to fileObjectId,
|
||||
Relations.NAME to "file object",
|
||||
|
@ -61,7 +61,6 @@ class EditorErrorMessageTest : EditorPresentationTestSetup() {
|
|||
Relations.LAYOUT to ObjectType.Layout.FILE.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val doc = listOf(
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
|
||||
import android.util.Log
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
|
@ -92,25 +93,25 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
Relations.TYPE to objectTypeId,
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE, r3.key)
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.UNIQUE_KEY to objectTypeKey,
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -124,7 +125,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -218,7 +219,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
|
@ -226,17 +227,17 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
Relations.TYPE to objectTypeId,
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE)
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.UNIQUE_KEY to objectTypeKey,
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -248,7 +249,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -322,7 +323,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
|
@ -330,17 +331,15 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
Relations.TYPE to objectTypeId,
|
||||
Relations.FEATURED_RELATIONS to emptyList<String>()
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.UNIQUE_KEY to objectTypeKey,
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -352,7 +351,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -427,25 +426,26 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
Relations.TYPE to objectTypeId,
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE, r3.key)
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.UNIQUE_KEY to objectTypeKey,
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -457,7 +457,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -549,25 +549,25 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
Relations.TYPE to objectTypeId,
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE, r1.key, r2.key, r3.key)
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.UNIQUE_KEY to objectTypeKey,
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -580,7 +580,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -694,17 +694,17 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
Relations.TYPE to objectTypeId,
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE, r3.key)
|
||||
)
|
||||
)
|
||||
|
||||
val customDetails = Block.Details(mapOf(root to objectFields))
|
||||
val customDetails = ObjectViewDetails(mapOf(root to objectFields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
@ -712,7 +712,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -809,24 +809,23 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
Relations.TYPE to objectTypeId,
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE, r3.key)
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.IS_DELETED to true
|
||||
)
|
||||
)
|
||||
|
||||
val customDetails =
|
||||
Block.Details(mapOf(root to objectFields, objectTypeId to objectTypeFields))
|
||||
ObjectViewDetails(mapOf(root to objectFields, objectTypeId to objectTypeFields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
@ -834,7 +833,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -922,7 +921,8 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val doc = listOf(page, header, title, block, featuredBlock)
|
||||
|
||||
val backlinksRelation = StubRelationObject(uniqueKey = Relations.BACKLINKS, key = Relations.BACKLINKS)
|
||||
val backlinksRelation =
|
||||
StubRelationObject(uniqueKey = Relations.BACKLINKS, key = Relations.BACKLINKS)
|
||||
val linksRelation = StubRelationObject(uniqueKey = Relations.LINKS, key = Relations.LINKS)
|
||||
|
||||
val objBacklinks1 = StubObject("objBacklinks1")
|
||||
|
@ -932,31 +932,33 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
val objLinksTo1 = StubObject("objLinksTo1")
|
||||
val objLinksTo2 = StubObject("objLinksTo2")
|
||||
|
||||
val objectDetails = Block.Details(
|
||||
val objectDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.BACKLINKS, Relations.LINKS),
|
||||
Relations.BACKLINKS to listOf(objBacklinks1.id, objBacklinks2.id, objBacklinks3.id),
|
||||
Relations.LINKS to listOf(objLinksTo1.id, objLinksTo2.id)
|
||||
)
|
||||
),
|
||||
objBacklinks1.id to Block.Fields(
|
||||
mapOf(Relations.ID to objBacklinks1.id)
|
||||
),
|
||||
objBacklinks2.id to Block.Fields(
|
||||
mapOf(Relations.ID to objBacklinks2.id)
|
||||
),
|
||||
objBacklinks3.id to Block.Fields(
|
||||
mapOf(Relations.ID to objBacklinks3.id)
|
||||
),
|
||||
objLinksTo1.id to Block.Fields(
|
||||
mapOf(Relations.ID to objLinksTo1.id)
|
||||
),
|
||||
objLinksTo2.id to Block.Fields(
|
||||
mapOf(Relations.ID to objLinksTo2.id)
|
||||
)
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(
|
||||
Relations.BACKLINKS,
|
||||
Relations.LINKS
|
||||
),
|
||||
Relations.BACKLINKS to listOf(
|
||||
objBacklinks1.id,
|
||||
objBacklinks2.id,
|
||||
objBacklinks3.id
|
||||
),
|
||||
Relations.LINKS to listOf(objLinksTo1.id, objLinksTo2.id)
|
||||
),
|
||||
objBacklinks1.id to
|
||||
mapOf(Relations.ID to objBacklinks1.id),
|
||||
objBacklinks2.id to
|
||||
mapOf(Relations.ID to objBacklinks2.id),
|
||||
objBacklinks3.id to
|
||||
mapOf(Relations.ID to objBacklinks3.id),
|
||||
objLinksTo1.id to
|
||||
mapOf(Relations.ID to objLinksTo1.id),
|
||||
objLinksTo2.id to
|
||||
mapOf(Relations.ID to objLinksTo2.id)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -971,7 +973,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = objectDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1031,89 +1033,94 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not render backlinks and links as featured relations, when no sub objects are present`() = runTest {
|
||||
fun `should not render backlinks and links as featured relations, when no sub objects are present`() =
|
||||
runTest {
|
||||
|
||||
val title = MockTypicalDocumentFactory.title
|
||||
val header = MockTypicalDocumentFactory.header
|
||||
val block = MockTypicalDocumentFactory.a
|
||||
val featuredBlock = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
fields = Block.Fields.empty(),
|
||||
children = emptyList(),
|
||||
content = Block.Content.FeaturedRelations
|
||||
)
|
||||
val title = MockTypicalDocumentFactory.title
|
||||
val header = MockTypicalDocumentFactory.header
|
||||
val block = MockTypicalDocumentFactory.a
|
||||
val featuredBlock = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
fields = Block.Fields.empty(),
|
||||
children = emptyList(),
|
||||
content = Block.Content.FeaturedRelations
|
||||
)
|
||||
|
||||
val page = Block(
|
||||
id = root,
|
||||
fields = Block.Fields(emptyMap()),
|
||||
content = Block.Content.Smart,
|
||||
children = listOf(header.id, featuredBlock.id, block.id)
|
||||
)
|
||||
val page = Block(
|
||||
id = root,
|
||||
fields = Block.Fields(emptyMap()),
|
||||
content = Block.Content.Smart,
|
||||
children = listOf(header.id, featuredBlock.id, block.id)
|
||||
)
|
||||
|
||||
val doc = listOf(page, header, title, block, featuredBlock)
|
||||
val doc = listOf(page, header, title, block, featuredBlock)
|
||||
|
||||
val backlinksRelation = StubRelationObject(uniqueKey = Relations.BACKLINKS, key = Relations.BACKLINKS)
|
||||
val linksRelation = StubRelationObject(uniqueKey = Relations.LINKS, key = Relations.LINKS)
|
||||
val backlinksRelation =
|
||||
StubRelationObject(uniqueKey = Relations.BACKLINKS, key = Relations.BACKLINKS)
|
||||
val linksRelation =
|
||||
StubRelationObject(uniqueKey = Relations.LINKS, key = Relations.LINKS)
|
||||
|
||||
val objectDetails = Block.Details(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.BACKLINKS, Relations.LINKS)
|
||||
val objectDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(
|
||||
Relations.BACKLINKS,
|
||||
Relations.LINKS
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
listOf(backlinksRelation, linksRelation)
|
||||
)
|
||||
|
||||
stubGetNetworkMode()
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = objectDetails,
|
||||
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
id = title.id,
|
||||
isFocused = false,
|
||||
text = title.content<Block.Content.Text>().text,
|
||||
emoji = null
|
||||
),
|
||||
BlockView.Text.Numbered(
|
||||
isFocused = false,
|
||||
id = block.id,
|
||||
marks = emptyList(),
|
||||
background = block.parseThemeBackgroundColor(),
|
||||
text = block.content<Block.Content.Text>().text,
|
||||
alignment = block.content<Block.Content.Text>().align?.toView(),
|
||||
number = 1,
|
||||
decorations = listOf(
|
||||
BlockView.Decoration(
|
||||
background = block.parseThemeBackgroundColor()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
listOf(backlinksRelation, linksRelation)
|
||||
)
|
||||
|
||||
stubGetNetworkMode()
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = objectDetails,
|
||||
relations = emptyList()
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
id = title.id,
|
||||
isFocused = false,
|
||||
text = title.content<Block.Content.Text>().text,
|
||||
emoji = null
|
||||
),
|
||||
BlockView.Text.Numbered(
|
||||
isFocused = false,
|
||||
id = block.id,
|
||||
marks = emptyList(),
|
||||
background = block.parseThemeBackgroundColor(),
|
||||
text = block.content<Block.Content.Text>().text,
|
||||
alignment = block.content<Block.Content.Text>().align?.toView(),
|
||||
number = 1,
|
||||
decorations = listOf(
|
||||
BlockView.Decoration(
|
||||
background = block.parseThemeBackgroundColor()
|
||||
)
|
||||
)
|
||||
assertEquals(
|
||||
expected = ViewState.Success(expected),
|
||||
actual = vm.state.value
|
||||
)
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
expected = ViewState.Success(expected),
|
||||
actual = vm.state.value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should render globalName relation with proper value from global name`() = runTest {
|
||||
|
@ -1141,21 +1148,22 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
key = Relations.IDENTITY,
|
||||
isHidden = true
|
||||
)
|
||||
val globalNameRelation = StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val globalNameRelation =
|
||||
StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val identityValue = MockDataFactory.randomString()
|
||||
val globalNameValue = "name123.any"
|
||||
|
||||
val objectDetails = Block.Details(
|
||||
val objectDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to emptyList<String>(),
|
||||
Relations.IDENTITY to identityValue,
|
||||
Relations.GLOBAL_NAME to globalNameValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to emptyList<String>(),
|
||||
Relations.IDENTITY to identityValue,
|
||||
Relations.GLOBAL_NAME to globalNameValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1170,7 +1178,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = objectDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1234,21 +1242,22 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
key = Relations.IDENTITY,
|
||||
isHidden = true
|
||||
)
|
||||
val globalNameRelation = StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val globalNameRelation =
|
||||
StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val identityValue = MockDataFactory.randomString()
|
||||
val globalNameValue = ""
|
||||
|
||||
val objectDetails = Block.Details(
|
||||
val objectDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.IDENTITY),
|
||||
Relations.IDENTITY to identityValue,
|
||||
Relations.GLOBAL_NAME to globalNameValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(Relations.IDENTITY),
|
||||
Relations.IDENTITY to identityValue,
|
||||
Relations.GLOBAL_NAME to globalNameValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1263,7 +1272,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = objectDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1322,23 +1331,24 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val doc = listOf(page, header, title, featuredBlock)
|
||||
|
||||
val globalNameRelation = StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val globalNameRelation =
|
||||
StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val globalNameValue = "name123.any"
|
||||
val someRelationKey = MockDataFactory.randomString()
|
||||
val someRelation = StubRelationObject(uniqueKey = someRelationKey, key = someRelationKey)
|
||||
val someRelationValue = "Some relation Value"
|
||||
|
||||
val objectDetails = Block.Details(
|
||||
val objectDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(someRelationKey),
|
||||
Relations.GLOBAL_NAME to globalNameValue,
|
||||
someRelationKey to someRelationValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(someRelationKey),
|
||||
Relations.GLOBAL_NAME to globalNameValue,
|
||||
someRelationKey to someRelationValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1353,7 +1363,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = objectDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1422,25 +1432,27 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val doc = listOf(page, header, title, featuredBlock)
|
||||
|
||||
val globalNameRelation = StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val globalNameRelation =
|
||||
StubRelationObject(uniqueKey = Relations.GLOBAL_NAME, key = Relations.GLOBAL_NAME)
|
||||
val globalNameValue = "name123.any"
|
||||
val identityRelation = StubRelationObject(uniqueKey = Relations.IDENTITY, key = Relations.IDENTITY)
|
||||
val identityRelation =
|
||||
StubRelationObject(uniqueKey = Relations.IDENTITY, key = Relations.IDENTITY)
|
||||
val identityValue = MockDataFactory.randomString()
|
||||
val someRelationKey = MockDataFactory.randomString()
|
||||
val someRelation = StubRelationObject(uniqueKey = someRelationKey, key = someRelationKey)
|
||||
val someRelationValue = "Some relation Value"
|
||||
|
||||
val objectDetails = Block.Details(
|
||||
val objectDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(someRelationKey),
|
||||
Relations.IDENTITY to identityValue,
|
||||
someRelationKey to someRelationValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.TYPE to MockDataFactory.randomString(),
|
||||
Relations.FEATURED_RELATIONS to listOf(someRelationKey),
|
||||
Relations.IDENTITY to identityValue,
|
||||
someRelationKey to someRelationValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.PARTICIPANT.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1455,7 +1467,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = objectDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
|
|
@ -2,20 +2,19 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import app.cash.turbine.test
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.InternalFlags
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubHeader
|
||||
import com.anytypeio.anytype.core_models.StubObjectType
|
||||
import com.anytypeio.anytype.core_models.StubSmartBlock
|
||||
import com.anytypeio.anytype.core_models.StubTitle
|
||||
import com.anytypeio.anytype.core_models.ext.toObject
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.presentation.util.DefaultCoroutineTestRule
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertIs
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.advanceUntilIdle
|
||||
import kotlinx.coroutines.test.runTest
|
||||
|
@ -50,16 +49,16 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
stubInterceptEvents()
|
||||
stubGetObjectTypes(emptyList())
|
||||
|
||||
val detailsList = Block.Details(
|
||||
val detailsList = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.TYPE to ObjectTypeIds.NOTE,
|
||||
Relations.LAYOUT to ObjectType.Layout.NOTE.code.toDouble(),
|
||||
Relations.INTERNAL_FLAGS to listOf(2.0, 0.0, 1.0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
stubOpenDocument(document = document, details = detailsList)
|
||||
|
||||
|
@ -71,39 +70,14 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val storedDetails = orchestrator.stores.details.current()
|
||||
|
||||
val objectDetails = ObjectWrapper.Basic(storedDetails.details[root]?.map.orEmpty())
|
||||
val objectDetails = storedDetails.details[root].toObject()
|
||||
|
||||
val expectedFlags = listOf(
|
||||
InternalFlags.ShouldSelectTemplate,
|
||||
InternalFlags.ShouldEmptyDelete,
|
||||
InternalFlags.ShouldSelectType
|
||||
)
|
||||
val actualFlags = objectDetails.internalFlags
|
||||
|
||||
assertEquals(expected = expectedFlags, actual = actualFlags)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should hasn't internal flags on object open`() = runTest {
|
||||
val title = StubTitle()
|
||||
val header = StubHeader(children = listOf(title.id))
|
||||
val page = StubSmartBlock(id = root, children = listOf(header.id))
|
||||
val document = listOf(page, header, title)
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(document = document)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
val storedDetails = orchestrator.stores.details.current()
|
||||
|
||||
val objectDetails = ObjectWrapper.Basic(storedDetails.details[root]?.map.orEmpty())
|
||||
|
||||
val expectedFlags = emptyList<InternalFlags>()
|
||||
val actualFlags = objectDetails.internalFlags
|
||||
val actualFlags = objectDetails?.internalFlags
|
||||
|
||||
assertEquals(expected = expectedFlags, actual = actualFlags)
|
||||
}
|
||||
|
@ -116,9 +90,9 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
val document = listOf(page, header, title)
|
||||
stubInterceptEvents()
|
||||
|
||||
val detailsList = Block.Details(
|
||||
val detailsList = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.TYPE to ObjectTypeIds.PAGE,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
|
@ -128,7 +102,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
InternalFlags.ShouldSelectType.code.toDouble(),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
stubOpenDocument(document = document, details = detailsList)
|
||||
|
@ -160,9 +134,9 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
||||
val detailsList = Block.Details(
|
||||
val detailsList = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.TYPE to ObjectTypeIds.PAGE,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
|
@ -171,7 +145,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
InternalFlags.ShouldEmptyDelete.code.toDouble()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
stubOpenDocument(document = document, details = detailsList)
|
||||
|
@ -200,9 +174,9 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
val document = listOf(page, header, title)
|
||||
stubInterceptEvents()
|
||||
|
||||
val detailsList = Block.Details(
|
||||
val detailsList = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.TYPE to ObjectTypeIds.PAGE,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
|
@ -211,7 +185,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
InternalFlags.ShouldEmptyDelete.code.toDouble(),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
stubOpenDocument(document = document, details = detailsList)
|
||||
|
@ -244,9 +218,9 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
val document = listOf(page, header, title)
|
||||
stubInterceptEvents()
|
||||
|
||||
val detailsList = Block.Details(
|
||||
val detailsList = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.TYPE to ObjectTypeIds.PAGE,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
|
@ -254,7 +228,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
InternalFlags.ShouldSelectType.code.toDouble(),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
stubOpenDocument(document = document, details = detailsList)
|
||||
|
@ -287,17 +261,18 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
val document = listOf(page, header, title)
|
||||
stubInterceptEvents()
|
||||
|
||||
val detailsList = Block.Details(
|
||||
val detailsList = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.TYPE to ObjectTypeIds.PAGE,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
Relations.INTERNAL_FLAGS to listOf(
|
||||
InternalFlags.ShouldSelectType.code.toDouble(),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
stubOpenDocument(document = document, details = detailsList)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
|
@ -279,16 +280,15 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
stubOpenDocument(
|
||||
document = page,
|
||||
details = Block.Details(
|
||||
details = ObjectViewDetails(
|
||||
mapOf(
|
||||
target to Block.Fields(
|
||||
target to
|
||||
mapOf(
|
||||
Relations.ID to target,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
Relations.SPACE_ID to defaultSpace
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -392,16 +392,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
stubClosePage()
|
||||
stubOpenDocument(
|
||||
document = page,
|
||||
details = Block.Details(
|
||||
details = ObjectViewDetails(
|
||||
mapOf(
|
||||
target to Block.Fields(
|
||||
target to
|
||||
mapOf(
|
||||
Relations.ID to target,
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
Relations.SPACE_ID to defaultSpace
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -505,16 +505,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
stubClosePage()
|
||||
stubOpenDocument(
|
||||
document = page,
|
||||
details = Block.Details(
|
||||
details = ObjectViewDetails(
|
||||
mapOf(
|
||||
bookmarkObjectId to Block.Fields(
|
||||
bookmarkObjectId to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.NAME to bookmarkTitle,
|
||||
Relations.DESCRIPTION to bookmarkDescription,
|
||||
Relations.SOURCE to bookmarkUrl
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -613,9 +613,9 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenDocument(
|
||||
document = page,
|
||||
details = Block.Details(
|
||||
details = ObjectViewDetails(
|
||||
mapOf(
|
||||
targetObjectId to Block.Fields(
|
||||
targetObjectId to
|
||||
mapOf(
|
||||
Relations.ID to targetObjectId,
|
||||
Relations.FILE_MIME_TYPE to mimeType,
|
||||
|
@ -623,7 +623,6 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
Relations.SIZE_IN_BYTES to fileSize
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -715,9 +714,9 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenDocument(
|
||||
document = page,
|
||||
details = Block.Details(
|
||||
details = ObjectViewDetails(
|
||||
mapOf(
|
||||
targetObjectId to Block.Fields(
|
||||
targetObjectId to
|
||||
mapOf(
|
||||
Relations.ID to targetObjectId,
|
||||
Relations.FILE_MIME_TYPE to mimeType,
|
||||
|
@ -725,7 +724,6 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
Relations.SIZE_IN_BYTES to fileSize
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -80,9 +80,7 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = Block.Details(),
|
||||
relations = listOf()
|
||||
document = doc
|
||||
)
|
||||
stubUpdateText()
|
||||
|
||||
|
@ -228,11 +226,7 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
|
|||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = Block.Details(),
|
||||
relations = listOf()
|
||||
)
|
||||
stubOpenDocument(document = doc)
|
||||
stubUpdateText()
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -396,9 +390,7 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = Block.Details(),
|
||||
relations = listOf()
|
||||
document = doc
|
||||
)
|
||||
stubUpdateText()
|
||||
val vm = buildViewModel()
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
import android.util.Log
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import app.cash.turbine.test
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.core_models.ObjectType.Layout
|
||||
|
@ -15,7 +16,6 @@ import com.anytypeio.anytype.domain.base.Result
|
|||
import com.anytypeio.anytype.domain.base.Resultat
|
||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParserImpl
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState
|
||||
import com.anytypeio.anytype.presentation.editor.editor.mention.MentionConst.MENTION_TITLE_EMPTY
|
||||
|
@ -163,7 +163,18 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val document = listOf(page, header, title, a)
|
||||
|
||||
stubOpenDocument(document)
|
||||
stubOpenDocument(
|
||||
document,
|
||||
details = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
mentionHash to mapOf(
|
||||
Relations.ID to mentionHash,
|
||||
Relations.LAYOUT to Layout.BASIC.code.toDouble(),
|
||||
Relations.NAME to mentionText
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
stubInterceptEvents()
|
||||
|
||||
updateText.stub {
|
||||
|
@ -203,8 +214,8 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
coroutineTestRule.advanceUntilIdle()
|
||||
|
||||
vm.state.test().apply {
|
||||
assertValue(
|
||||
ViewState.Success(
|
||||
assertEquals(
|
||||
expected = ViewState.Success(
|
||||
blocks = listOf(
|
||||
BlockView.Title.Basic(
|
||||
id = title.id,
|
||||
|
@ -226,14 +237,15 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
from = 5,
|
||||
to = 9
|
||||
),
|
||||
Markup.Mark.Mention.Base(
|
||||
from = from,
|
||||
to = from + mentionText.length,
|
||||
param = mentionHash,
|
||||
isArchived = false
|
||||
),
|
||||
Markup.Mark.Strikethrough(
|
||||
from = 29,
|
||||
to = 33
|
||||
),
|
||||
Markup.Mark.Mention.Loading(
|
||||
from = from,
|
||||
to = from + mentionText.length,
|
||||
param = mentionHash
|
||||
)
|
||||
),
|
||||
indent = 0,
|
||||
|
@ -246,7 +258,8 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
actual = this.value()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -844,14 +857,21 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = Block.Details(),
|
||||
blocks = document,
|
||||
details = mapOf(
|
||||
mentionTarget to mapOf(
|
||||
Relations.ID to mentionTarget,
|
||||
Relations.NAME to ""
|
||||
)
|
||||
),
|
||||
objectRestrictions = emptyList()
|
||||
),
|
||||
Event.Command.Details.Amend(
|
||||
context = root,
|
||||
target = mentionTarget,
|
||||
details = mapOf(Block.Fields.NAME_KEY to "Foob")
|
||||
details = mapOf(
|
||||
Relations.NAME to "Foob"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -973,12 +993,11 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
children = listOf(header.id, a.id)
|
||||
)
|
||||
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Relations.ID to mentionTarget,
|
||||
Relations.NAME to ""
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget to fieldsUpdated1,
|
||||
|
@ -1002,7 +1021,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = Block.Details(detailsAmend),
|
||||
details = detailsAmend,
|
||||
blocks = document,
|
||||
objectRestrictions = emptyList()
|
||||
),
|
||||
|
@ -1259,12 +1278,11 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
children = listOf(header.id, a.id)
|
||||
)
|
||||
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Relations.ID to mentionTarget,
|
||||
Relations.NAME to " "
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget to fieldsUpdated1,
|
||||
|
@ -1288,7 +1306,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = Block.Details(detailsAmend),
|
||||
details = detailsAmend,
|
||||
blocks = document,
|
||||
objectRestrictions = emptyList()
|
||||
),
|
||||
|
@ -1418,11 +1436,10 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
children = listOf(header.id, a.id)
|
||||
)
|
||||
|
||||
val fieldsUpdated1 = Block.Fields(
|
||||
val fieldsUpdated1 =
|
||||
mapOf(
|
||||
Relations.ID to mentionTarget
|
||||
)
|
||||
)
|
||||
|
||||
val detailsAmend = mapOf(
|
||||
mentionTarget to fieldsUpdated1,
|
||||
|
@ -1446,7 +1463,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = Block.Details(detailsAmend),
|
||||
details = detailsAmend,
|
||||
blocks = document,
|
||||
objectRestrictions = emptyList()
|
||||
),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
|
@ -63,15 +63,14 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
val doc = page(root)
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to defaultSpace
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
|
@ -114,16 +113,15 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
val space = defaultSpace
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.SPACE_ID to defaultSpace,
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to space
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val doc = page(root)
|
||||
|
@ -199,18 +197,16 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
val typeId = MockDataFactory.randomString()
|
||||
|
||||
val details = Block.Details(
|
||||
val details = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to space,
|
||||
Relations.TYPE to typeId
|
||||
)
|
||||
),
|
||||
typeId to Block.Fields(
|
||||
mapOf(Relations.ID to typeId, Relations.UNIQUE_KEY to ObjectTypeIds.PROFILE)
|
||||
)
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to space,
|
||||
Relations.TYPE to typeId
|
||||
),
|
||||
typeId to
|
||||
mapOf(Relations.ID to typeId, Relations.UNIQUE_KEY to ObjectTypeIds.PROFILE)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
import android.util.Log
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import app.cash.turbine.test
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubObjectType
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
|
@ -104,8 +104,9 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
|
@ -113,17 +114,15 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE),
|
||||
Relations.LAYOUT to ObjectType.Layout.NOTE.code.toDouble()
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.UNIQUE_KEY to objectType.uniqueKey,
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -136,10 +135,7 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
stubGetDefaultObjectType()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -224,8 +220,9 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
|
@ -233,17 +230,15 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
Relations.FEATURED_RELATIONS to listOf(Relations.TYPE),
|
||||
Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble()
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.UNIQUE_KEY to MockDataFactory.randomString(),
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -256,10 +251,7 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
stubGetDefaultObjectType()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
|
||||
import android.util.Log
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
|
@ -99,16 +100,15 @@ class EditorObjectTypeChangeWidgetTest : EditorPresentationTestSetup() {
|
|||
|
||||
val doc = listOf(page, header, title, paragraph, featuredBlock)
|
||||
|
||||
val objectDetails = Block.Fields(
|
||||
val objectDetails =
|
||||
mapOf(
|
||||
Relations.SPACE_ID to defaultSpace,
|
||||
Relations.TYPE to ObjectTypeIds.NOTE,
|
||||
Relations.LAYOUT to ObjectType.Layout.NOTE.code.toDouble(),
|
||||
Relations.INTERNAL_FLAGS to listOf(1.0)
|
||||
)
|
||||
)
|
||||
|
||||
val detailsList = Block.Details(details = mapOf(root to objectDetails))
|
||||
val detailsList = ObjectViewDetails(details = mapOf(root to objectDetails))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
@ -169,14 +169,13 @@ class EditorObjectTypeChangeWidgetTest : EditorPresentationTestSetup() {
|
|||
|
||||
val doc = listOf(page, header, paragraph, featuredBlock)
|
||||
|
||||
val objectDetails = Block.Fields(
|
||||
val objectDetails =
|
||||
mapOf(
|
||||
"type" to ObjectTypeIds.NOTE,
|
||||
"layout" to ObjectType.Layout.NOTE.code.toDouble()
|
||||
)
|
||||
)
|
||||
|
||||
val detailsList = Block.Details(details = mapOf(root to objectDetails))
|
||||
val detailsList = ObjectViewDetails(details = mapOf(root to objectDetails))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.NetworkModeConfig
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Response
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
|
@ -26,7 +25,6 @@ import com.anytypeio.anytype.domain.block.interactor.CreateBlock
|
|||
import com.anytypeio.anytype.domain.block.interactor.DuplicateBlock
|
||||
import com.anytypeio.anytype.domain.block.interactor.MergeBlocks
|
||||
import com.anytypeio.anytype.domain.block.interactor.Move
|
||||
import com.anytypeio.anytype.domain.block.interactor.MoveOld
|
||||
import com.anytypeio.anytype.domain.block.interactor.RemoveLinkMark
|
||||
import com.anytypeio.anytype.domain.block.interactor.ReplaceBlock
|
||||
import com.anytypeio.anytype.domain.block.interactor.SetObjectType
|
||||
|
@ -537,10 +535,8 @@ open class EditorPresentationTestSetup {
|
|||
|
||||
fun stubOpenDocument(
|
||||
document: List<Block> = emptyList(),
|
||||
details: Block.Details = Block.Details(),
|
||||
relations: List<Relation> = emptyList(),
|
||||
details: ObjectViewDetails = ObjectViewDetails.EMPTY,
|
||||
objectRestrictions: List<ObjectRestriction> = emptyList(),
|
||||
relationLinks: List<RelationLink> = emptyList(),
|
||||
spaceId: SpaceId = SpaceId(defaultSpace)
|
||||
) {
|
||||
openPage.stub {
|
||||
|
@ -560,7 +556,7 @@ open class EditorPresentationTestSetup {
|
|||
Event.Command.ShowObject(
|
||||
context = root,
|
||||
root = root,
|
||||
details = details,
|
||||
details = details.details,
|
||||
blocks = document,
|
||||
objectRestrictions = objectRestrictions
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
|
@ -62,7 +63,9 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
val value = "Safe as milk"
|
||||
|
||||
val customDetails = Block.Details(mapOf(root to Block.Fields(mapOf(relation.key to value))))
|
||||
val customDetails = ObjectViewDetails(mapOf(root to mapOf(
|
||||
Relations.ID to root,
|
||||
relation.key to value)))
|
||||
|
||||
val a = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
|
@ -95,7 +98,7 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = document,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -190,22 +193,21 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
relationObjectType.key to objectTypeId
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -217,7 +219,7 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
@ -311,22 +313,23 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
|
|||
val objectTypeName = MockDataFactory.randomString()
|
||||
val objectTypeDescription = MockDataFactory.randomString()
|
||||
|
||||
val objectFields = Block.Fields(
|
||||
val objectFields =
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1,
|
||||
r2.key to value2,
|
||||
r3.key to value3,
|
||||
relationObjectType.key to objectTypeId
|
||||
)
|
||||
)
|
||||
|
||||
val objectTypeFields = Block.Fields(
|
||||
val objectTypeFields =
|
||||
mapOf(
|
||||
Relations.ID to objectTypeId,
|
||||
Relations.NAME to objectTypeName,
|
||||
Relations.DESCRIPTION to objectTypeDescription
|
||||
Relations.DESCRIPTION to objectTypeDescription,
|
||||
Relations.UNIQUE_KEY to objectTypeId
|
||||
)
|
||||
)
|
||||
val customDetails = Block.Details(
|
||||
val customDetails = ObjectViewDetails(
|
||||
mapOf(
|
||||
root to objectFields,
|
||||
objectTypeId to objectTypeFields
|
||||
|
@ -339,7 +342,7 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relations = emptyList()
|
||||
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.presentation.MockObjectTypes
|
||||
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
|
||||
|
@ -440,16 +441,16 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() {
|
|||
val value3 = "Captain Beefheart and his Magic Band"
|
||||
|
||||
val customDetails =
|
||||
Block.Details(
|
||||
ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
root to
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
relation1.key to value1,
|
||||
relation2.key to value2,
|
||||
relation3.key to value3
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val a = Block(
|
||||
|
@ -483,13 +484,7 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubOpenDocument(
|
||||
document = document,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(
|
||||
key = it.key,
|
||||
format = it.relationFormat
|
||||
)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
|
|
@ -2,10 +2,10 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
|
||||
import android.os.Build
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubObjectType
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
|
@ -240,16 +240,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -300,16 +297,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -350,16 +344,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -404,19 +395,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(
|
||||
key = it.key,
|
||||
format = it.relationFormat
|
||||
)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
storeOfRelations.merge(objectRelations)
|
||||
|
@ -449,8 +434,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type1 = MockObjectTypes.objectTypePage
|
||||
val type2 = MockObjectTypes.objectTypeNote
|
||||
val type3 = MockObjectTypes.objectTypeTask
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubGetObjectTypes(listOf(type1, type2, type3))
|
||||
|
@ -517,16 +502,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -562,16 +544,16 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1, r2.key to value2, r3.key to value3
|
||||
)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
stubGetObjectTypes(listOf())
|
||||
|
||||
|
@ -633,16 +615,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -683,16 +662,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -737,16 +713,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -787,16 +760,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -841,16 +811,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -891,16 +858,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -945,16 +909,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -995,16 +956,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1063,16 +1021,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1113,16 +1068,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1181,16 +1133,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1233,16 +1182,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1288,16 +1234,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1340,16 +1283,13 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1393,8 +1333,7 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
|
@ -1440,8 +1379,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
|
@ -1487,8 +1426,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
|
@ -1532,8 +1471,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type1 = MockObjectTypes.objectTypePage
|
||||
val type2 = MockObjectTypes.objectTypeNote
|
||||
val type3 = MockObjectTypes.objectTypeCustom
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSearchObjects(
|
||||
|
@ -1612,16 +1551,20 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(
|
||||
Relations.ID to root,
|
||||
r1.key to value1, r2.key to value2, r3.key to value3
|
||||
)
|
||||
val customDetails = ObjectViewDetails(
|
||||
details = mapOf(
|
||||
root to fields
|
||||
)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
@ -1687,8 +1630,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
|
@ -1740,8 +1683,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
|
@ -1798,8 +1741,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
|
@ -1840,8 +1783,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
val type2 = StubObjectType(name = "Df")
|
||||
val type3 = StubObjectType(name = "LK")
|
||||
val objectTypes = listOf(type1, type2, type3)
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
|
@ -1879,8 +1822,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
// SETUP
|
||||
val doc = MockTypicalDocumentFactory.page(root)
|
||||
val a = MockTypicalDocumentFactory.a
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSearchObjects()
|
||||
|
@ -1917,8 +1860,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
// SETUP
|
||||
val doc = MockTypicalDocumentFactory.page(root)
|
||||
val a = MockTypicalDocumentFactory.a
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSearchObjects()
|
||||
|
@ -1955,8 +1898,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
// SETUP
|
||||
val doc = MockTypicalDocumentFactory.page(root)
|
||||
val a = MockTypicalDocumentFactory.a
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSearchObjects()
|
||||
|
@ -1993,8 +1936,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
// SETUP
|
||||
val doc = MockTypicalDocumentFactory.page(root)
|
||||
val a = MockTypicalDocumentFactory.a
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSearchObjects()
|
||||
|
@ -2031,8 +1974,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
// SETUP
|
||||
val doc = MockTypicalDocumentFactory.page(root)
|
||||
val a = MockTypicalDocumentFactory.a
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSearchObjects()
|
||||
|
@ -2069,8 +2012,7 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
// SETUP
|
||||
val doc = MockTypicalDocumentFactory.page(root)
|
||||
val a = MockTypicalDocumentFactory.a
|
||||
val fields = Block.Fields.empty()
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val customDetails = ObjectViewDetails.EMPTY
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSearchObjects()
|
||||
|
|
|
@ -2,10 +2,10 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
|
||||
import android.util.Log
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Position
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.domain.block.interactor.CreateBlock
|
||||
|
@ -76,8 +76,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubUpdateText()
|
||||
|
@ -188,8 +188,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubUpdateText()
|
||||
|
@ -311,8 +311,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(details = mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
|
@ -410,8 +410,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubUpdateText()
|
||||
|
@ -503,18 +503,16 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
val value1 = MockDataFactory.randomString()
|
||||
val value2 = MockDataFactory.randomString()
|
||||
val value3 = MockDataFactory.randomString()
|
||||
val fields = Block.Fields(mapOf(r1.key to value1, r2.key to value2, r3.key to value3))
|
||||
val customDetails = Block.Details(mapOf(root to fields))
|
||||
val fields = mapOf(r1.key to value1, r2.key to value2, r3.key to value3)
|
||||
val customDetails = ObjectViewDetails(mapOf(root to fields))
|
||||
|
||||
stubInterceptEvents()
|
||||
stubUpdateText()
|
||||
stubCreateBlock(root = root)
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(document = doc,
|
||||
details = customDetails,
|
||||
relationLinks = objectRelations.map {
|
||||
RelationLink(key = it.key, format = it.relationFormat)
|
||||
}
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = customDetails
|
||||
)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation.editor.editor
|
|||
|
||||
import android.util.Log
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Position
|
||||
|
@ -112,13 +113,11 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
|
||||
private fun setupInteractions(
|
||||
doc: List<Block>,
|
||||
details: Block.Details = Block.Details(),
|
||||
relations: List<Relation> = listOf()
|
||||
details: ObjectViewDetails = ObjectViewDetails.EMPTY,
|
||||
) {
|
||||
stubInterceptEvents()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
relations = relations,
|
||||
details = details
|
||||
)
|
||||
stubSplitBlock()
|
||||
|
@ -196,15 +195,14 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
fun createDetailsWithFeaturedRelations(root: Id, relation1: String, relation2: String) =
|
||||
Block.Details(
|
||||
ObjectViewDetails(
|
||||
mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf(
|
||||
"featuredRelations" to listOf(
|
||||
relation1, relation2
|
||||
root to
|
||||
mapOf(
|
||||
"featuredRelations" to listOf(
|
||||
relation1, relation2
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -613,7 +611,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -954,7 +952,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1018,7 +1016,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1197,7 +1195,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1378,7 +1376,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1452,7 +1450,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1526,7 +1524,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1602,7 +1600,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1675,7 +1673,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
@ -1748,7 +1746,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
setupInteractions(
|
||||
doc = doc,
|
||||
details = createDetailsWithFeaturedRelations(root, description.id, relation2.key),
|
||||
relations = listOf()
|
||||
|
||||
)
|
||||
val vm = buildViewModel()
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
|
|
@ -225,8 +225,6 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
|
|||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = Block.Details(),
|
||||
relations = listOf()
|
||||
)
|
||||
stubUpdateText()
|
||||
|
||||
|
@ -507,8 +505,6 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
|
|||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = Block.Details(),
|
||||
relations = listOf()
|
||||
)
|
||||
stubUpdateText()
|
||||
|
||||
|
@ -819,9 +815,7 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = Block.Details(),
|
||||
relations = listOf()
|
||||
document = doc
|
||||
)
|
||||
stubUpdateText()
|
||||
|
||||
|
@ -1045,9 +1039,7 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
|
|||
stubInterceptThreadStatus()
|
||||
stubSearchObjects()
|
||||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = Block.Details(),
|
||||
relations = listOf()
|
||||
document = doc
|
||||
)
|
||||
stubUpdateText()
|
||||
|
||||
|
|
|
@ -313,7 +313,10 @@ class EditorTitleTest : EditorPresentationTestSetup() {
|
|||
listOf(Event.Command.Details.Amend(
|
||||
context = root,
|
||||
target = root,
|
||||
details = mapOf(Relations.ICON_EMOJI to emoji)
|
||||
details = mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.ICON_EMOJI to emoji
|
||||
)
|
||||
))
|
||||
)
|
||||
}
|
||||
|
@ -430,7 +433,10 @@ class EditorTitleTest : EditorPresentationTestSetup() {
|
|||
listOf(Event.Command.Details.Amend(
|
||||
context = root,
|
||||
target = root,
|
||||
details = mapOf(Relations.ICON_EMOJI to emoji)
|
||||
details = mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.ICON_EMOJI to emoji
|
||||
)
|
||||
))
|
||||
)
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue