diff --git a/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/BlockContext.kt b/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/BlockContext.kt index f44c3832..7400929e 100644 --- a/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/BlockContext.kt +++ b/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/BlockContext.kt @@ -82,7 +82,7 @@ public class BlockContext internal constructor( } } -public suspend fun SpaceContext.block(configure: suspend BlockContext.() -> Unit) { +public suspend fun SpaceContext.block(configure: suspend BlockContext.() -> Unit): Block { val space = space.id log.i { @@ -104,9 +104,11 @@ public suspend fun SpaceContext.block(configure: suspend BlockContext.() -> Unit ) context.configure() + + return context.block } -public suspend fun SpaceContext.sizedBlock(size: BlockSize, configure: suspend BlockContext.() -> Unit) { +public suspend fun SpaceContext.sizedBlock(size: BlockSize, configure: suspend BlockContext.() -> Unit): Block = block { setSize { size @@ -114,13 +116,12 @@ public suspend fun SpaceContext.sizedBlock(size: BlockSize, configure: suspend B configure() } -} public suspend fun SpaceContext.sizedBlockWithEntities( size: BlockSize, row: RowIndex? = null, configureEntities: suspend ContentEntitiesBuilder.() -> Unit -) { +): Block = sizedBlock(size) { row?.let { setRow { it } @@ -128,48 +129,35 @@ public suspend fun SpaceContext.sizedBlockWithEntities( setEntities(configureEntities) } -} -public suspend fun SpaceContext.smallBlock(configure: suspend BlockContext.() -> Unit) { +public suspend fun SpaceContext.smallBlock(configure: suspend BlockContext.() -> Unit): Block = sizedBlock(size = BlockSize.SMALL, configure) -} -public suspend fun SpaceContext.mediumBlock(configure: suspend BlockContext.() -> Unit) { +public suspend fun SpaceContext.mediumBlock(configure: suspend BlockContext.() -> Unit): Block = sizedBlock(size = BlockSize.MEDIUM, configure) -} -public suspend fun SpaceContext.largeBlock(configure: suspend BlockContext.() -> Unit) { +public suspend fun SpaceContext.largeBlock(configure: suspend BlockContext.() -> Unit): Block = sizedBlock(size = BlockSize.LARGE, configure) -} -public suspend fun SpaceContext.extraLargeBlock(configure: suspend BlockContext.() -> Unit) { +public suspend fun SpaceContext.extraLargeBlock(configure: suspend BlockContext.() -> Unit): Block = sizedBlock(size = BlockSize.EXTRA_LARGE, configure) -} public suspend fun SpaceContext.smallBlockWithEntities( row: RowIndex? = null, configureEntities: suspend ContentEntitiesBuilder.() -> Unit -) { - sizedBlockWithEntities(size = BlockSize.SMALL, row, configureEntities) -} +): Block = sizedBlockWithEntities(size = BlockSize.SMALL, row, configureEntities) public suspend fun SpaceContext.mediumBlockWithEntities( row: RowIndex? = null, configureEntities: suspend ContentEntitiesBuilder.() -> Unit -) { - sizedBlockWithEntities(size = BlockSize.MEDIUM, row, configureEntities) -} +): Block = sizedBlockWithEntities(size = BlockSize.MEDIUM, row, configureEntities) public suspend fun SpaceContext.largeBlockWithEntities( row: RowIndex? = null, configureEntities: suspend ContentEntitiesBuilder.() -> Unit -) { - sizedBlockWithEntities(size = BlockSize.LARGE, row, configureEntities) -} +): Block = sizedBlockWithEntities(size = BlockSize.LARGE, row, configureEntities) public suspend fun SpaceContext.extraLargeBlockWithEntities( row: RowIndex? = null, configureEntities: suspend ContentEntitiesBuilder.() -> Unit -) { - sizedBlockWithEntities(size = BlockSize.EXTRA_LARGE, row, configureEntities) -} \ No newline at end of file +): Block = sizedBlockWithEntities(size = BlockSize.EXTRA_LARGE, row, configureEntities) \ No newline at end of file diff --git a/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/SpaceContext.kt b/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/SpaceContext.kt index 38a396f1..cbd40670 100644 --- a/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/SpaceContext.kt +++ b/beam-client-app/src/jvmMain/kotlin/dev/d1s/beam/client/app/state/SpaceContext.kt @@ -100,7 +100,7 @@ public suspend fun ApplicationContext.space( spaceIdentifier: SpaceIdentifier = ROOT_SPACE_SLUG, processBlocks: Boolean = true, configure: suspend SpaceContext.() -> Unit -) { +): Space { var space = client.getSpace(spaceIdentifier).getOrNull() if (space == null) { @@ -142,6 +142,8 @@ public suspend fun ApplicationContext.space( val context = SpaceContext(space, processBlocks, client) context.configure() + + return context.space } public suspend fun SpaceContext.row(