Skip to content

Commit 1cc518e

Browse files
committed
feat(model-client): Add convenience method overload for pollHash to provide hash only
1 parent 13e7399 commit 1cc518e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

model-client/src/commonMain/kotlin/org/modelix/model/client2/IModelClientV2.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ interface IModelClientV2 {
7070
*/
7171
suspend fun poll(branch: BranchReference, lastKnownVersion: IVersion?): IVersion
7272

73+
suspend fun pollHash(branch: BranchReference, lastKnownHash: String?): String
74+
7375
suspend fun pollHash(branch: BranchReference, lastKnownVersion: IVersion?): String
7476

7577
suspend fun <R> query(branch: BranchReference, body: (IMonoStep<INode>) -> IMonoStep<R>): R

model-client/src/commonMain/kotlin/org/modelix/model/client2/ModelClientV2.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,16 @@ class ModelClientV2(
288288
}
289289

290290
override suspend fun pollHash(branch: BranchReference, lastKnownVersion: IVersion?): String {
291+
return pollHash(branch, lastKnownVersion?.getContentHash())
292+
}
293+
294+
override suspend fun pollHash(branch: BranchReference, lastKnownHash: String?): String {
291295
val response = httpClient.get {
292296
url {
293297
takeFrom(baseUrl)
294298
appendPathSegmentsEncodingSlash("repositories", branch.repositoryId.id, "branches", branch.branchName, "pollHash")
295-
if (lastKnownVersion != null) {
296-
parameters["lastKnown"] = lastKnownVersion.getContentHash()
299+
if (lastKnownHash != null) {
300+
parameters["lastKnown"] = lastKnownHash
297301
}
298302
}
299303
}

0 commit comments

Comments
 (0)