Skip to content

Commit

Permalink
encapsulate Document
Browse files Browse the repository at this point in the history
  • Loading branch information
7hong13 committed May 27, 2024
1 parent 677fa29 commit 9a2e440
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions yorkie/src/main/kotlin/dev/yorkie/core/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public class Client @VisibleForTesting internal constructor(
return@async SUCCESS
}

document.status = DocumentStatus.Attached
document.setStatus(DocumentStatus.Attached)
attachments.value += document.key to Attachment(
document,
response.documentId,
Expand Down Expand Up @@ -535,7 +535,7 @@ public class Client @VisibleForTesting internal constructor(
val pack = response.changePack.toChangePack()
document.applyChangePack(pack)
if (document.status != DocumentStatus.Removed) {
document.status = DocumentStatus.Detached
document.setStatus(DocumentStatus.Detached)
attachments.value -= document.key
}
SUCCESS
Expand Down
6 changes: 5 additions & 1 deletion yorkie/src/main/kotlin/dev/yorkie/document/Document.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class Document(

@Volatile
public var status = DocumentStatus.Detached
internal set
private set

@VisibleForTesting
public val garbageLength: Int
Expand Down Expand Up @@ -451,6 +451,10 @@ public class Document(
onlineClients.value -= actorID
}

internal fun setStatus(newStatus: DocumentStatus) {
this.status = newStatus
}

/**
* Deletes elements that were removed before the given time.
*/
Expand Down

0 comments on commit 9a2e440

Please sign in to comment.