From e0cf59d90fc78823040a0a3ec453584ad5c1066d Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 26 Jan 2024 15:52:36 -0500 Subject: [PATCH] Use POST for search history --- docs/playlet-web-api.yml | 2 +- playlet-app/src/source/Main.bs | 2 +- .../Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs | 3 +-- playlet-web/src/lib/Api/PlayletApi.ts | 4 ++-- playlet-web/src/lib/Screens/SearchScreen.svelte | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/playlet-web-api.yml b/docs/playlet-web-api.yml index e8e2b4e6..b18b051f 100644 --- a/docs/playlet-web-api.yml +++ b/docs/playlet-web-api.yml @@ -106,7 +106,7 @@ paths: type: array items: type: string - put: + post: summary: Add to search history description: | Add a query to the search history. diff --git a/playlet-app/src/source/Main.bs b/playlet-app/src/source/Main.bs index a25408f2..93b5eb8f 100644 --- a/playlet-app/src/source/Main.bs +++ b/playlet-app/src/source/Main.bs @@ -45,7 +45,7 @@ function Main(args as object) as void input = CreateObject("roInput") input.setMessagePort(port) - ' TODO:P1 follow up on bug where roSystemLog does not fire for a video player in ComponentLibrary + ' TODO:P2 follow up on bug where roSystemLog does not fire for a video player in ComponentLibrary ' https://community.roku.com/t5/Roku-Developer-Program/BUG-roSystemLog-not-firing-with-ComponentLibrary/td-p/906075 systemLog = CreateObject("roSystemLog") systemLog.SetMessagePort(port) diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs index 31963b8c..62946ac0 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs @@ -18,8 +18,7 @@ namespace Http return true end function - ' TODO:P1 should be POST - @put("/api/search-history") + @post("/api/search-history") function AddSearchHistory(context as object) as boolean request = context.request response = context.response diff --git a/playlet-web/src/lib/Api/PlayletApi.ts b/playlet-web/src/lib/Api/PlayletApi.ts index c97cc0a6..96bdb1c3 100644 --- a/playlet-web/src/lib/Api/PlayletApi.ts +++ b/playlet-web/src/lib/Api/PlayletApi.ts @@ -111,8 +111,8 @@ export class PlayletApi { return await response.json(); } - static async putSearchHistory(query: string) { - const response = await PlayletApi.putJson(`${PlayletApi.host()}/api/search-history`, { query }); + static async addSearchHistory(query: string) { + const response = await PlayletApi.postJson(`${PlayletApi.host()}/api/search-history`, { query }); return await response.json(); } diff --git a/playlet-web/src/lib/Screens/SearchScreen.svelte b/playlet-web/src/lib/Screens/SearchScreen.svelte index 46ff96c6..8a7eddeb 100644 --- a/playlet-web/src/lib/Screens/SearchScreen.svelte +++ b/playlet-web/src/lib/Screens/SearchScreen.svelte @@ -104,7 +104,7 @@ } if (page === 1) { - const newSearchHistory = await PlayletApi.putSearchHistory(searchBoxText); + const newSearchHistory = await PlayletApi.addSearchHistory(searchBoxText); searchHistoryStore.set(newSearchHistory); } }