Skip to content

Commit

Permalink
Rename methods and fix save bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mfcar committed May 11, 2024
1 parent 00bfb5c commit 9ff5f2f
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 69 deletions.
104 changes: 52 additions & 52 deletions client/pages/config/rss-feeds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@
</div>
</template>
<template v-else>
<div v-if="incomingFeeds.length" class="block max-w-full">
<div v-if="feedSubscriptions.length" class="block max-w-full">
<div class="flex -mx-1 items-center mb-3">
<div class="w-3/4 px-1">
<form @submit.prevent="incomingFeedsSubmit" class="flex flex-grow">
<ui-text-input v-model="incomingFeedsSearch" @input="incomingFeedsInputUpdate" type="search" :placeholder="$strings.PlaceholderSearchTitle" class="flex-grow text-sm md:text-base" />
<form @submit.prevent="feedSubscriptionsSubmit" class="flex flex-grow">
<ui-text-input v-model="feedSubscriptionsSearch" @input="feedSubscriptionsInputUpdate" type="search" :placeholder="$strings.PlaceholderSearchTitle" class="flex-grow text-sm md:text-base" />
</form>
</div>
<div class="flex-grow px-1">
<ui-checkbox v-model="incomingFeedShowOnlyUnhealthy" :label="$strings.LabelFeedShowOnlyUnhealthy" checkbox-bg="primary" border-color="gray-600" label-class="pl-2 text-base font-semibold" />
<ui-checkbox v-model="feedSubscriptionsShowOnlyUnhealthy" :label="$strings.LabelFeedShowOnlyUnhealthy" checkbox-bg="primary" border-color="gray-600" label-class="pl-2 text-base font-semibold" />
</div>
</div>

Expand All @@ -109,43 +109,43 @@
<th class="w-16 text-center"></th>
</tr>

<tr v-for="incomingFeed in incomingFeedsList" :key="incomingFeed.id" class="cursor-pointer h-12">
<tr v-for="feedSubscription in feedSubscriptionsList" :key="feedSubscription.id" class="cursor-pointer h-12">
<!-- -->
<td>
<covers-preview-cover v-if="incomingFeed?.metadata?.imageUrl" :width="50"
:src="incomingFeed.metadata.imageUrl"
<covers-preview-cover v-if="feedSubscription?.metadata?.imageUrl" :width="50"
:src="feedSubscription.metadata.imageUrl"
:book-cover-aspect-ratio="bookCoverAspectRatio" :show-resolution="false"/>
<img v-else :src="noCoverUrl" class="h-full w-full"/>
</td>
<!-- -->
<td class="w-48 max-w-64 min-w-24 text-left truncate">
<p class="truncate">{{ incomingFeed.metadata.title }}</p>
<p class="truncate text-xs text-gray-300">{{ incomingFeed.metadata.feedUrl }}</p>
<p class="truncate">{{ feedSubscription.metadata.title }}</p>
<p class="truncate text-xs text-gray-300">{{ feedSubscription.metadata.feedUrl }}</p>
</td>
<!-- -->
<td class="text-left">
<ui-tooltip v-if="incomingFeed.lastEpisodeCheck" direction="top"
:text="$formatDatetime(incomingFeed.lastEpisodeCheck, dateFormat, timeFormat)">
<p class="text-gray-200">{{ $dateDistanceFromNow(incomingFeed.lastEpisodeCheck) }}</p>
<ui-tooltip v-if="feedSubscription.lastEpisodeCheck" direction="top"
:text="$formatDatetime(feedSubscription.lastEpisodeCheck, dateFormat, timeFormat)">
<p class="text-gray-200">{{ $dateDistanceFromNow(feedSubscription.lastEpisodeCheck) }}</p>
</ui-tooltip>
</td>
<!-- -->
<td class="text-left">
<ui-tooltip v-if="incomingFeed.metadata.lastSuccessfulFetchAt" direction="top"
:text="$formatDatetime(incomingFeed.metadata.lastSuccessfulFetchAt, dateFormat, timeFormat)">
<ui-tooltip v-if="feedSubscription.metadata.lastSuccessfulFetchAt" direction="top"
:text="$formatDatetime(feedSubscription.metadata.lastSuccessfulFetchAt, dateFormat, timeFormat)">
<p class="text-gray-200">{{
$dateDistanceFromNow(incomingFeed.metadata.lastSuccessfulFetchAt)
$dateDistanceFromNow(feedSubscription.metadata.lastSuccessfulFetchAt)
}}</p>
</ui-tooltip>
<p class="text-gray-200" v-else>{{ $strings.MessageNoAvailable }}</p>
</td>
<!-- -->
<td class="text-center leading-none lg:table-cell">
<widgets-feed-healthy-indicator :value="!!incomingFeed.metadata.feedHealthy" />
<widgets-feed-healthy-indicator :value="!!feedSubscription.metadata.feedHealthy" />
</td>
<!-- -->
<td class="text-center leading-none lg:table-cell">
<ui-tooltip v-if="incomingFeed.autoDownloadEpisodes" direction="top"
<ui-tooltip v-if="feedSubscription.autoDownloadEpisodes" direction="top"
:text="$strings.LabelEnabled">
<span class="material-icons text-2xl">check</span>
</ui-tooltip>
Expand All @@ -156,10 +156,10 @@
</td>
<!-- -->
<td class="text-left">
<ui-tooltip v-if="incomingFeed.autoDownloadEpisodes" direction="top"
:text="`${$strings.LabelCronExpression}: ${incomingFeed.autoDownloadSchedule}`">
<ui-tooltip v-if="feedSubscription.autoDownloadEpisodes" direction="top"
:text="`${$strings.LabelCronExpression}: ${feedSubscription.autoDownloadSchedule}`">
<p class="text-gray-200">
{{ nextRun(incomingFeed.autoDownloadSchedule) }}
{{ nextRun(feedSubscription.autoDownloadSchedule) }}
</p>
</ui-tooltip>
</td>
Expand All @@ -169,14 +169,14 @@
<ui-tooltip direction="top"
:text="$strings.ButtonCopyFeedURL">
<button class="inline-flex material-icons text-xl mx-1 mt-1 text-white/70 hover:text-white/100"
@click.stop="copyToClipboard(incomingFeed.metadata.feedUrl)">content_copy
@click.stop="copyToClipboard(feedSubscription.metadata.feedUrl)">content_copy
</button>
</ui-tooltip>
<ui-tooltip direction="top" :text="$strings.ButtonForceReCheckFeed">
<button class="inline-flex material-icons text-xl mx-1 mt-1 text-white/70 hover:text-white/100"
@click.stop="forceRecheckFeed(incomingFeed)"
:disabled="incomingFeed.isLoading">
<span v-if="incomingFeed.isLoading" class="material-icons">hourglass_empty</span>
@click.stop="forceRecheckFeed(feedSubscription)"
:disabled="feedSubscription.isLoading">
<span v-if="feedSubscription.isLoading" class="material-icons">hourglass_empty</span>
<span v-else class="material-icons">autorenew</span>
</button>
</ui-tooltip>
Expand All @@ -201,14 +201,14 @@ export default {
showFeedModal: false,
selectedFeed: null,
feeds: [],
incomingFeeds: [],
feedSubscriptions: [],
feedsSearch: null,
feedsSearchTimeout: null,
feedsSearchText: null,
incomingFeedsSearch: null,
incomingFeedsSearchTimeout: null,
incomingFeedsSearchText: null,
incomingFeedShowOnlyUnhealthy: false,
feedSubscriptionsSearch: null,
feedSubscriptionsSearchTimeout: null,
feedSubscriptionsSearchText: null,
feedSubscriptionsShowOnlyUnhealthy: false,
}
},
computed: {
Expand All @@ -230,17 +230,17 @@ export default {
return feed?.meta?.title?.toLowerCase().includes(this.feedsSearchText) || feed?.slug?.toLowerCase().includes(this.feedsSearchText)
})
},
incomingFeedsSorted() {
return this.incomingFeedShowOnlyUnhealthy
? this.incomingFeeds.filter(incomingFeed => !incomingFeed.metadata.feedHealthy)
: this.incomingFeeds;
feedSubscriptionsSorted() {
return this.feedSubscriptionsShowOnlyUnhealthy
? this.feedSubscriptions.filter(feedSubscription => !feedSubscription.metadata.feedHealthy)
: this.feedSubscriptions;
},
incomingFeedsList() {
return this.incomingFeedsSorted.filter((incomingFeed) => {
if (!this.incomingFeedsSearchText) return true
if (this.incomingFeedShowOnlyUnhealthy && incomingFeed?.metadata?.feedHealthy) return false
return incomingFeed?.metadata?.title?.toLowerCase().includes(this.incomingFeedsSearchText) ||
incomingFeed?.metadata?.feedUrl?.toLowerCase().includes(this.incomingFeedsSearchText)
feedSubscriptionsList() {
return this.feedSubscriptionsSorted.filter((feedSubscription) => {
if (!this.feedSubscriptionsSearchText) return true
if (this.feedSubscriptionsShowOnlyUnhealthy && feedSubscription?.metadata?.feedHealthy) return false
return feedSubscription?.metadata?.title?.toLowerCase().includes(this.feedSubscriptionsSearchText) ||
feedSubscription?.metadata?.feedUrl?.toLowerCase().includes(this.feedSubscriptionsSearchText)
})
},
},
Expand All @@ -256,15 +256,15 @@ export default {
this.feedsSearchText = this.feedsSearch.toLowerCase().trim()
}, 500)
},
incomingFeedsSubmit() {},
incomingFeedsInputUpdate() {
clearTimeout(this.incomingFeedsSearchTimeout)
this.incomingFeedsSearchTimeout = setTimeout(() => {
if (!this.incomingFeedsSearch || !this.incomingFeedsSearch.trim()) {
this.incomingFeedsSearchText = ''
feedSubscriptionsSubmit() {},
feedSubscriptionsInputUpdate() {
clearTimeout(this.feedSubscriptionsSearchTimeout)
this.feedSubscriptionsSearchTimeout = setTimeout(() => {
if (!this.feedSubscriptionsSearch || !this.feedSubscriptionsSearch.trim()) {
this.feedSubscriptionsSearchText = ''
return
}
this.incomingFeedsSearchText = this.incomingFeedsSearch.toLowerCase().trim()
this.feedSubscriptionsSearchText = this.feedSubscriptionsSearch.toLowerCase().trim()
}, 500)
},
showFeed(feed) {
Expand Down Expand Up @@ -355,21 +355,21 @@ export default {
}
this.feeds = data.feeds
},
async loadIncomingFeeds() {
const data = await this.$axios.$get(`/api/podcasts/incomingFeeds`).catch((err) => {
console.error('Failed to load incoming RSS feeds', err)
async loadPodcastsWithExternalFeedSubscriptions() {
const data = await this.$axios.$get(`/api/podcasts/external-podcast-feeds-status`).catch((err) => {
console.error('Failed to load podcasts with external feed subscriptions', err)
return null
})
if (!data) {
this.$toast.error('Failed to load incoming RSS feeds')
this.$toast.error('Failed to load podcasts with external feed subscriptions')
return
}
this.incomingFeeds = data.podcasts.map(podcast => ({...podcast, isLoading: false}));
this.feedSubscriptions = data.podcasts.map(podcast => ({...podcast, isLoading: false}));
},
init() {
this.loadFeeds()
this.loadIncomingFeeds()
this.loadPodcastsWithExternalFeedSubscriptions()
}
},
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion client/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"HeaderEpisodes": "Episodes",
"HeaderEreaderDevices": "Ereader Devices",
"HeaderEreaderSettings": "Ereader Settings",
"HeaderExternalFeedURLHealthChecker": "External Feed URL Health Checker",
"HeaderExternalFeedURLHealthChecker": "External Podcast Feeds Subscription Health Checker",
"HeaderFiles": "Files",
"HeaderFindChapters": "Find Chapters",
"HeaderIgnoredFiles": "Ignored Files",
Expand Down
12 changes: 6 additions & 6 deletions server/controllers/PodcastController.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ class PodcastController {

/**
* POST: /api/podcasts/feed
*
*
* @typedef getPodcastFeedReqBody
* @property {string} rssFeed
*
* @param {import('express').Request<{}, {}, getPodcastFeedReqBody, {}} req
* @param {import('express').Response} res
*
* @param {import('express').Request<{}, {}, getPodcastFeedReqBody, {}} req
* @param {import('express').Response} res
*/
async getPodcastFeed(req, res) {
if (!req.user.isAdminOrUp) {
Expand All @@ -130,8 +130,8 @@ class PodcastController {
res.json({ podcast })
}

async getPodcastsWithIncomingFeeds(req, res) {
const podcasts = await Database.podcastModel.getAllIncomingFeeds()
async getPodcastsWithExternalFeedsSubscriptions(req, res) {
const podcasts = await Database.podcastModel.getAllIWithFeedSubscriptions()
res.json({
podcasts
})
Expand Down
4 changes: 2 additions & 2 deletions server/managers/PodcastManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class PodcastManager {
}
podcast.lastEpisodeCheck = Date.now()
podcast.updatedAt = Date.now()
await Database.podcastModel.update(podcast, {where: { id: podcastId }})
await podcast.save()

return {lastEpisodeCheck: podcast.lastEpisodeCheck, lastSuccessfulFetchAt: podcast.lastSuccessfulFetchAt, feedHealthy: podcast.feedHealthy}
}
Expand Down Expand Up @@ -397,7 +397,7 @@ class PodcastManager {

/**
* OPML file string for podcasts in a library
* @param {import('../models/Podcast')[]} podcasts
* @param {import('../models/Podcast')[]} podcasts
* @returns {string} XML string
*/
generateOPMLFileText(podcasts) {
Expand Down
6 changes: 3 additions & 3 deletions server/models/Podcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { DataTypes, Model } = require('sequelize')
/**
* @typedef PodcastExpandedProperties
* @property {import('./PodcastEpisode')[]} podcastEpisodes
*
*
* @typedef {Podcast & PodcastExpandedProperties} PodcastExpanded
*/

Expand Down Expand Up @@ -127,7 +127,7 @@ class Podcast extends Model {
}
}

static async getAllIncomingFeeds() {
static async getAllIWithFeedSubscriptions() {
const podcasts = await this.findAll()
const podcastsFiltered = podcasts.filter(p => p.dataValues.feedURL !== null);
return podcastsFiltered.map(p => this.getOldPodcast({media: p.dataValues}))
Expand All @@ -154,7 +154,7 @@ class Podcast extends Model {

/**
* Initialize model
* @param {import('../Database').sequelize} sequelize
* @param {import('../Database').sequelize} sequelize
*/
static init(sequelize) {
super.init({
Expand Down
8 changes: 4 additions & 4 deletions server/routers/ApiRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ApiRouter {
//
this.router.post('/podcasts', PodcastController.create.bind(this))
this.router.post('/podcasts/feed', PodcastController.getPodcastFeed.bind(this))
this.router.get('/podcasts/incomingFeeds', PodcastController.getPodcastsWithIncomingFeeds.bind(this))
this.router.get('/podcasts/external-podcast-feeds-status', PodcastController.getPodcastsWithExternalFeedsSubscriptions.bind(this))
this.router.get('/podcasts/:id/feed', PodcastController.middleware.bind(this), PodcastController.checkPodcastFeed.bind(this))
this.router.get('/podcasts/:id/check-feed-url', PodcastController.checkPodcastFeedUrl.bind(this))
this.router.post('/podcasts/opml', PodcastController.getFeedsFromOPMLText.bind(this))
Expand Down Expand Up @@ -428,9 +428,9 @@ class ApiRouter {
/**
* Used when a series is removed from a book
* Series is removed if it only has 1 book
*
*
* @param {string} bookId
* @param {string[]} seriesIds
* @param {string[]} seriesIds
*/
async checkRemoveEmptySeries(bookId, seriesIds) {
if (!seriesIds?.length) return
Expand Down Expand Up @@ -458,7 +458,7 @@ class ApiRouter {

/**
* Remove an empty series & close an open RSS feed
* @param {import('../models/Series')} series
* @param {import('../models/Series')} series
*/
async removeEmptySeries(series) {
await this.rssFeedManager.closeFeedForEntityId(series.id)
Expand Down
2 changes: 1 addition & 1 deletion server/utils/queries/libraryItemsPodcastFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ module.exports = {
},

/**
* Get longest podcasts in library
* Get the longest podcasts in library
* @param {string} libraryId
* @param {number} limit
* @returns {Promise<{ id:string, title:string, duration:number }[]>}
Expand Down

0 comments on commit 9ff5f2f

Please sign in to comment.