diff --git a/src/renderer/components/data-settings/data-settings.js b/src/renderer/components/data-settings/data-settings.js index a46d54afa87ab..51ebde0359d80 100644 --- a/src/renderer/components/data-settings/data-settings.js +++ b/src/renderer/components/data-settings/data-settings.js @@ -698,20 +698,28 @@ export default defineComponent({ textDecode.pop() const requiredKeys = [ - '_id', 'author', 'authorId', 'description', 'isLive', 'lengthSeconds', - 'paid', 'published', 'timeWatched', 'title', 'type', 'videoId', 'viewCount', - 'watchProgress' + 'watchProgress', + ] + + const optionalKeys = [ + // `_id` absent if marked as watched manually + '_id', + 'lastViewedPlaylistId', + ] + + const ignoredKeys = [ + 'paid', ] textDecode.forEach((history) => { @@ -723,15 +731,19 @@ export default defineComponent({ const historyObject = {} Object.keys(historyData).forEach((key) => { - if (!requiredKeys.includes(key)) { - showToast(`Unknown data key: ${key}`) - } else { + if (requiredKeys.includes(key) || optionalKeys.includes(key)) { historyObject[key] = historyData[key] + } else if (!ignoredKeys.includes(key)) { + showToast(`Unknown data key: ${key}`) } + // Else do not import the key }) - if (Object.keys(historyObject).length < (requiredKeys.length - 2)) { + const historyObjectKeysSet = new Set(Object.keys(historyObject)) + const missingKeys = requiredKeys.filter(x => !historyObjectKeysSet.has(x)) + if (missingKeys.length > 0) { showToast(this.$t('Settings.Data Settings.History object has insufficient data, skipping item')) + console.error('Missing Keys: ', missingKeys, historyData) } else { this.updateHistory(historyObject) } @@ -815,7 +827,6 @@ export default defineComponent({ historyObject.lengthSeconds = null historyObject.watchProgress = 1 historyObject.isLive = false - historyObject.paid = false this.updateHistory(historyObject) } @@ -889,8 +900,7 @@ export default defineComponent({ 'lengthSeconds', 'timeAdded', 'isLive', - 'paid', - 'type' + 'type', ] playlists.forEach(async (playlistData) => { diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index 96c8f247b0c34..9c5e399afe299 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -568,7 +568,6 @@ export default defineComponent({ watchProgress: 0, timeWatched: new Date().getTime(), isLive: false, - paid: false, type: 'video' } this.updateHistory(videoData) @@ -598,8 +597,7 @@ export default defineComponent({ lengthSeconds: this.data.lengthSeconds, timeAdded: new Date().getTime(), isLive: false, - paid: false, - type: 'video' + type: 'video', } const payload = { diff --git a/src/renderer/components/watch-video-info/watch-video-info.js b/src/renderer/components/watch-video-info/watch-video-info.js index 75f2e448d8d43..1798fb01c4ec4 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.js +++ b/src/renderer/components/watch-video-info/watch-video-info.js @@ -318,8 +318,7 @@ export default defineComponent({ lengthSeconds: this.lengthSeconds, timeAdded: new Date().getTime(), isLive: false, - paid: false, - type: 'video' + type: 'video', } const payload = { diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 4799f5188f97e..a07f748bf58b8 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -1027,8 +1027,7 @@ export default defineComponent({ watchProgress: watchProgress, timeWatched: new Date().getTime(), isLive: false, - paid: false, - type: 'video' + type: 'video', } this.updateHistory(videoData)