@@ -50,6 +50,9 @@ export default defineComponent({
50
50
allPlaylists : function ( ) {
51
51
return this . $store . getters . getAllPlaylists
52
52
} ,
53
+ historyCacheById : function ( ) {
54
+ return this . $store . getters . getHistoryCacheById
55
+ } ,
53
56
historyCacheSorted : function ( ) {
54
57
return this . $store . getters . getHistoryCacheSorted
55
58
} ,
@@ -616,7 +619,7 @@ export default defineComponent({
616
619
} )
617
620
} ,
618
621
619
- importFreeTubeHistory ( textDecode ) {
622
+ async importFreeTubeHistory ( textDecode ) {
620
623
textDecode . pop ( )
621
624
622
625
const requiredKeys = [
@@ -630,20 +633,24 @@ export default defineComponent({
630
633
'title' ,
631
634
'type' ,
632
635
'videoId' ,
633
- 'viewCount' ,
634
636
'watchProgress' ,
635
637
]
636
638
637
639
const optionalKeys = [
638
640
// `_id` absent if marked as watched manually
639
641
'_id' ,
640
642
'lastViewedPlaylistId' ,
643
+ 'lastViewedPlaylistItemId' ,
644
+ 'lastViewedPlaylistType' ,
645
+ 'viewCount' ,
641
646
]
642
647
643
648
const ignoredKeys = [
644
649
'paid' ,
645
650
]
646
651
652
+ const historyItems = new Map ( Object . entries ( this . historyCacheById ) )
653
+
647
654
textDecode . forEach ( ( history ) => {
648
655
const historyData = JSON . parse ( history )
649
656
// We would technically already be done by the time the data is parsed,
@@ -667,14 +674,16 @@ export default defineComponent({
667
674
showToast ( this . $t ( 'Settings.Data Settings.History object has insufficient data, skipping item' ) )
668
675
console . error ( 'Missing Keys: ' , missingKeys , historyData )
669
676
} else {
670
- this . updateHistory ( historyObject )
677
+ historyItems . set ( historyObject . videoId , historyObject )
671
678
}
672
679
} )
673
680
681
+ await this . overwriteHistory ( historyItems )
682
+
674
683
showToast ( this . $t ( 'Settings.Data Settings.All watched history has been successfully imported' ) )
675
684
} ,
676
685
677
- importYouTubeHistory ( historyData ) {
686
+ async importYouTubeHistory ( historyData ) {
678
687
const filterPredicate = item =>
679
688
item . products . includes ( 'YouTube' ) &&
680
689
item . titleUrl != null && // removed video doesnt contain url...
@@ -722,6 +731,8 @@ export default defineComponent({
722
731
'activityControls' ,
723
732
] . concat ( Object . keys ( keyMapping ) )
724
733
734
+ const historyItems = new Map ( Object . entries ( this . historyCacheById ) )
735
+
725
736
filteredHistoryData . forEach ( element => {
726
737
const historyObject = { }
727
738
@@ -750,10 +761,12 @@ export default defineComponent({
750
761
historyObject . watchProgress = 1
751
762
historyObject . isLive = false
752
763
753
- this . updateHistory ( historyObject )
764
+ historyItems . set ( historyObject . videoId , historyObject )
754
765
}
755
766
} )
756
767
768
+ await this . overwriteHistory ( historyItems )
769
+
757
770
showToast ( this . $t ( 'Settings.Data Settings.All watched history has been successfully imported' ) )
758
771
} ,
759
772
@@ -1069,10 +1082,10 @@ export default defineComponent({
1069
1082
...mapActions ( [
1070
1083
'updateProfile' ,
1071
1084
'updateShowProgressBar' ,
1072
- 'updateHistory' ,
1073
1085
'addPlaylist' ,
1074
1086
'addVideo' ,
1075
1087
'updatePlaylist' ,
1088
+ 'overwriteHistory'
1076
1089
] ) ,
1077
1090
1078
1091
...mapMutations ( [
0 commit comments