Skip to content

Commit

Permalink
fix: add ability to disallow block management
Browse files Browse the repository at this point in the history
  • Loading branch information
d1snin committed May 8, 2024
1 parent 3e13771 commit 7832f26
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private val log = logging()

public class BlockContext internal constructor(
initialBlock: Block,
private val manage: Boolean,
internal val client: BeamClient
) {
private var internalBlock = initialBlock
Expand Down Expand Up @@ -81,7 +82,9 @@ public class BlockContext internal constructor(
}

val processedMetadata = metadata.toMutableMap().apply {
set(MetadataKeys.APP_BLOCK_MANAGED, "true")
if (manage) {
set(MetadataKeys.APP_BLOCK_MANAGED, "true")
}
}

val modification = BlockModification(row, validIndex, size, entities, processedMetadata, block.spaceId)
Expand All @@ -96,7 +99,7 @@ public class BlockContext internal constructor(
}
}

public suspend fun SpaceContext.block(configure: suspend BlockContext.() -> Unit): Block {
public suspend fun SpaceContext.block(manage: Boolean = true, configure: suspend BlockContext.() -> Unit): Block {
val space = space.id

log.i {
Expand All @@ -109,13 +112,16 @@ public suspend fun SpaceContext.block(configure: suspend BlockContext.() -> Unit
size = BlockSize.SMALL
spaceId = space

metadata(MetadataKeys.APP_BLOCK_MANAGED, "true")
if (manage) {
metadata(MetadataKeys.APP_BLOCK_MANAGED, "true")
}

void()
}.getOrThrow()

val context = BlockContext(
createdBlock,
manage,
client
)

Expand Down

0 comments on commit 7832f26

Please sign in to comment.