Skip to content

Commit

Permalink
Merge branch 'feature/subscription-cache' into custom-builds/current
Browse files Browse the repository at this point in the history
* feature/subscription-cache:
  ! Rename subscriptions to subscription cache & fix outdated mutation reference
  Translated using Weblate (Italian)
  Translated using Weblate (Chinese (Traditional))
  Translated using Weblate (Chinese (Simplified))
  Translated using Weblate (French)
  Translated using Weblate (Spanish)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Spanish)
  Make adding duplicate disabled by default (FreeTubeApp#5044)
  Switch settings sections and form elements to created lifecycle hook (FreeTubeApp#5224)
  Translated using Weblate (French)
  Translated using Weblate (Estonian)
  Bump sass from 1.77.2 to 1.77.4 (FreeTubeApp#5222)
  Bump lefthook from 1.6.13 to 1.6.15 (FreeTubeApp#5223)
  Bump the eslint group with 2 updates (FreeTubeApp#5218)
  Bump electron from 30.0.8 to 30.0.9 (FreeTubeApp#5221)
  Bump swiper from 11.1.3 to 11.1.4 (FreeTubeApp#5220)
  Bump stylelint from 16.6.0 to 16.6.1 in the stylelint group (FreeTubeApp#5219)
  Add missing IPC channel constants (FreeTubeApp#5216)
  • Loading branch information
PikachuEXE committed Jun 5, 2024
2 parents a84051f + 80c322b commit 7b90488
Show file tree
Hide file tree
Showing 35 changed files with 434 additions and 255 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"path-browserify": "^1.0.1",
"portal-vue": "^2.1.7",
"process": "^0.11.10",
"swiper": "^11.1.3",
"swiper": "^11.1.4",
"video.js": "7.21.5",
"videojs-contrib-quality-levels": "^3.0.0",
"videojs-http-source-selector": "^1.1.6",
Expand All @@ -92,7 +92,7 @@
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"electron": "^30.0.8",
"electron": "^30.0.9",
"electron-builder": "^24.13.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -101,31 +101,31 @@
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-n": "^17.7.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-unicorn": "^53.0.0",
"eslint-plugin-vue": "^9.26.0",
"eslint-plugin-vuejs-accessibility": "^2.3.0",
"eslint-plugin-yml": "^1.14.0",
"html-webpack-plugin": "^5.6.0",
"js-yaml": "^4.1.0",
"json-minimizer-webpack-plugin": "^5.0.0",
"lefthook": "^1.6.13",
"lefthook": "^1.6.15",
"mini-css-extract-plugin": "^2.9.0",
"npm-run-all2": "^6.2.0",
"postcss": "^8.4.38",
"postcss-scss": "^4.0.9",
"prettier": "^2.8.8",
"rimraf": "^5.0.7",
"sass": "^1.77.2",
"sass": "^1.77.4",
"sass-loader": "^14.2.1",
"stylelint": "^16.6.0",
"stylelint": "^16.6.1",
"stylelint-config-sass-guidelines": "^11.1.0",
"stylelint-config-standard": "^36.0.0",
"stylelint-high-performance-animation": "^1.10.0",
"stylelint-use-logical-spec": "^5.0.1",
"tree-kill": "1.2.2",
"vue-devtools": "^5.1.4",
"vue-eslint-parser": "^9.4.2",
"vue-eslint-parser": "^9.4.3",
"vue-loader": "^15.10.0",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
Expand Down
21 changes: 17 additions & 4 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,35 @@ const IpcChannels = {
CREATE_NEW_WINDOW: 'create-new-window',
OPEN_IN_EXTERNAL_PLAYER: 'open-in-external-player',
NATIVE_THEME_UPDATE: 'native-theme-update',
APP_READY: 'app-ready',
RELAUNCH_REQUEST: 'relaunch-request',

SEARCH_INPUT_HANDLING_READY: 'search-input-handling-ready',
UPDATE_SEARCH_INPUT_TEXT: 'update-search-input-text',

OPEN_URL: 'open-url',
CHANGE_VIEW: 'change-view',

HISTORY_BACK: 'history-back',
HISTORY_FORWARD: 'history-forward',

DB_SETTINGS: 'db-settings',
DB_HISTORY: 'db-history',
DB_PROFILES: 'db-profiles',
DB_PLAYLISTS: 'db-playlists',
DB_SUBSCRIPTIONS: 'db-subscriptions',
DB_SUBSCRIPTION_CACHE: 'db-subscription-cache',

SYNC_SETTINGS: 'sync-settings',
SYNC_HISTORY: 'sync-history',
SYNC_PROFILES: 'sync-profiles',
SYNC_PLAYLISTS: 'sync-playlists',
SYNC_SUBSCRIPTIONS: 'sync-subscriptions',
SYNC_SUBSCRIPTION_CACHE: 'sync-subscription-cache',

GET_REPLACE_HTTP_CACHE: 'get-replace-http-cache',
TOGGLE_REPLACE_HTTP_CACHE: 'toggle-replace-http-cache',

SHOW_VIDEO_STATISTICS: 'show-video-statistics',

PLAYER_CACHE_GET: 'player-cache-get',
PLAYER_CACHE_SET: 'player-cache-set'
}
Expand Down Expand Up @@ -55,7 +68,7 @@ const DBActions = {
DELETE_ALL_VIDEOS: 'db-action-playlists-delete-all-videos',
},

SUBSCRIPTIONS: {
SUBSCRIPTION_CACHE: {
UPDATE_VIDEOS_BY_CHANNEL: 'db-action-subscriptions-update-videos-by-channel',
UPDATE_LIVE_STREAMS_BY_CHANNEL: 'db-action-subscriptions-update-live-streams-by-channel',
UPDATE_SHORTS_BY_CHANNEL: 'db-action-subscriptions-update-shorts-by-channel',
Expand All @@ -82,7 +95,7 @@ const SyncEvents = {
DELETE_VIDEO: 'sync-playlists-delete-video',
},

SUBSCRIPTIONS: {
SUBSCRIPTION_CACHE: {
UPDATE_VIDEOS_BY_CHANNEL: 'sync-subscriptions-update-videos-by-channel',
UPDATE_LIVE_STREAMS_BY_CHANNEL: 'sync-subscriptions-update-live-streams-by-channel',
UPDATE_SHORTS_BY_CHANNEL: 'sync-subscriptions-update-shorts-by-channel',
Expand Down
24 changes: 12 additions & 12 deletions src/datastores/handlers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,37 +167,37 @@ class Playlists {
}
}

class Subscriptions {
class SubscriptionCache {
static find() {
return db.subscriptions.findAsync({})
return db.subscriptionCache.findAsync({})
}

static updateVideosByChannelId({ channelId, entries, timestamp }) {
return db.subscriptions.updateAsync(
return db.subscriptionCache.updateAsync(
{ _id: channelId },
{ $set: { videos: entries, videosTimestamp: timestamp } },
{ upsert: true }
)
}

static updateLiveStreamsByChannelId({ channelId, entries, timestamp }) {
return db.subscriptions.updateAsync(
return db.subscriptionCache.updateAsync(
{ _id: channelId },
{ $set: { liveStreams: entries, liveStreamsTimestamp: timestamp } },
{ upsert: true }
)
}

static updateShortsByChannelId({ channelId, entries, timestamp }) {
return db.subscriptions.updateAsync(
return db.subscriptionCache.updateAsync(
{ _id: channelId },
{ $set: { shorts: entries, shortsTimestamp: timestamp } },
{ upsert: true }
)
}

static updateShortsWithChannelPageShortsByChannelId({ channelId, entries }) {
return db.subscriptions.findOneAsync({ _id: channelId }, { shorts: 1 }).then((doc) => {
return db.subscriptionCache.findOneAsync({ _id: channelId }, { shorts: 1 }).then((doc) => {
if (doc == null) { return }

const shorts = doc.shorts
Expand All @@ -221,7 +221,7 @@ class Subscriptions {
}
})

return db.subscriptions.updateAsync(
return db.subscriptionCache.updateAsync(
{ _id: channelId },
{ $set: { shorts: cacheShorts } },
{ upsert: true }
Expand All @@ -230,19 +230,19 @@ class Subscriptions {
}

static updateCommunityPostsByChannelId({ channelId, entries, timestamp }) {
return db.subscriptions.updateAsync(
return db.subscriptionCache.updateAsync(
{ _id: channelId },
{ $set: { communityPosts: entries, communityPostsTimestamp: timestamp } },
{ upsert: true }
)
}

static deleteMultipleChannels(channelIds) {
return db.subscriptions.removeAsync({ _id: { $in: channelIds } }, { multi: true })
return db.subscriptionCache.removeAsync({ _id: { $in: channelIds } }, { multi: true })
}

static deleteAll() {
return db.subscriptions.removeAsync({}, { multi: true })
return db.subscriptionCache.removeAsync({}, { multi: true })
}
}

Expand All @@ -252,7 +252,7 @@ function compactAllDatastores() {
db.history.compactDatafileAsync(),
db.profiles.compactDatafileAsync(),
db.playlists.compactDatafileAsync(),
db.subscriptions.compactDatafileAsync(),
db.subscriptionCache.compactDatafileAsync(),
])
}

Expand All @@ -261,7 +261,7 @@ export {
History as history,
Profiles as profiles,
Playlists as playlists,
Subscriptions as subscriptions,
SubscriptionCache as subscriptionCache,

compactAllDatastores,
}
30 changes: 15 additions & 15 deletions src/datastores/handlers/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,74 +191,74 @@ class Playlists {
}
}

class Subscriptions {
class SubscriptionCache {
static find() {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{ action: DBActions.GENERAL.FIND }
)
}

static updateVideosByChannelId({ channelId, entries, timestamp }) {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{
action: DBActions.SUBSCRIPTIONS.UPDATE_VIDEOS_BY_CHANNEL,
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_VIDEOS_BY_CHANNEL,
data: { channelId, entries, timestamp },
}
)
}

static updateLiveStreamsByChannelId({ channelId, entries, timestamp }) {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{
action: DBActions.SUBSCRIPTIONS.UPDATE_LIVE_STREAMS_BY_CHANNEL,
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_LIVE_STREAMS_BY_CHANNEL,
data: { channelId, entries, timestamp },
}
)
}

static updateShortsByChannelId({ channelId, entries, timestamp }) {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{
action: DBActions.SUBSCRIPTIONS.UPDATE_SHORTS_BY_CHANNEL,
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_SHORTS_BY_CHANNEL,
data: { channelId, entries, timestamp },
}
)
}

static updateShortsWithChannelPageShortsByChannelId({ channelId, entries }) {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{
action: DBActions.SUBSCRIPTIONS.UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL,
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL,
data: { channelId, entries },
}
)
}

static updateCommunityPostsByChannelId({ channelId, entries, timestamp }) {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{
action: DBActions.SUBSCRIPTIONS.UPDATE_COMMUNITY_POSTS_BY_CHANNEL,
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_COMMUNITY_POSTS_BY_CHANNEL,
data: { channelId, entries, timestamp },
}
)
}

static deleteMultipleChannels(channelIds) {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{ action: DBActions.GENERAL.DELETE_MULTIPLE, data: channelIds }
)
}

static deleteAll() {
return ipcRenderer.invoke(
IpcChannels.DB_SUBSCRIPTIONS,
IpcChannels.DB_SUBSCRIPTION_CACHE,
{ action: DBActions.GENERAL.DELETE_ALL }
)
}
Expand All @@ -269,5 +269,5 @@ export {
History as history,
Profiles as profiles,
Playlists as playlists,
Subscriptions as subscriptions,
SubscriptionCache as subscriptionCache,
}
2 changes: 1 addition & 1 deletion src/datastores/handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export {
history as DBHistoryHandlers,
profiles as DBProfileHandlers,
playlists as DBPlaylistHandlers,
subscriptions as DBSubscriptionsHandlers,
subscriptionCache as DBSubscriptionCacheHandlers,
} from 'DB_HANDLERS_ELECTRON_RENDERER_OR_WEB'
20 changes: 10 additions & 10 deletions src/datastores/handlers/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,56 +110,56 @@ class Playlists {
}
}

class Subscriptions {
class SubscriptionCache {
static find() {
return baseHandlers.subscriptions.find()
return baseHandlers.subscriptionCache.find()
}

static updateVideosByChannelId({ channelId, entries, timestamp }) {
return baseHandlers.subscriptions.updateVideosByChannelId({
return baseHandlers.subscriptionCache.updateVideosByChannelId({
channelId,
entries,
timestamp,
})
}

static updateLiveStreamsByChannelId({ channelId, entries, timestamp }) {
return baseHandlers.subscriptions.updateLiveStreamsByChannelId({
return baseHandlers.subscriptionCache.updateLiveStreamsByChannelId({
channelId,
entries,
timestamp,
})
}

static updateShortsByChannelId({ channelId, entries, timestamp }) {
return baseHandlers.subscriptions.updateShortsByChannelId({
return baseHandlers.subscriptionCache.updateShortsByChannelId({
channelId,
entries,
timestamp,
})
}

static updateShortsWithChannelPageShortsByChannelId({ channelId, entries }) {
return baseHandlers.subscriptions.updateShortsWithChannelPageShortsByChannelId({
return baseHandlers.subscriptionCache.updateShortsWithChannelPageShortsByChannelId({
channelId,
entries,
})
}

static updateCommunityPostsByChannelId({ channelId, entries, timestamp }) {
return baseHandlers.subscriptions.updateCommunityPostsByChannelId({
return baseHandlers.subscriptionCache.updateCommunityPostsByChannelId({
channelId,
entries,
timestamp,
})
}

static deleteMultipleChannels(channelIds) {
return baseHandlers.subscriptions.deleteMultipleChannels(channelIds)
return baseHandlers.subscriptionCache.deleteMultipleChannels(channelIds)
}

static deleteAll() {
return baseHandlers.subscriptions.deleteAll()
return baseHandlers.subscriptionCache.deleteAll()
}
}

Expand All @@ -168,5 +168,5 @@ export {
History as history,
Profiles as profiles,
Playlists as playlists,
Subscriptions as subscriptions,
SubscriptionCache as subscriptionCache,
}
2 changes: 1 addition & 1 deletion src/datastores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export const settings = new Datastore({ filename: dbPath('settings'), autoload:
export const profiles = new Datastore({ filename: dbPath('profiles'), autoload: true })
export const playlists = new Datastore({ filename: dbPath('playlists'), autoload: true })
export const history = new Datastore({ filename: dbPath('history'), autoload: true })
export const subscriptions = new Datastore({ filename: dbPath('subscriptions'), autoload: true })
export const subscriptionCache = new Datastore({ filename: dbPath('subscription-cache'), autoload: true })
Loading

0 comments on commit 7b90488

Please sign in to comment.