Skip to content

Commit

Permalink
Update FT history import to accept key lastViewedPlaylistId (#4038)
Browse files Browse the repository at this point in the history
* * Update FT history import to accept key `lastViewedPlaylistId`

Also update the strange required key check logic
Which was last changed by 58882b3

* * Remove unused video property `paid`
  • Loading branch information
PikachuEXE authored Sep 29, 2023
1 parent 3dcf535 commit c936a0e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
30 changes: 20 additions & 10 deletions src/renderer/components/data-settings/data-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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)
}
Expand Down Expand Up @@ -815,7 +827,6 @@ export default defineComponent({
historyObject.lengthSeconds = null
historyObject.watchProgress = 1
historyObject.isLive = false
historyObject.paid = false

this.updateHistory(historyObject)
}
Expand Down Expand Up @@ -889,8 +900,7 @@ export default defineComponent({
'lengthSeconds',
'timeAdded',
'isLive',
'paid',
'type'
'type',
]

playlists.forEach(async (playlistData) => {
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/components/ft-list-video/ft-list-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ export default defineComponent({
watchProgress: 0,
timeWatched: new Date().getTime(),
isLive: false,
paid: false,
type: 'video'
}
this.updateHistory(videoData)
Expand Down Expand Up @@ -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 = {
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/watch-video-info/watch-video-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ export default defineComponent({
lengthSeconds: this.lengthSeconds,
timeAdded: new Date().getTime(),
isLive: false,
paid: false,
type: 'video'
type: 'video',
}

const payload = {
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,7 @@ export default defineComponent({
watchProgress: watchProgress,
timeWatched: new Date().getTime(),
isLive: false,
paid: false,
type: 'video'
type: 'video',
}

this.updateHistory(videoData)
Expand Down

0 comments on commit c936a0e

Please sign in to comment.