mirror of https://github.com/FreeTubeApp/FreeTube
Update FT history import to accept key lastViewedPlaylistId (#4038)
* * Update FT history import to accept key `lastViewedPlaylistId`
Also update the strange required key check logic
Which was last changed by 58882b3e16
* * Remove unused video property `paid`
This commit is contained in:
parent
3dcf535841
commit
c936a0ea5e
|
@ -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) => {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -318,8 +318,7 @@ export default defineComponent({
|
|||
lengthSeconds: this.lengthSeconds,
|
||||
timeAdded: new Date().getTime(),
|
||||
isLive: false,
|
||||
paid: false,
|
||||
type: 'video'
|
||||
type: 'video',
|
||||
}
|
||||
|
||||
const payload = {
|
||||
|
|
|
@ -1027,8 +1027,7 @@ export default defineComponent({
|
|||
watchProgress: watchProgress,
|
||||
timeWatched: new Date().getTime(),
|
||||
isLive: false,
|
||||
paid: false,
|
||||
type: 'video'
|
||||
type: 'video',
|
||||
}
|
||||
|
||||
this.updateHistory(videoData)
|
||||
|
|
Loading…
Reference in New Issue