Skip to content

Commit 7f140e2

Browse files
committed
fix: check for present video duration in history (with small refactoring)
1 parent e630b53 commit 7f140e2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/renderer/helpers/playlists.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export function getSortedPlaylistItems(playlistItems, sortOrder, locale, reverse
3535
})
3636
}
3737

38-
export function videoDurationPresent(v) {
39-
if (typeof v.lengthSeconds !== 'number') { return false }
38+
export function videoDurationPresent(video) {
39+
if (typeof video.lengthSeconds !== 'number') { return false }
4040

41-
return !(isNaN(v.lengthSeconds) || v.lengthSeconds === 0)
41+
return !(isNaN(video.lengthSeconds) || video.lengthSeconds === 0)
4242
}
4343

44-
function videoDurationWithFallback(v) {
45-
if (videoDurationPresent(v)) { return v.lengthSeconds }
44+
export function videoDurationWithFallback(video) {
45+
if (videoDurationPresent(video)) { return video.lengthSeconds }
4646

4747
// Fallback
4848
return 0

src/renderer/views/Playlist/Playlist.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
deepCopy,
2424
} from '../../helpers/utils'
2525
import { invidiousGetPlaylistInfo, youtubeImageUrlToInvidious } from '../../helpers/api/invidious'
26-
import { getSortedPlaylistItems, videoDurationPresent, SORT_BY_VALUES } from '../../helpers/playlists'
26+
import { getSortedPlaylistItems, videoDurationPresent, videoDurationWithFallback, SORT_BY_VALUES } from '../../helpers/playlists'
2727
import packageDetails from '../../../../package.json'
2828
import { MOBILE_WIDTH_THRESHOLD, PLAYLIST_HEIGHT_FORCE_LIST_THRESHOLD } from '../../../constants'
2929

@@ -442,7 +442,7 @@ export default defineComponent({
442442

443443
const videoHistory = this.$store.getters.getHistoryCacheById[video.videoId]
444444
if (typeof videoHistory !== 'undefined') {
445-
video.lengthSeconds = videoHistory.lengthSeconds
445+
video.lengthSeconds = videoDurationWithFallback(videoHistory)
446446
} else {
447447
// Mark at least one video have no duration, show notice later
448448
// Also assign fallback duration here

0 commit comments

Comments
 (0)