From 665fa44a4970dc79d2ed83e21df1abb3bf4652c9 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 10 Nov 2023 17:34:31 -0500 Subject: [PATCH] Fix bug with requests not sent --- CHANGELOG.md | 1 + .../src/components/Services/Invidious/InvidiousService.bs | 4 ++-- .../components/Services/SponsorBlock/SponsorBlockService.bs | 2 +- playlet-lib/src/source/services/HttpClient.bs | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a5056e7..5560d804 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - A rare bug that causes the app to crash when displaying video cells - A bug where we show error dialogs that happened on screens that are already closed - A bug where bookmarks show duplicate videos +- A bug where watch history is not always sent to Invidious ## [0.15.0] - 2023-11-05 diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs index b56fec1f..34f9df9d 100644 --- a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs +++ b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs @@ -88,7 +88,7 @@ namespace Invidious url = `${authToken.instance}${Invidious.HISTORY_ENDPOINT}/${videoId}` request = HttpClient.Post(url, "") request.Headers(m.GetAuthenticationHeaders(authToken.token)) - request.Send() + request.Await() end function function SearchSuggestions(q as string, cancellation = invalid as object) as object @@ -482,7 +482,7 @@ namespace Invidious request.Headers(m.GetAuthenticationHeaders(authToken.token)) request.Header("Content-Type", "application/json") - request.Send() + request.Await() end function function GetAuthorizeTokenLink() as dynamic diff --git a/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs b/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs index 196f9a6b..6f90380d 100644 --- a/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs +++ b/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs @@ -84,7 +84,7 @@ namespace SponsorBlock end if url = `${m.sponsorBlockConfig.serverAddress}${SponsorBlock.VIEWED_SEGMENT_ENDPOINT}?UUID=${segmentId}` - HttpClient.Post(url, "").Send() + HttpClient.Post(url, "").Await() end function function GenerateProgressBarBackground(segments as object, lengthSeconds as integer, path as string) diff --git a/playlet-lib/src/source/services/HttpClient.bs b/playlet-lib/src/source/services/HttpClient.bs index 6bc2fa6b..8dd17b32 100644 --- a/playlet-lib/src/source/services/HttpClient.bs +++ b/playlet-lib/src/source/services/HttpClient.bs @@ -202,6 +202,8 @@ namespace HttpClient return command end function + ' Note: Calling Send() only without Await() will not guarentee a request will be sent. + ' If a Task finishes before the request is sent, the request might be dropped. function Send() as HttpRequest if m.urlTransfer <> invalid or m._cache <> invalid return m