Skip to content

Commit

Permalink
make document wait for its initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
7hong13 committed May 28, 2024
1 parent 9f86bbf commit 286eca6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion yorkie/src/androidTest/kotlin/dev/yorkie/core/TestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const val GENERAL_TIMEOUT = 3_000L
fun createClient() = Client(
"http://10.0.2.2:8080",
unaryClient = OkHttpClient.Builder()
.protocols(listOf(Protocol.H2_PRIOR_KNOWLEDGE))
.protocols(listOf(Protocol.HTTP_1_1))
.build(),
)

Expand Down
7 changes: 4 additions & 3 deletions yorkie/src/main/kotlin/dev/yorkie/core/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,10 @@ public class Client @VisibleForTesting internal constructor(
}

private suspend fun waitForInitialization(documentKey: Document.Key) {
val attachment = attachments.value[documentKey] ?: return
if (attachment.syncMode == SyncMode.Realtime) {
attachment.document.presences.first { it != UninitializedPresences }
val attachment = attachments.first { documentKey in it.keys }[documentKey] ?: return
attachment.document.presences.first { it != UninitializedPresences }
if (attachment.syncMode != SyncMode.Manual) {
attachment.document.events.first { it is Initialized }
}
}

Expand Down

0 comments on commit 286eca6

Please sign in to comment.