Skip to content

Commit

Permalink
Merge branch 'development' into feature/subscription-cache
Browse files Browse the repository at this point in the history
* development: (29 commits)
  Translated using Weblate (Flemish (West))
  Added translation using Weblate (Flemish (West))
  Translated using Weblate (Slovak)
  Improve history import performance and fix some bugs (FreeTubeApp#5666)
  Bump electron from 32.0.2 to 32.1.0 (FreeTubeApp#5710)
  Local API: Use IOS HLS manifest for livestreams (FreeTubeApp#5705)
  Translated using Weblate (Slovak)
  Translated using Weblate (Japanese)
  Bump the stylelint group with 2 updates (FreeTubeApp#5706)
  Bump swiper from 11.1.12 to 11.1.14 (FreeTubeApp#5709)
  Fix a few memory leaks while tearing down the player (FreeTubeApp#5698)
  Fix audio track selection (FreeTubeApp#5697)
  Bump shaka-player from 4.10.12 to 4.11.1 (FreeTubeApp#5677)
  Translated using Weblate (Czech)
  Translated using Weblate (Serbian)
  Translated using Weblate (Polish)
  Translated using Weblate (German)
  Translated using Weblate (Chinese (Simplified Han script))
  Bump express from 4.19.2 to 4.20.0 (FreeTubeApp#5687)
  Translated using Weblate (Turkish)
  ...
  • Loading branch information
PikachuEXE committed Sep 16, 2024
2 parents 58c6b19 + 3529520 commit 8ef7b92
Show file tree
Hide file tree
Showing 34 changed files with 1,709 additions and 718 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"path-browserify": "^1.0.1",
"portal-vue": "^2.1.7",
"process": "^0.11.10",
"shaka-player": "^4.10.12",
"swiper": "^11.1.12",
"shaka-player": "^4.11.1",
"swiper": "^11.1.14",
"vue": "^2.7.16",
"vue-i18n": "^8.28.2",
"vue-observe-visibility": "^1.0.0",
Expand All @@ -87,7 +87,7 @@
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"electron": "^32.0.2",
"electron": "^32.1.0",
"electron-builder": "^25.0.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -107,14 +107,14 @@
"lefthook": "^1.7.15",
"mini-css-extract-plugin": "^2.9.1",
"npm-run-all2": "^6.2.2",
"postcss": "^8.4.45",
"postcss": "^8.4.47",
"postcss-scss": "^4.0.9",
"prettier": "^2.8.8",
"rimraf": "^6.0.1",
"sass": "^1.78.0",
"sass-loader": "^16.0.1",
"stylelint": "^16.9.0",
"stylelint-config-sass-guidelines": "^12.0.0",
"stylelint-config-sass-guidelines": "^12.1.0",
"stylelint-config-standard": "^36.0.1",
"stylelint-high-performance-animation": "^1.10.0",
"stylelint-use-logical-spec": "^5.0.1",
Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const DBActions = {
},

HISTORY: {
OVERWRITE: 'db-action-history-overwrite',
UPDATE_WATCH_PROGRESS: 'db-action-history-update-watch-progress',
UPDATE_PLAYLIST: 'db-action-history-update-playlist',
},
Expand Down Expand Up @@ -88,6 +89,7 @@ const SyncEvents = {
},

HISTORY: {
OVERWRITE: 'sync-history-overwrite',
UPDATE_WATCH_PROGRESS: 'sync-history-update-watch-progress',
UPDATE_PLAYLIST: 'sync-history-update-playlist',
},
Expand Down
6 changes: 6 additions & 0 deletions src/datastores/handlers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ class History {
return db.history.updateAsync({ videoId: record.videoId }, record, { upsert: true })
}

static async overwrite(records) {
await db.history.removeAsync({}, { multi: true })

await db.history.insertAsync(records)
}

static updateWatchProgress(videoId, watchProgress) {
return db.history.updateAsync({ videoId }, { $set: { watchProgress } }, { upsert: true })
}
Expand Down
7 changes: 7 additions & 0 deletions src/datastores/handlers/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class History {
)
}

static overwrite(records) {
return ipcRenderer.invoke(
IpcChannels.DB_HISTORY,
{ action: DBActions.HISTORY.OVERWRITE, data: records }
)
}

static updateWatchProgress(videoId, watchProgress) {
return ipcRenderer.invoke(
IpcChannels.DB_HISTORY,
Expand Down
4 changes: 4 additions & 0 deletions src/datastores/handlers/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class History {
return baseHandlers.history.upsert(record)
}

static overwrite(records) {
return baseHandlers.history.overwrite(records)
}

static updateWatchProgress(videoId, watchProgress) {
return baseHandlers.history.updateWatchProgress(videoId, watchProgress)
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,15 @@ function runApp() {
)
return null

case DBActions.HISTORY.OVERWRITE:
await baseHandlers.history.overwrite(data)
syncOtherWindows(
IpcChannels.SYNC_HISTORY,
event,
{ event: SyncEvents.HISTORY.OVERWRITE, data }
)
return null

case DBActions.HISTORY.UPDATE_WATCH_PROGRESS:
await baseHandlers.history.updateWatchProgress(data.videoId, data.watchProgress)
syncOtherWindows(
Expand Down
25 changes: 19 additions & 6 deletions src/renderer/components/data-settings/data-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default defineComponent({
allPlaylists: function () {
return this.$store.getters.getAllPlaylists
},
historyCacheById: function () {
return this.$store.getters.getHistoryCacheById
},
historyCacheSorted: function () {
return this.$store.getters.getHistoryCacheSorted
},
Expand Down Expand Up @@ -616,7 +619,7 @@ export default defineComponent({
})
},

importFreeTubeHistory(textDecode) {
async importFreeTubeHistory(textDecode) {
textDecode.pop()

const requiredKeys = [
Expand All @@ -630,20 +633,24 @@ export default defineComponent({
'title',
'type',
'videoId',
'viewCount',
'watchProgress',
]

const optionalKeys = [
// `_id` absent if marked as watched manually
'_id',
'lastViewedPlaylistId',
'lastViewedPlaylistItemId',
'lastViewedPlaylistType',
'viewCount',
]

const ignoredKeys = [
'paid',
]

const historyItems = new Map(Object.entries(this.historyCacheById))

textDecode.forEach((history) => {
const historyData = JSON.parse(history)
// We would technically already be done by the time the data is parsed,
Expand All @@ -667,14 +674,16 @@ export default defineComponent({
showToast(this.$t('Settings.Data Settings.History object has insufficient data, skipping item'))
console.error('Missing Keys: ', missingKeys, historyData)
} else {
this.updateHistory(historyObject)
historyItems.set(historyObject.videoId, historyObject)
}
})

await this.overwriteHistory(historyItems)

showToast(this.$t('Settings.Data Settings.All watched history has been successfully imported'))
},

importYouTubeHistory(historyData) {
async importYouTubeHistory(historyData) {
const filterPredicate = item =>
item.products.includes('YouTube') &&
item.titleUrl != null && // removed video doesnt contain url...
Expand Down Expand Up @@ -722,6 +731,8 @@ export default defineComponent({
'activityControls',
].concat(Object.keys(keyMapping))

const historyItems = new Map(Object.entries(this.historyCacheById))

filteredHistoryData.forEach(element => {
const historyObject = {}

Expand Down Expand Up @@ -750,10 +761,12 @@ export default defineComponent({
historyObject.watchProgress = 1
historyObject.isLive = false

this.updateHistory(historyObject)
historyItems.set(historyObject.videoId, historyObject)
}
})

await this.overwriteHistory(historyItems)

showToast(this.$t('Settings.Data Settings.All watched history has been successfully imported'))
},

Expand Down Expand Up @@ -1069,10 +1082,10 @@ export default defineComponent({
...mapActions([
'updateProfile',
'updateShowProgressBar',
'updateHistory',
'addPlaylist',
'addVideo',
'updatePlaylist',
'overwriteHistory'
]),

...mapMutations([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@
flex-direction: column-reverse;
}

/*
With the legacy formats, shaka hands over the captions to the browser,
that causes issues like the captions being displayed under the player controls.
The browser positions captions based on the video element as it doesn't know about shaka's custom controls.
To solve that we use shaka's caption displayer (UITextDisplayer), so we need to hide the browser's ones
*/
.player::-webkit-media-text-track-container {
display: none;
}

.sixteenByNine {
aspect-ratio: 16 / 9;
}
Expand Down
Loading

0 comments on commit 8ef7b92

Please sign in to comment.