Skip to content

Commit 3d66e47

Browse files
committed
Merge branch 'development' into sabr-pr
* development: Change clear filter button from text to icon (FreeTubeApp#8205) Feat clickable playlist progress bar (FreeTubeApp#7782) Add Hide channels based on text (FreeTubeApp#7948) Clean up defunct shaka-player types patching (FreeTubeApp#8224)
2 parents e71d486 + 2bdce9b commit 3d66e47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+486
-246
lines changed

_scripts/patchShaka.mjs

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,12 @@
1-
// This script fixes shaka not exporting its type definitions and referencing the Roboto font on google fonts in its CSS
2-
// by adding an export line to the type definitions and updating the CSS to point to the local Roboto font
1+
// This script fixes shaka-player referencing the Roboto font on google fonts in its CSS
2+
// by updating the CSS to point to the local Roboto font
33
// this script only makes changes if they are needed, so running it multiple times doesn't cause any problems
44

5-
import { appendFileSync, closeSync, ftruncateSync, openSync, readFileSync, writeSync } from 'fs'
5+
import { closeSync, ftruncateSync, openSync, readFileSync, writeSync } from 'fs'
66
import { resolve } from 'path'
77

88
const SHAKA_DIST_DIR = resolve(import.meta.dirname, '../node_modules/shaka-player/dist')
99

10-
function fixTypes() {
11-
let fixedTypes = false
12-
13-
let fileHandleNormal
14-
try {
15-
fileHandleNormal = openSync(`${SHAKA_DIST_DIR}/shaka-player.ui.d.ts`, 'a+')
16-
17-
const contents = readFileSync(fileHandleNormal, 'utf-8')
18-
19-
// This script is run after every `yarn install`, even if shaka-player wasn't updated
20-
// So we want to check first, if we actually need to make any changes
21-
// or if the ones from the previous run are still intact
22-
if (!contents.includes('export default shaka')) {
23-
appendFileSync(fileHandleNormal, 'export default shaka;\n')
24-
25-
fixedTypes = true
26-
}
27-
} finally {
28-
if (typeof fileHandleNormal !== 'undefined') {
29-
closeSync(fileHandleNormal)
30-
}
31-
}
32-
33-
let fileHandleDebug
34-
try {
35-
fileHandleDebug = openSync(`${SHAKA_DIST_DIR}/shaka-player.ui.debug.d.ts`, 'a+')
36-
37-
const contents = readFileSync(fileHandleDebug, 'utf-8')
38-
39-
// This script is run after every `yarn install`, even if shaka-player wasn't updated
40-
// So we want to check first, if we actually need to make any changes
41-
// or if the ones from the previous run are still intact
42-
if (!contents.includes('export default shaka')) {
43-
appendFileSync(fileHandleDebug, 'export default shaka;\n')
44-
45-
fixedTypes = true
46-
}
47-
} finally {
48-
if (typeof fileHandleDebug !== 'undefined') {
49-
closeSync(fileHandleDebug)
50-
}
51-
}
52-
53-
if (fixedTypes) {
54-
console.log('Fixed shaka-player types')
55-
}
56-
}
57-
5810
function removeRobotoFont() {
5911
let cssFileHandle
6012
try {
@@ -72,11 +24,10 @@ function removeRobotoFont() {
7224
console.log('Removed shaka-player Roboto font, so it uses ours')
7325
}
7426
} finally {
75-
if (typeof cssFileHandle !== 'undefined') {
27+
if (cssFileHandle !== undefined) {
7628
closeSync(cssFileHandle)
7729
}
7830
}
7931
}
8032

81-
fixTypes()
8233
removeRobotoFont()

src/renderer/components/DistractionSettings/DistractionSettings.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@
7878
</FtFlexBox>
7979
<FtFlexBox class="containingTextFlexBox">
8080
<FtInputTags
81-
:label="t('Settings.Distraction Free Settings.Hide Videos and Playlists Containing Text')"
82-
:tag-name-placeholder="t('Settings.Distraction Free Settings.Hide Videos and Playlists Containing Text Placeholder')"
81+
:label="t('Settings.Distraction Free Settings.Hide Videos, Playlists and Channels Containing Text')"
82+
:tag-name-placeholder="t('Settings.Distraction Free Settings.Hide Videos, Playlists and Channels Containing Text Placeholder')"
8383
:show-tags="showAddedForbiddenTitles"
8484
:tag-list="forbiddenTitles"
8585
:min-input-length="1"
86-
:tooltip="t('Tooltips.Distraction Free Settings.Hide Videos and Playlists Containing Text')"
86+
:tooltip="t('Tooltips.Distraction Free Settings.Hide Videos, Playlists and Channels Containing Text')"
8787
@change="handleForbiddenTitles"
8888
@toggle-show-tags="handleAddedForbiddenTitles"
8989
/>

src/renderer/components/FtListLazyWrapper/FtListLazyWrapper.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const channelsHidden = computed(() => {
172172
/** @type {string[]} */
173173
const forbiddenTitles = computed(() => {
174174
if (!props.hideForbiddenTitles) { return [] }
175-
return JSON.parse(store.getters.getForbiddenTitles)
175+
return JSON.parse(store.getters.getForbiddenTitles.toLowerCase())
176176
})
177177
178178
const showResult = computed(() => {
@@ -203,13 +203,16 @@ const showResult = computed(() => {
203203
return false
204204
}
205205
206-
if (channelsHidden.value.some(ch => ch.name === props.data.authorId) || channelsHidden.value.some(ch => ch.name === props.data.author)) {
206+
const lowerCaseAuthor = props.data.author?.toLowerCase()
207+
208+
if (channelsHidden.value.some(ch => ch.name === props.data.authorId) || channelsHidden.value.some(ch => ch.name === props.data.author) || (forbiddenTitles.value.some((text) => lowerCaseAuthor.includes(text)))) {
207209
// hide videos by author
208210
return false
209211
}
210212
211213
const lowerCaseTitle = props.data.title?.toLowerCase()
212-
if (forbiddenTitles.value.some((text) => lowerCaseTitle.includes(text.toLowerCase()))) {
214+
215+
if (forbiddenTitles.value.some((text) => lowerCaseTitle.includes(text))) {
213216
return false
214217
}
215218
} else if (dataType === 'channel') {
@@ -223,14 +226,19 @@ const showResult = computed(() => {
223226
props.data.authorId,
224227
]
225228
226-
if (attrsToCheck.some(a => a != null && channelsHidden.value.some(ch => ch.name === a))) {
229+
const lowerCaseName = props.data.name?.toLowerCase()
230+
231+
if ((attrsToCheck.some(a => a != null && channelsHidden.value.some(ch => ch.name === a))) ||
232+
(forbiddenTitles.value.some((text) => lowerCaseName.includes(text)))) {
227233
// hide channels by author
228234
return false
229235
}
230236
} else if (dataType === 'playlist') {
231237
const lowerCaseTitle = props.data.title?.toLowerCase()
238+
const lowerCaseChannelName = props.data.channelName?.toLowerCase()
232239
233-
if (forbiddenTitles.value.some((text) => lowerCaseTitle.includes(text.toLowerCase()))) {
240+
if ((forbiddenTitles.value.some((text) => lowerCaseTitle.includes(text))) ||
241+
(forbiddenTitles.value.some((text) => lowerCaseChannelName.includes(text)))) {
234242
return false
235243
}
236244

src/renderer/components/FtListVideoLazy.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,21 @@ const channelsHidden = computed(() => {
130130
131131
const forbiddenTitles = computed(() => {
132132
if (!props.hideForbiddenTitles) { return [] }
133-
return JSON.parse(store.getters.getForbiddenTitles)
133+
return JSON.parse(store.getters.getForbiddenTitles.toLowerCase())
134+
})
135+
136+
const hideChannelsBasedOnText = computed(() => {
137+
return store.getters.getHideChannelsBasedOnText
134138
})
135139
136140
const shouldBeVisible = computed(() => {
137141
const lowerCaseTitle = props.data.title?.toLowerCase()
142+
const lowerCaseAuthor = props.data.author?.toLowerCase()
138143
139144
return !(channelsHidden.value.some(ch => ch.name === props.data.authorId) ||
140145
channelsHidden.value.some(ch => ch.name === props.data.author) ||
141-
(lowerCaseTitle && forbiddenTitles.value.some((text) => lowerCaseTitle.includes(text.toLowerCase()))))
146+
(lowerCaseTitle && forbiddenTitles.value.some((text) => lowerCaseTitle.includes(text))) ||
147+
(hideChannelsBasedOnText.value && lowerCaseAuthor && forbiddenTitles.value.some((text) => lowerCaseAuthor.includes(text))))
142148
})
143149
144150
/**

src/renderer/components/FtSearchFilters/FtSearchFilters.css

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.center {
2-
margin-block: 5px 10px;
2+
margin-block-start: 10px;
33
text-align: center;
44
user-select: none;
55
}
@@ -18,6 +18,42 @@
1818
justify-content: center;
1919
}
2020

21+
.titleContainer {
22+
display: flex;
23+
align-items: baseline;
24+
justify-content: center;
25+
gap: 0.5rem;
26+
block-size: inherit;
27+
}
28+
29+
.clearFilterButton {
30+
border-radius: 50%;
31+
border-style: none;
32+
background-color: transparent;
33+
color: var(--primary-text-color);
34+
cursor: pointer;
35+
font-size: 20px;
36+
line-height: 1em;
37+
padding: 10px;
38+
transition: background 0.2s ease-out;
39+
40+
&:hover {
41+
background-color: var(--side-nav-hover-color);
42+
color: var(--side-nav-hover-text-color);
43+
transition: background 0.2s ease-in;
44+
}
45+
46+
&:active {
47+
background-color: var(--tertiary-text-color);
48+
color: var(--side-nav-active-text-color);
49+
transition: background 0.2s ease-in;
50+
}
51+
}
52+
53+
.clearFilterIcon {
54+
vertical-align: -0.25em;
55+
}
56+
2157
@media only screen and (width <= 680px) {
2258
.searchRadio {
2359
border-inline-end: 0;

src/renderer/components/FtSearchFilters/FtSearchFilters.vue

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,25 @@
44
@click="hideSearchFilters"
55
>
66
<template #label="{ labelId }">
7-
<h2
8-
:id="labelId"
9-
class="center"
10-
>
11-
{{ title }}
12-
</h2>
7+
<div class="titleContainer">
8+
<h2
9+
:id="labelId"
10+
class="center"
11+
>
12+
{{ title }}
13+
</h2>
14+
<button
15+
class="clearFilterButton"
16+
:title="$t('Search Filters.Clear Filters')"
17+
:style="{visibility: (searchFilterValueChanged ? 'visible' : 'hidden')}"
18+
@click="clearFilters"
19+
>
20+
<FontAwesomeIcon
21+
class="clearFilterIcon"
22+
:icon="['fas', 'filter-circle-xmark']"
23+
/>
24+
</button>
25+
</div>
1326
</template>
1427

1528
<FtFlexBox class="radioFlexBox">
@@ -50,12 +63,6 @@
5063
/>
5164
</FtFlexBox>
5265
<div class="searchFilterCloseButtonContainer">
53-
<FtButton
54-
:label="$t('Search Filters.Clear Filters')"
55-
background-color="var(--accent-color)"
56-
text-color="var(--text-with-accent-color)"
57-
@click="clearFilters"
58-
/>
5966
<FtButton
6067
:label="$t('Close')"
6168
background-color="null"

src/renderer/components/SubscriptionsPosts.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ function loadPostsFromCacheSometimes() {
155155
isLoading.value = false
156156
}
157157
158+
/** @type {import('vue').ComputedRef<string[]>} */
159+
const forbiddenTitles = computed(() => {
160+
return JSON.parse(store.getters.getForbiddenTitles.toLowerCase())
161+
})
162+
158163
function loadPostsFromCacheForAllActiveProfileChannels() {
159164
const postList_ = cacheEntriesForAllActiveProfileChannels.value.flatMap((cacheEntry) => {
160165
return cacheEntry.posts
@@ -164,7 +169,7 @@ function loadPostsFromCacheForAllActiveProfileChannels() {
164169
return b.publishedTime - a.publishedTime
165170
})
166171
167-
postList.value = postList_
172+
postList.value = postList_.filter(post => !forbiddenTitles.value.some(text => post.author.toLowerCase().includes(text)))
168173
isLoading.value = false
169174
}
170175
@@ -224,6 +229,7 @@ async function loadPostsForSubscriptionsFromRemote() {
224229
}
225230
}
226231
232+
posts = posts.filter(post => !forbiddenTitles.value.some(text => post.author.toLowerCase().includes(text)))
227233
return posts
228234
}))).flat()
229235

0 commit comments

Comments
 (0)