Skip to content

Commit

Permalink
Merge branch 'development' into feature/history/remember-search-query
Browse files Browse the repository at this point in the history
* development: (74 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 2f8fa91 + 3529520 commit 47222b9
Show file tree
Hide file tree
Showing 113 changed files with 5,150 additions and 1,637 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/calibreapp-image-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
compressOnly: true
- name: Create New Pull Request If Needed
if: steps.calibre.outputs.markdown != ''
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
title: Compressed Images Nightly
branch-suffix: timestamp
Expand Down
23 changes: 5 additions & 18 deletions _scripts/ProcessLocalesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ class ProcessLocalesPlugin {
/** @type {(updatedLocales: [string, string][]) => void|null} */
this.notifyLocaleChange = null

if (this.hotReload) {
this.hotReloadScript = readFileSync(`${__dirname}/_hotReloadLocalesScript.js`, 'utf-8')
}

this.loadLocales()
}

/** @param {import('webpack').Compiler} compiler */
apply(compiler) {
const { CachedSource, RawSource } = compiler.webpack.sources;
const { Compilation } = compiler.webpack
const { Compilation, DefinePlugin } = compiler.webpack

new DefinePlugin({
'process.env.HOT_RELOAD_LOCALES': this.hotReload
}).apply(compiler)

compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
const IS_DEV_SERVER = !!compiler.watching
Expand Down Expand Up @@ -136,19 +136,6 @@ class ProcessLocalesPlugin {
compilation.fileDependencies.addAll(this.filePaths)
}
})

compiler.hooks.emit.tap(PLUGIN_NAME, (compilation) => {
if (this.hotReload) {
// Find generated JavaScript output file (e.g. renderer.js or web.js)
// and inject the code snippet that listens for locale updates and replaces vue-i18n's locales

/** @type {string} */
const filename = [...[...compilation.chunks][0].files]
.find(file => file.endsWith('.js'))

compilation.assets[filename]._source._children.push(`\n${this.hotReloadScript}`)
}
})
}

loadLocales() {
Expand Down
18 changes: 0 additions & 18 deletions _scripts/_hotReloadLocalesScript.js

This file was deleted.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
"autolinker": "^4.0.0",
"electron-context-menu": "^4.0.4",
"lodash.debounce": "^4.0.8",
"marked": "^14.1.0",
"marked": "^14.1.2",
"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,18 +87,18 @@
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"electron": "^32.0.1",
"electron-builder": "^24.13.3",
"electron": "^32.1.0",
"electron-builder": "^25.0.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-n": "^17.10.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-unicorn": "^55.0.0",
"eslint-plugin-vue": "^9.27.0",
"eslint-plugin-vue": "^9.28.0",
"eslint-plugin-vuejs-accessibility": "^2.4.1",
"eslint-plugin-yml": "^1.14.0",
"html-webpack-plugin": "^5.6.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.44",
"postcss": "^8.4.47",
"postcss-scss": "^4.0.9",
"prettier": "^2.8.8",
"rimraf": "^6.0.1",
"sass": "^1.77.8",
"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 All @@ -124,7 +124,7 @@
"vue-loader": "^15.10.0",
"webpack": "^5.94.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4",
"webpack-dev-server": "^5.1.0",
"yaml-eslint-parser": "^1.2.3"
}
}
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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 @@ -78,6 +79,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
11 changes: 11 additions & 0 deletions src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@ export default defineComponent({
break
}

case 'post': {
const { postId, query } = result

openInternalPath({
path: `/post/${postId}`,
query,
doCreateNewWindow
})
break
}

case 'channel': {
const { channelId, subPath, url } = result

Expand Down
1 change: 1 addition & 0 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
>
<span
class="changeLogText"
lang="en"
v-html="updateChangelog"
/>
<ft-flex-box>
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
26 changes: 22 additions & 4 deletions src/renderer/components/ft-community-post/ft-community-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import autolinker from 'autolinker'

import { A11y, Navigation, Pagination } from 'swiper/modules'

import { createWebURL, deepCopy, toLocalePublicationString } from '../../helpers/utils'
import { createWebURL, deepCopy, formatNumber, toLocalePublicationString } from '../../helpers/utils'
import { youtubeImageUrlToInvidious } from '../../helpers/api/invidious'

export default defineComponent({
Expand All @@ -29,17 +29,23 @@ export default defineComponent({
hideForbiddenTitles: {
type: Boolean,
default: true
}
},
singlePost: {
type: Boolean,
default: false
},
},
data: function () {
return {
postText: '',
postId: '',
authorThumbnails: null,
publishedText: '',
voteCount: '',
voteCount: 0,
formattedVoteCount: '',
postContent: '',
commentCount: '',
commentCount: null,
formattedCommentCount: '',
author: '',
authorId: '',
}
Expand All @@ -56,6 +62,16 @@ export default defineComponent({

hideVideo() {
return this.forbiddenTitles.some((text) => this.data.postContent.content.title?.toLowerCase().includes(text.toLowerCase()))
},

backendPreference: function () {
return this.$store.getters.getBackendPreference
},
backendFallback: function () {
return this.$store.getters.getBackendFallback
},
isInvidiousAllowed: function() {
return this.backendPreference === 'invidious' || this.backendFallback
}
},
created: function () {
Expand Down Expand Up @@ -127,7 +143,9 @@ export default defineComponent({
isRSS: this.data.isRSS
})
this.voteCount = this.data.voteCount
this.formattedVoteCount = formatNumber(this.voteCount)
this.commentCount = this.data.commentCount
this.formattedCommentCount = formatNumber(this.commentCount)
this.type = (this.data.postContent !== null && this.data.postContent !== undefined) ? this.data.postContent.type : 'text'
this.author = this.data.author
this.authorId = this.data.authorId
Expand Down
Loading

0 comments on commit 47222b9

Please sign in to comment.