add refresh button to each podcast on the main page

pull/156/head
Arno Hautala 4 years ago
parent 8a2f7af9e8
commit 8cf1d8eaf0

@ -271,6 +271,13 @@
>
<i style="color: red;" class="fas fa-dot-circle"></i>
</button>
<button
class="button"
title="Click to refresh this podcast."
@click="refreshPodcast(podcast)"
>
<i class="fas fa-sync"></i>
</button>
<button
class="button"
title="Click to see details."
@ -667,6 +674,7 @@
return dt.toDateString()
},
downloadAllEpisodes(id) { downloadAllEpisodes(id);},
refreshPodcast(podcast) { refreshPodcast(podcast); },
deletePodcast(id){ deletePodcast(id,()=>{
const index= this.podcasts.findIndex(x=>x.ID===id);

@ -172,6 +172,34 @@
.then(function () {});
return false;
}
function refreshPodcast(podcast) {
axios
.get("/podcasts/" + podcast.ID + "/refresh")
.then(function (response) {
Vue.toasted.show(
"\"" + podcast.Title + "\" has been enqueued to refresh.",
{
theme: "bubble",
type: "info",
position: "top-right",
duration: 5000,
}
);
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
function deletePodcast(id,onSuccess) {
if (typeof id !== 'string'){
id= id.getAttribute('data-id')

@ -200,6 +200,17 @@ func DownloadAllEpisodesByPodcastId(c *gin.Context) {
}
}
func RefreshEpisodesByPodcastId(c *gin.Context) {
var searchByIdQuery SearchByIdQuery
if c.ShouldBindUri(&searchByIdQuery) == nil {
go service.RefreshPodcastByPodcastId(searchByIdQuery.Id)
c.JSON(200, gin.H{})
} else {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
}
}
func GetAllPodcastItems(c *gin.Context) {
var filter model.EpisodesFilter
err := c.ShouldBindQuery(&filter)

@ -155,6 +155,7 @@ func main() {
router.DELETE("/podcasts/:id", controllers.DeletePodcastById)
router.GET("/podcasts/:id/items", controllers.GetPodcastItemsByPodcastId)
router.GET("/podcasts/:id/download", controllers.DownloadAllEpisodesByPodcastId)
router.GET("/podcasts/:id/refresh", controllers.RefreshEpisodesByPodcastId)
router.DELETE("/podcasts/:id/items", controllers.DeletePodcastEpisodesById)
router.DELETE("/podcasts/:id/podcast", controllers.DeleteOnlyPodcastById)
router.GET("/podcasts/:id/pause", controllers.PausePodcastById)

@ -614,12 +614,7 @@ func RefreshEpisodes() error {
return err
}
for _, item := range data {
isNewPodcast := item.LastEpisode == nil
if isNewPodcast {
fmt.Println(item.Title)
db.ForceSetLastEpisodeDate(item.ID)
}
AddPodcastItems(&item, isNewPodcast)
RefreshPodcast(&item)
}
// setting := db.GetOrCreateSetting()
@ -628,6 +623,29 @@ func RefreshEpisodes() error {
return nil
}
func RefreshPodcastByPodcastId(podcastId string) error {
var podcast db.Podcast
err := db.GetPodcastById(podcastId, &podcast)
if err != nil {
return err
}
RefreshPodcast(&podcast)
go DownloadMissingEpisodes()
return nil
}
func RefreshPodcast(podcast *db.Podcast) {
isNewPodcast := podcast.LastEpisode == nil
if isNewPodcast {
fmt.Println(podcast.Title)
db.ForceSetLastEpisodeDate(podcast.ID)
}
AddPodcastItems(podcast, isNewPodcast)
}
func DeletePodcastEpisodes(id string) error {
var podcast db.Podcast

Loading…
Cancel
Save