Skip to content

Commit ce7c712

Browse files
committed
Merge branch 'development' into feature/history/remember-search-query
* development: Fix video start time handling (FreeTubeApp#5719) Local API: Handle new shorts node (FreeTubeApp#5679) Update subscription cache when subscribing from the channel page (FreeTubeApp#5717) Translated using Weblate (English (United Kingdom)) Implement persistent subscription cache (FreeTubeApp#5185) Translated using Weblate (Belarusian) Bump npm-run-all2 from 6.2.2 to 6.2.3 (FreeTubeApp#5708) Translated using Weblate (Swedish) Bump shaka-player from 4.11.1 to 4.11.3 (FreeTubeApp#5707) Translated using Weblate (Persian) v Downgrade electron-builder 25.x > 24.x (FreeTubeApp#5712) Translated using Weblate (Persian) Translated using Weblate (Persian) # Conflicts: # src/renderer/views/Channel/Channel.js # src/renderer/views/Channel/Channel.vue
2 parents 47222b9 + 9ca2c74 commit ce7c712

File tree

34 files changed

+1114
-1005
lines changed

34 files changed

+1114
-1005
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@
6767
"path-browserify": "^1.0.1",
6868
"portal-vue": "^2.1.7",
6969
"process": "^0.11.10",
70-
"shaka-player": "^4.11.1",
70+
"shaka-player": "^4.11.3",
7171
"swiper": "^11.1.14",
7272
"vue": "^2.7.16",
7373
"vue-i18n": "^8.28.2",
7474
"vue-observe-visibility": "^1.0.0",
7575
"vue-router": "^3.6.5",
7676
"vuex": "^3.6.2",
77-
"youtubei.js": "^10.4.0"
77+
"youtubei.js": "^10.5.0"
7878
},
7979
"devDependencies": {
8080
"@babel/core": "^7.25.2",
@@ -88,7 +88,7 @@
8888
"css-loader": "^7.1.2",
8989
"css-minimizer-webpack-plugin": "^7.0.0",
9090
"electron": "^32.1.0",
91-
"electron-builder": "^25.0.5",
91+
"electron-builder": "^24.13.3",
9292
"eslint": "^8.57.0",
9393
"eslint-config-prettier": "^9.1.0",
9494
"eslint-config-standard": "^17.1.0",
@@ -106,7 +106,7 @@
106106
"json-minimizer-webpack-plugin": "^5.0.0",
107107
"lefthook": "^1.7.15",
108108
"mini-css-extract-plugin": "^2.9.1",
109-
"npm-run-all2": "^6.2.2",
109+
"npm-run-all2": "^6.2.3",
110110
"postcss": "^8.4.47",
111111
"postcss-scss": "^4.0.9",
112112
"prettier": "^2.8.8",

src/constants.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ const IpcChannels = {
2525
DB_HISTORY: 'db-history',
2626
DB_PROFILES: 'db-profiles',
2727
DB_PLAYLISTS: 'db-playlists',
28+
DB_SUBSCRIPTION_CACHE: 'db-subscription-cache',
2829

2930
SYNC_SETTINGS: 'sync-settings',
3031
SYNC_HISTORY: 'sync-history',
3132
SYNC_PROFILES: 'sync-profiles',
3233
SYNC_PLAYLISTS: 'sync-playlists',
34+
SYNC_SUBSCRIPTION_CACHE: 'sync-subscription-cache',
3335

3436
GET_REPLACE_HTTP_CACHE: 'get-replace-http-cache',
3537
TOGGLE_REPLACE_HTTP_CACHE: 'toggle-replace-http-cache',
@@ -67,7 +69,15 @@ const DBActions = {
6769
DELETE_VIDEO_ID: 'db-action-playlists-delete-video-by-playlist-name',
6870
DELETE_VIDEO_IDS: 'db-action-playlists-delete-video-ids',
6971
DELETE_ALL_VIDEOS: 'db-action-playlists-delete-all-videos',
70-
}
72+
},
73+
74+
SUBSCRIPTION_CACHE: {
75+
UPDATE_VIDEOS_BY_CHANNEL: 'db-action-subscriptions-update-videos-by-channel',
76+
UPDATE_LIVE_STREAMS_BY_CHANNEL: 'db-action-subscriptions-update-live-streams-by-channel',
77+
UPDATE_SHORTS_BY_CHANNEL: 'db-action-subscriptions-update-shorts-by-channel',
78+
UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL: 'db-action-subscriptions-update-shorts-with-channel-page-shorts-by-channel',
79+
UPDATE_COMMUNITY_POSTS_BY_CHANNEL: 'db-action-subscriptions-update-community-posts-by-channel',
80+
},
7181
}
7282

7383
const SyncEvents = {
@@ -92,7 +102,15 @@ const SyncEvents = {
92102
PLAYLISTS: {
93103
UPSERT_VIDEO: 'sync-playlists-upsert-video',
94104
DELETE_VIDEO: 'sync-playlists-delete-video',
95-
}
105+
},
106+
107+
SUBSCRIPTION_CACHE: {
108+
UPDATE_VIDEOS_BY_CHANNEL: 'sync-subscriptions-update-videos-by-channel',
109+
UPDATE_LIVE_STREAMS_BY_CHANNEL: 'sync-subscriptions-update-live-streams-by-channel',
110+
UPDATE_SHORTS_BY_CHANNEL: 'sync-subscriptions-update-shorts-by-channel',
111+
UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL: 'sync-subscriptions-update-shorts-with-channel-page-shorts-by-channel',
112+
UPDATE_COMMUNITY_POSTS_BY_CHANNEL: 'sync-subscriptions-update-community-posts-by-channel',
113+
},
96114
}
97115

98116
// Utils

src/datastores/handlers/base.js

+81
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,92 @@ class Playlists {
203203
}
204204
}
205205

206+
class SubscriptionCache {
207+
static find() {
208+
return db.subscriptionCache.findAsync({})
209+
}
210+
211+
static updateVideosByChannelId({ channelId, entries, timestamp }) {
212+
return db.subscriptionCache.updateAsync(
213+
{ _id: channelId },
214+
{ $set: { videos: entries, videosTimestamp: timestamp } },
215+
{ upsert: true }
216+
)
217+
}
218+
219+
static updateLiveStreamsByChannelId({ channelId, entries, timestamp }) {
220+
return db.subscriptionCache.updateAsync(
221+
{ _id: channelId },
222+
{ $set: { liveStreams: entries, liveStreamsTimestamp: timestamp } },
223+
{ upsert: true }
224+
)
225+
}
226+
227+
static updateShortsByChannelId({ channelId, entries, timestamp }) {
228+
return db.subscriptionCache.updateAsync(
229+
{ _id: channelId },
230+
{ $set: { shorts: entries, shortsTimestamp: timestamp } },
231+
{ upsert: true }
232+
)
233+
}
234+
235+
static updateShortsWithChannelPageShortsByChannelId({ channelId, entries }) {
236+
return db.subscriptionCache.findOneAsync({ _id: channelId }, { shorts: 1 }).then((doc) => {
237+
if (doc == null) { return }
238+
239+
const shorts = doc.shorts
240+
const cacheShorts = Array.isArray(shorts) ? shorts : []
241+
242+
cacheShorts.forEach(cachedVideo => {
243+
const channelVideo = entries.find(short => cachedVideo.videoId === short.videoId)
244+
if (!channelVideo) { return }
245+
246+
// authorId probably never changes, so we don't need to update that
247+
cachedVideo.title = channelVideo.title
248+
cachedVideo.author = channelVideo.author
249+
250+
// as the channel shorts page only has compact view counts for numbers above 1000 e.g. 12k
251+
// and the RSS feeds include an exact value, we only want to overwrite it when the number is larger than the cached value
252+
// 12345 vs 12000 => 12345
253+
// 12345 vs 15000 => 15000
254+
255+
if (channelVideo.viewCount > cachedVideo.viewCount) {
256+
cachedVideo.viewCount = channelVideo.viewCount
257+
}
258+
})
259+
260+
return db.subscriptionCache.updateAsync(
261+
{ _id: channelId },
262+
{ $set: { shorts: cacheShorts } },
263+
{ upsert: true }
264+
)
265+
})
266+
}
267+
268+
static updateCommunityPostsByChannelId({ channelId, entries, timestamp }) {
269+
return db.subscriptionCache.updateAsync(
270+
{ _id: channelId },
271+
{ $set: { communityPosts: entries, communityPostsTimestamp: timestamp } },
272+
{ upsert: true }
273+
)
274+
}
275+
276+
static deleteMultipleChannels(channelIds) {
277+
return db.subscriptionCache.removeAsync({ _id: { $in: channelIds } }, { multi: true })
278+
}
279+
280+
static deleteAll() {
281+
return db.subscriptionCache.removeAsync({}, { multi: true })
282+
}
283+
}
284+
206285
function compactAllDatastores() {
207286
return Promise.allSettled([
208287
db.settings.compactDatafileAsync(),
209288
db.history.compactDatafileAsync(),
210289
db.profiles.compactDatafileAsync(),
211290
db.playlists.compactDatafileAsync(),
291+
db.subscriptionCache.compactDatafileAsync(),
212292
])
213293
}
214294

@@ -217,6 +297,7 @@ export {
217297
History as history,
218298
Profiles as profiles,
219299
Playlists as playlists,
300+
SubscriptionCache as subscriptionCache,
220301

221302
compactAllDatastores,
222303
}

src/datastores/handlers/electron.js

+75-1
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,83 @@ class Playlists {
218218
}
219219
}
220220

221+
class SubscriptionCache {
222+
static find() {
223+
return ipcRenderer.invoke(
224+
IpcChannels.DB_SUBSCRIPTION_CACHE,
225+
{ action: DBActions.GENERAL.FIND }
226+
)
227+
}
228+
229+
static updateVideosByChannelId({ channelId, entries, timestamp }) {
230+
return ipcRenderer.invoke(
231+
IpcChannels.DB_SUBSCRIPTION_CACHE,
232+
{
233+
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_VIDEOS_BY_CHANNEL,
234+
data: { channelId, entries, timestamp },
235+
}
236+
)
237+
}
238+
239+
static updateLiveStreamsByChannelId({ channelId, entries, timestamp }) {
240+
return ipcRenderer.invoke(
241+
IpcChannels.DB_SUBSCRIPTION_CACHE,
242+
{
243+
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_LIVE_STREAMS_BY_CHANNEL,
244+
data: { channelId, entries, timestamp },
245+
}
246+
)
247+
}
248+
249+
static updateShortsByChannelId({ channelId, entries, timestamp }) {
250+
return ipcRenderer.invoke(
251+
IpcChannels.DB_SUBSCRIPTION_CACHE,
252+
{
253+
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_SHORTS_BY_CHANNEL,
254+
data: { channelId, entries, timestamp },
255+
}
256+
)
257+
}
258+
259+
static updateShortsWithChannelPageShortsByChannelId({ channelId, entries }) {
260+
return ipcRenderer.invoke(
261+
IpcChannels.DB_SUBSCRIPTION_CACHE,
262+
{
263+
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL,
264+
data: { channelId, entries },
265+
}
266+
)
267+
}
268+
269+
static updateCommunityPostsByChannelId({ channelId, entries, timestamp }) {
270+
return ipcRenderer.invoke(
271+
IpcChannels.DB_SUBSCRIPTION_CACHE,
272+
{
273+
action: DBActions.SUBSCRIPTION_CACHE.UPDATE_COMMUNITY_POSTS_BY_CHANNEL,
274+
data: { channelId, entries, timestamp },
275+
}
276+
)
277+
}
278+
279+
static deleteMultipleChannels(channelIds) {
280+
return ipcRenderer.invoke(
281+
IpcChannels.DB_SUBSCRIPTION_CACHE,
282+
{ action: DBActions.GENERAL.DELETE_MULTIPLE, data: channelIds }
283+
)
284+
}
285+
286+
static deleteAll() {
287+
return ipcRenderer.invoke(
288+
IpcChannels.DB_SUBSCRIPTION_CACHE,
289+
{ action: DBActions.GENERAL.DELETE_ALL }
290+
)
291+
}
292+
}
293+
221294
export {
222295
Settings as settings,
223296
History as history,
224297
Profiles as profiles,
225-
Playlists as playlists
298+
Playlists as playlists,
299+
SubscriptionCache as subscriptionCache,
226300
}

src/datastores/handlers/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export {
22
settings as DBSettingHandlers,
33
history as DBHistoryHandlers,
44
profiles as DBProfileHandlers,
5-
playlists as DBPlaylistHandlers
5+
playlists as DBPlaylistHandlers,
6+
subscriptionCache as DBSubscriptionCacheHandlers,
67
} from 'DB_HANDLERS_ELECTRON_RENDERER_OR_WEB'

src/datastores/handlers/web.js

+55-1
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,63 @@ class Playlists {
122122
}
123123
}
124124

125+
class SubscriptionCache {
126+
static find() {
127+
return baseHandlers.subscriptionCache.find()
128+
}
129+
130+
static updateVideosByChannelId({ channelId, entries, timestamp }) {
131+
return baseHandlers.subscriptionCache.updateVideosByChannelId({
132+
channelId,
133+
entries,
134+
timestamp,
135+
})
136+
}
137+
138+
static updateLiveStreamsByChannelId({ channelId, entries, timestamp }) {
139+
return baseHandlers.subscriptionCache.updateLiveStreamsByChannelId({
140+
channelId,
141+
entries,
142+
timestamp,
143+
})
144+
}
145+
146+
static updateShortsByChannelId({ channelId, entries, timestamp }) {
147+
return baseHandlers.subscriptionCache.updateShortsByChannelId({
148+
channelId,
149+
entries,
150+
timestamp,
151+
})
152+
}
153+
154+
static updateShortsWithChannelPageShortsByChannelId({ channelId, entries }) {
155+
return baseHandlers.subscriptionCache.updateShortsWithChannelPageShortsByChannelId({
156+
channelId,
157+
entries,
158+
})
159+
}
160+
161+
static updateCommunityPostsByChannelId({ channelId, entries, timestamp }) {
162+
return baseHandlers.subscriptionCache.updateCommunityPostsByChannelId({
163+
channelId,
164+
entries,
165+
timestamp,
166+
})
167+
}
168+
169+
static deleteMultipleChannels(channelIds) {
170+
return baseHandlers.subscriptionCache.deleteMultipleChannels(channelIds)
171+
}
172+
173+
static deleteAll() {
174+
return baseHandlers.subscriptionCache.deleteAll()
175+
}
176+
}
177+
125178
export {
126179
Settings as settings,
127180
History as history,
128181
Profiles as profiles,
129-
Playlists as playlists
182+
Playlists as playlists,
183+
SubscriptionCache as subscriptionCache,
130184
}

src/datastores/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ export const settings = new Datastore({ filename: dbPath('settings'), autoload:
2626
export const profiles = new Datastore({ filename: dbPath('profiles'), autoload: true })
2727
export const playlists = new Datastore({ filename: dbPath('playlists'), autoload: true })
2828
export const history = new Datastore({ filename: dbPath('history'), autoload: true })
29+
export const subscriptionCache = new Datastore({ filename: dbPath('subscription-cache'), autoload: true })

0 commit comments

Comments
 (0)