Skip to content

Commit

Permalink
Merge branch 'feature/playlist-2023-05' into custom-builds/current
Browse files Browse the repository at this point in the history
* feature/playlist-2023-05: (36 commits)
  ! Fix default playlists added when no playlist stored had no required attributes added on 1st run
  Translated using Weblate (Ukrainian)
  Translated using Weblate (Czech)
  Translated using Weblate (Hungarian)
  Translated using Weblate (Estonian)
  Translated using Weblate (Chinese (Simplified))
  Translated using Weblate (Turkish)
  Translated using Weblate (Arabic)
  local API: Support Post Live DVR videos (FreeTubeApp#3872)
  Make profiles keyboard accessible (FreeTubeApp#3863)
  Bump @babel/preset-env from 7.22.9 to 7.22.10 (FreeTubeApp#3882)
  Bump @babel/eslint-parser from 7.22.9 to 7.22.10 (FreeTubeApp#3880)
  Bump eslint-plugin-vuejs-accessibility from 2.1.0 to 2.2.0 (FreeTubeApp#3883)
  Bump marked from 7.0.0 to 7.0.2 (FreeTubeApp#3881)
  Bump eslint-plugin-vue from 9.16.1 to 9.17.0 (FreeTubeApp#3879)
  Bump @babel/core from 7.22.9 to 7.22.10 (FreeTubeApp#3877)
  Bump stylelint-high-performance-animation from 1.8.0 to 1.9.0 (FreeTubeApp#3878)
  Bump sass from 1.64.2 to 1.65.1 (FreeTubeApp#3876)
  Bump eslint from 8.46.0 to 8.47.0 (FreeTubeApp#3875)
  Translated using Weblate (Italian)
  ...
  • Loading branch information
PikachuEXE committed Aug 15, 2023
2 parents 734a56e + bcc99a1 commit 823d84e
Show file tree
Hide file tree
Showing 43 changed files with 598 additions and 483 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
'plugin:vue/recommended',
'standard',
'plugin:jsonc/recommended-with-json',
// 'plugin:vuejs-accessibility/recommended' // uncomment once issues are fixed
'plugin:vuejs-accessibility/recommended'
],

// https://eslint.org/docs/user-guide/configuring#configuring-plugins
Expand All @@ -70,6 +70,7 @@ module.exports = {
some: ['nesting', 'id']
}
}],
'vuejs-accessibility/no-static-element-interactions': 'off',
'n/no-callback-literal': 'warn',
'n/no-path-concat': 'warn',
'unicorn/better-regex': 'error',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/autoMerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- name: Auto Merge PR
if: github.event.pull_request.draft == false && (contains(${{ github.event.pull_request.base.ref }}, 'development') || contains(${{ github.event.pull_request.base.ref }}, 'RC'))
if: ${{ !github.event.pull_request.draft && (contains(github.event.pull_request.base.ref, 'development') || contains(github.event.pull_request.base.ref, 'RC')) }}
run: |
echo ${{ secrets.PUSH_TOKEN }} >> auth.txt
gh auth login --with-token < auth.txt
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
"ci": "yarn install --silent --frozen-lockfile"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-brands-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/vue-fontawesome": "^2.0.10",
"@seald-io/nedb": "^4.0.2",
"@silvermine/videojs-quality-selector": "^1.3.0",
"autolinker": "^4.0.0",
"electron-context-menu": "^3.6.1",
"lodash.debounce": "^4.0.8",
"marked": "^4.3.0",
"nedb-promises": "^6.2.1",
"marked": "^7.0.2",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"video.js": "7.21.5",
Expand All @@ -81,45 +81,45 @@
"youtubei.js": "^5.8.0"
},
"devDependencies": {
"@babel/core": "^7.22.9",
"@babel/eslint-parser": "^7.22.9",
"@babel/core": "^7.22.10",
"@babel/eslint-parser": "^7.22.10",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/preset-env": "^7.22.9",
"@babel/preset-env": "^7.22.10",
"@double-great/stylelint-a11y": "^2.0.2",
"babel-loader": "^9.1.3",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^5.0.1",
"electron": "^22.3.18",
"electron-builder": "^24.6.3",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.9.0",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsonc": "^2.9.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^48.0.1",
"eslint-plugin-vue": "^9.16.1",
"eslint-plugin-vuejs-accessibility": "^2.1.0",
"eslint-plugin-vue": "^9.17.0",
"eslint-plugin-vuejs-accessibility": "^2.2.0",
"eslint-plugin-yml": "^1.8.0",
"html-webpack-plugin": "^5.5.3",
"js-yaml": "^4.1.0",
"json-minimizer-webpack-plugin": "^4.0.0",
"lefthook": "^1.4.7",
"lefthook": "^1.4.8",
"mini-css-extract-plugin": "^2.7.6",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.26",
"postcss-scss": "^4.0.6",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"sass": "^1.64.1",
"sass": "^1.65.1",
"sass-loader": "^13.3.2",
"stylelint": "^15.10.2",
"stylelint-config-sass-guidelines": "^10.0.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-high-performance-animation": "^1.8.0",
"stylelint-high-performance-animation": "^1.9.0",
"tree-kill": "1.2.2",
"vue-devtools": "^5.1.4",
"vue-eslint-parser": "^9.3.1",
Expand Down
6 changes: 6 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,18 @@ const SyncEvents = {
}
}

// https://v2.vuejs.org/v2/api/#provide-inject
const Injectables = {
SHOW_OUTLINES: 'showOutlines'
}

// Utils
const MAIN_PROFILE_ID = 'allChannels'

export {
IpcChannels,
DBActions,
SyncEvents,
Injectables,
MAIN_PROFILE_ID
}
89 changes: 54 additions & 35 deletions src/datastores/handlers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import db from '../index'

class Settings {
static find() {
return db.settings.find({ _id: { $ne: 'bounds' } })
return db.settings.findAsync({ _id: { $ne: 'bounds' } })
}

static upsert(_id, value) {
return db.settings.update({ _id }, { _id, value }, { upsert: true })
return db.settings.updateAsync({ _id }, { _id, value }, { upsert: true })
}

static persist() {
return db.settings.compactDatafileAsync()
}

// ******************** //
// Unique Electron main process handlers
static _findAppReadyRelatedSettings() {
return db.settings.find({
return db.settings.findAsync({
$or: [
{ _id: 'disableSmoothScrolling' },
{ _id: 'useProxy' },
Expand All @@ -24,152 +28,167 @@ class Settings {
}

static _findBounds() {
return db.settings.findOne({ _id: 'bounds' })
return db.settings.findOneAsync({ _id: 'bounds' })
}

static _findTheme() {
return db.settings.findOne({ _id: 'baseTheme' })
return db.settings.findOneAsync({ _id: 'baseTheme' })
}

static _findSidenavSettings() {
return {
hideTrendingVideos: db.settings.findOne({ _id: 'hideTrendingVideos' }),
hidePopularVideos: db.settings.findOne({ _id: 'hidePopularVideos' }),
backendFallback: db.settings.findOne({ _id: 'backendFallback' }),
backendPreference: db.settings.findOne({ _id: 'backendPreference' }),
hidePlaylists: db.settings.findOne({ _id: 'hidePlaylists' }),
hideTrendingVideos: db.settings.findOneAsync({ _id: 'hideTrendingVideos' }),
hidePopularVideos: db.settings.findOneAsync({ _id: 'hidePopularVideos' }),
backendFallback: db.settings.findOneAsync({ _id: 'backendFallback' }),
backendPreference: db.settings.findOneAsync({ _id: 'backendPreference' }),
hidePlaylists: db.settings.findOneAsync({ _id: 'hidePlaylists' }),
}
}

static _updateBounds(value) {
return db.settings.update({ _id: 'bounds' }, { _id: 'bounds', value }, { upsert: true })
return db.settings.updateAsync({ _id: 'bounds' }, { _id: 'bounds', value }, { upsert: true })
}
// ******************** //
}

class History {
static find() {
return db.history.find({}).sort({ timeWatched: -1 })
return db.history.findAsync({}).sort({ timeWatched: -1 })
}

static upsert(record) {
return db.history.update({ videoId: record.videoId }, record, { upsert: true })
return db.history.updateAsync({ videoId: record.videoId }, record, { upsert: true })
}

static updateWatchProgress(videoId, watchProgress) {
return db.history.update({ videoId }, { $set: { watchProgress } }, { upsert: true })
return db.history.updateAsync({ videoId }, { $set: { watchProgress } }, { upsert: true })
}

static updateLastViewedPlaylist(videoId, lastViewedPlaylistId, lastViewedPlaylistType) {
return db.history.update({ videoId }, { $set: { lastViewedPlaylistId, lastViewedPlaylistType } }, { upsert: true })
return db.history.updateAsync({ videoId }, { $set: { lastViewedPlaylistId, lastViewedPlaylistType } }, { upsert: true })
}

static delete(videoId) {
return db.history.remove({ videoId })
return db.history.removeAsync({ videoId })
}

static deleteAll() {
return db.history.remove({}, { multi: true })
return db.history.removeAsync({}, { multi: true })
}

static persist() {
db.history.persistence.compactDatafile()
return db.history.compactDatafileAsync()
}
}

class Profiles {
static create(profile) {
return db.profiles.insert(profile)
return db.profiles.insertAsync(profile)
}

static find() {
return db.profiles.find({})
return db.profiles.findAsync({})
}

static upsert(profile) {
return db.profiles.update({ _id: profile._id }, profile, { upsert: true })
return db.profiles.updateAsync({ _id: profile._id }, profile, { upsert: true })
}

static delete(id) {
return db.profiles.remove({ _id: id })
return db.profiles.removeAsync({ _id: id })
}

static persist() {
db.profiles.persistence.compactDatafile()
return db.profiles.compactDatafileAsync()
}
}

class Playlists {
static create(playlists) {
return db.playlists.insert(playlists)
return db.playlists.insertAsync(playlists)
}

static find() {
return db.playlists.find({})
return db.playlists.findAsync({})
}

static upsert(playlist) {
return db.playlists.update({ _id: playlist._id }, playlist, { upsert: true })
return db.playlists.updateAsync({ _id: playlist._id }, playlist, { upsert: true })
}

static upsertVideoByPlaylistId(_id, videoData) {
return db.playlists.update(
return db.playlists.updateAsync(
{ _id },
{ $push: { videos: videoData } },
{ upsert: true }
)
}

static upsertVideoIdsByPlaylistId(_id, videoIds) {
return db.playlists.update(
return db.playlists.updateAsync(
{ _id },
{ $push: { videos: { $each: videoIds } } },
{ upsert: true }
)
}

static delete(_id) {
return db.playlists.remove({ _id, protected: { $ne: true } })
return db.playlists.removeAsync({ _id, protected: { $ne: true } })
}

static deleteVideoIdByPlaylistId(_id, videoId) {
return db.playlists.update(
return db.playlists.updateAsync(
{ _id },
{ $pull: { videos: { videoId } } },
{ upsert: true }
)
}

static deleteVideoIdsByPlaylistId(_id, videoIds) {
return db.playlists.update(
return db.playlists.updateAsync(
{ _id },
{ $pull: { videos: { $in: videoIds } } },
{ upsert: true }
)
}

static deleteAllVideosByPlaylistId(_id) {
return db.playlists.update(
return db.playlists.updateAsync(
{ _id },
{ $set: { videos: [] } },
{ upsert: true }
)
}

static deleteMultiple(ids) {
return db.playlists.remove({ _id: { $in: ids }, protected: { $ne: true } })
return db.playlists.removeAsync({ _id: { $in: ids }, protected: { $ne: true } })
}

static deleteAll() {
return db.playlists.removeMany()
return db.playlists.removeAsync({}, { multi: true })
}

static persist() {
return db.playlists.compactDatafileAsync()
}
}

function compactAllDatastores() {
return Promise.allSettled([
Settings.persist(),
History.persist(),
Profiles.persist(),
Playlists.persist(),
])
}

const baseHandlers = {
settings: Settings,
history: History,
profiles: Profiles,
playlists: Playlists
playlists: Playlists,

compactAllDatastores,
}

export default baseHandlers
10 changes: 5 additions & 5 deletions src/datastores/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Datastore from 'nedb-promises'
import Datastore from '@seald-io/nedb'

let dbPath = null

Expand All @@ -23,9 +23,9 @@ if (process.env.IS_ELECTRON_MAIN) {
}

const db = {}
db.settings = Datastore.create({ filename: dbPath('settings'), autoload: true })
db.profiles = Datastore.create({ filename: dbPath('profiles'), autoload: true })
db.playlists = Datastore.create({ filename: dbPath('playlists'), autoload: true })
db.history = Datastore.create({ filename: dbPath('history'), autoload: true })
db.settings = new Datastore({ filename: dbPath('settings'), autoload: true })
db.profiles = new Datastore({ filename: dbPath('profiles'), autoload: true })
db.playlists = new Datastore({ filename: dbPath('playlists'), autoload: true })
db.history = new Datastore({ filename: dbPath('history'), autoload: true })

export default db
Loading

0 comments on commit 823d84e

Please sign in to comment.