From f558e1637ce58a66a14dc9824fb3023ca6007c0c Mon Sep 17 00:00:00 2001 From: Laurent Constantin Date: Mon, 12 Aug 2024 23:48:43 +0200 Subject: [PATCH] fix(kobo): Fix bookmark progression as int --- src/Entity/BookmarkUser.php | 10 ++++++++++ src/Kobo/Response/SyncResponse.php | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Entity/BookmarkUser.php b/src/Entity/BookmarkUser.php index 421e2c5a..0091fd4a 100644 --- a/src/Entity/BookmarkUser.php +++ b/src/Entity/BookmarkUser.php @@ -58,6 +58,11 @@ public function getPercent(): ?float return $this->percent; } + public function getPercentAsInt(): ?int + { + return $this->percent === null ? null : intval($this->percent * 100); + } + public function setPercent(?float $percent): static { $this->percent = $percent; @@ -70,6 +75,11 @@ public function getSourcePercent(): ?float return $this->sourcePercent; } + public function getSourcePercentAsInt(): ?int + { + return $this->sourcePercent === null ? null : intval($this->sourcePercent * 100); + } + public function setSourcePercent(?float $sourcePercent): static { $this->sourcePercent = $sourcePercent; diff --git a/src/Kobo/Response/SyncResponse.php b/src/Kobo/Response/SyncResponse.php index 24658157..b6d22ccd 100644 --- a/src/Kobo/Response/SyncResponse.php +++ b/src/Kobo/Response/SyncResponse.php @@ -278,8 +278,8 @@ private function createBookmark(?BookmarkUser $bookMark): array 'Value' => $bookMark->getLocationValue(), 'Source' => $bookMark->getLocationSource(), ], - 'ProgressPercent' => $bookMark->getPercent(), - 'ContentSourceProgressPercent' => $bookMark->getSourcePercent(), + 'ProgressPercent' => $bookMark->getPercentAsInt(), + 'ContentSourceProgressPercent' => $bookMark->getSourcePercentAsInt(), ]; if (false === $bookMark->hasLocation()) {