From af7c5da9a85531dfb430cde08395499bfcd091e9 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Sat, 31 Aug 2024 19:28:53 +0200 Subject: [PATCH] Fixed gpodder link loading --- src/gpodder/episodes/gpodder_episodes.rs | 11 ++++++++++- src/gpodder/subscription/subscriptions.rs | 6 +++++- ui/src/pages/GPodderIntegration.tsx | 17 ++++++++++------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/gpodder/episodes/gpodder_episodes.rs b/src/gpodder/episodes/gpodder_episodes.rs index a16b4d06..94e1f1c8 100644 --- a/src/gpodder/episodes/gpodder_episodes.rs +++ b/src/gpodder/episodes/gpodder_episodes.rs @@ -47,7 +47,7 @@ pub async fn get_episode_actions( let since_date = DateTime::from_timestamp(since.since, 0) .map(|v| v.naive_utc()); - let actions = Episode::get_actions_by_username( + let mut actions = Episode::get_actions_by_username( username.clone(), &mut pool.get().unwrap(), since_date, @@ -56,6 +56,15 @@ pub async fn get_episode_actions( since.podcast.clone(), ) .await; + + + if let Some(device) = since.device.clone() { + actions.iter_mut().for_each(|a| { + a.device = device.clone(); + }); + } + + Ok(HttpResponse::Ok().json(EpisodeActionResponse { actions, timestamp: get_current_timestamp(), diff --git a/src/gpodder/subscription/subscriptions.rs b/src/gpodder/subscription/subscriptions.rs index 91ca24b5..54473228 100644 --- a/src/gpodder/subscription/subscriptions.rs +++ b/src/gpodder/subscription/subscriptions.rs @@ -48,8 +48,12 @@ pub async fn get_subscriptions( ) .await; + match res { - Ok(res) => Ok(HttpResponse::Ok().json(res)), + Ok(res) => { + + Ok(HttpResponse::Ok().json(res)) + }, Err(_) => Ok(HttpResponse::InternalServerError().finish()), } } diff --git a/ui/src/pages/GPodderIntegration.tsx b/ui/src/pages/GPodderIntegration.tsx index b33fde51..1ca93fe2 100644 --- a/ui/src/pages/GPodderIntegration.tsx +++ b/ui/src/pages/GPodderIntegration.tsx @@ -1,6 +1,6 @@ import axios, {AxiosResponse} from "axios"; import {Setting} from "../models/Setting"; -import {useState} from "react"; +import {useEffect, useState} from "react"; import {useTranslation} from "react-i18next"; import {Podcast} from "../store/CommonSlice"; import {handleAddPodcast} from "../utils/ErrorSnackBarResponses"; @@ -16,11 +16,14 @@ export const GPodderIntegration = ()=> { const [gpodderOnlyPodcasts, setGPodderOnlyPodcasts] = useState([]) const {t} = useTranslation() - axios.get('/podcast/available/gpodder') - .then((res: AxiosResponse) => { - console.log("Res is",res) - setGPodderOnlyPodcasts(res.data) - }) + + useEffect(() => { + axios.get('/podcast/available/gpodder') + .then((res: AxiosResponse) => { + setGPodderOnlyPodcasts(res.data) + }) + }, []); + const addPodcast = (feedUrl: string)=>{ setGPodderOnlyPodcasts(gpodderOnlyPodcasts.filter(p=>p.podcast!=feedUrl)) @@ -63,4 +66,4 @@ export const GPodderIntegration = ()=> { } -} \ No newline at end of file +}