Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FT history import to accept key lastViewedPlaylistId #4038

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -570,7 +570,6 @@ export default defineComponent({
watchProgress: 0,
timeWatched: new Date().getTime(),
isLive: false,
paid: false,
type: 'video'
}
this.updateHistory(videoData)
Expand Down Expand Up @@ -600,8 +599,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 @@ -999,8 +999,7 @@ export default defineComponent({
watchProgress: watchProgress,
timeWatched: new Date().getTime(),
isLive: false,
paid: false,
type: 'video'
type: 'video',
}

this.updateHistory(videoData)
Expand Down