Skip to content

Commit

Permalink
fix: background_visible, root_document_visible can be None in SceneInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Seb-sti1 committed Dec 5, 2024
1 parent d664759 commit a1de51a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rmscene/scene_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ def version_info(self, _) -> tuple[int, int]:
return (0, 1)

current_layer: LwwValue[CrdtId]
background_visible: LwwValue[bool]
root_document_visible: LwwValue[bool]
background_visible: tp.Optional[LwwValue[bool]]
root_document_visible: tp.Optional[LwwValue[bool]]
paper_size: tp.Optional[tuple[int, int]]

@classmethod
def from_stream(cls, stream: TaggedBlockReader) -> SceneInfo:
current_layer = stream.read_lww_id(1)
background_visible = stream.read_lww_bool(2)
root_document_visible = stream.read_lww_bool(3)
background_visible = stream.read_lww_bool(2) if stream.bytes_remaining_in_block() > 0 else None
root_document_visible = stream.read_lww_bool(3) if stream.bytes_remaining_in_block() > 0 else None
paper_size = stream.read_int_pair(5) if stream.bytes_remaining_in_block() > 0 else None

return SceneInfo(current_layer=current_layer,
Expand All @@ -159,8 +159,11 @@ def from_stream(cls, stream: TaggedBlockReader) -> SceneInfo:

def to_stream(self, writer: TaggedBlockWriter):
writer.write_lww_id(1, self.current_layer)
if not self.background_visible: return
writer.write_lww_bool(2, self.background_visible)
if not self.root_document_visible: return
writer.write_lww_bool(3, self.root_document_visible)
if not self.paper_size: return
writer.write_int_pair(5, self.paper_size)


Expand Down

0 comments on commit a1de51a

Please sign in to comment.