feat: playlist optimizations (#1216)

This commit is contained in:
Markos Gogoulos 2025-03-09 20:44:04 +02:00 committed by GitHub
parent 50e9f3103f
commit 21f76dbb6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -1312,7 +1312,7 @@ class Playlist(models.Model):
@property @property
def media_count(self): def media_count(self):
return self.media.count() return self.media.filter(listable=True).count()
def get_absolute_url(self, api=False): def get_absolute_url(self, api=False):
if api: if api:
@ -1359,7 +1359,7 @@ class Playlist(models.Model):
@property @property
def thumbnail_url(self): def thumbnail_url(self):
pm = self.playlistmedia_set.first() pm = self.playlistmedia_set.filter(media__listable=True).first()
if pm and pm.media.thumbnail: if pm and pm.media.thumbnail:
return helpers.url_from_path(pm.media.thumbnail.path) return helpers.url_from_path(pm.media.thumbnail.path)
return None return None

View File

@ -46,6 +46,11 @@ if (window.MediaCMS.site.devEnv) {
} }
function PlayAllLink(props) { function PlayAllLink(props) {
if (!props.media || !props.media.length) {
return <span>{props.children}</span>;
}
let playAllUrl = props.media[0].url; let playAllUrl = props.media[0].url;
if (window.MediaCMS.site.devEnv && -1 < playAllUrl.indexOf('view?')) { if (window.MediaCMS.site.devEnv && -1 < playAllUrl.indexOf('view?')) {

File diff suppressed because one or more lines are too long