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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.anytypeio.anytype.core_models.ObjectTypeIds.BOOKMARK
import com.anytypeio.anytype.core_models.ObjectWrapper
import com.anytypeio.anytype.core_models.RelationLink
import com.anytypeio.anytype.core_models.Relations
import com.anytypeio.anytype.core_models.SupportedLayouts
import com.anytypeio.anytype.core_models.ThemeColor
import com.anytypeio.anytype.core_models.ext.parseThemeTextColor
import com.anytypeio.anytype.core_models.ext.textColor
Expand Down Expand Up @@ -622,6 +623,11 @@ class DefaultBlockViewRenderer @Inject constructor(
isPreviousBlockMedia = link is BlockView.LinkToObject.Default.Card
}
is Content.File -> {
val detail = details.details.getOrDefault(root.id, Block.Fields.empty())
val obj = ObjectWrapper.Basic(detail.map)
if (SupportedLayouts.fileLayouts.contains(obj.layout)) {
return@forEach
}
mCounter = 0
val blockDecorationScheme = buildNestedDecorationData(
block = block,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5752,4 +5752,63 @@ class DefaultBlockViewRendererTest {
assertEquals(expected = expected, actual = result)
}
//endregion

@Test
fun `should not render file block in case of file layout`() {

val file = StubFile(
backgroundColor = null,
state = Block.Content.File.State.DONE,
type = Block.Content.File.Type.FILE
)

val paragraph = StubParagraph()

val page = StubSmartBlock(children = listOf(paragraph.id, file.id))

val details = mapOf(page.id to Block.Fields(
mapOf(
Relations.NAME to "file-name",
Relations.LAYOUT to Layout.FILE.code.toDouble()
)
))

val blocks = listOf(page, paragraph, file)

val map = blocks.asMap()

wrapper = BlockViewRenderWrapper(
blocks = map,
renderer = renderer
)

val result = runBlocking {
wrapper.render(
root = page,
anchor = page.id,
focus = Editor.Focus.empty(),
indent = 0,
details = Block.Details(details)
)
}

val expected = listOf(
BlockView.Text.Paragraph(
indent = 0,
isFocused = false,
id = paragraph.id,
marks = emptyList(),
background = paragraph.parseThemeBackgroundColor(),
text = paragraph.content<Block.Content.Text>().text,
decorations = listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.None,
background = paragraph.parseThemeBackgroundColor()
)
),
)
)

assertEquals(expected = expected, actual = result)
}
}
Loading