Skip to content

Commit 57aa854

Browse files
authored
Fix player button hiding (FreeTubeApp#8065)
1 parent 57c6d1f commit 57aa854

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
showToast,
2626
writeFileWithPicker,
2727
throttle,
28+
removeFromArrayIfExists,
2829
} from '../../helpers/utils'
2930

3031
/** @typedef {import('../../helpers/sponsorblock').SponsorBlockCategory} SponsorBlockCategory */
@@ -851,39 +852,28 @@ export default defineComponent({
851852
}
852853

853854
if (!enableScreenshot.value || props.format === 'audio') {
854-
const index = elementList.indexOf('ft_screenshot')
855-
elementList.splice(index, 1)
855+
removeFromArrayIfExists(elementList, 'ft_screenshot')
856856
}
857857

858858
if (!props.theatrePossible) {
859-
const index = elementList.indexOf('ft_theatre_mode')
860-
// doesn't exist in overflow menu, as theatre mode only works on wide screens
861-
if (index !== -1) {
862-
elementList.splice(index, 1)
863-
}
859+
removeFromArrayIfExists(uiConfig.controlPanelElements, 'ft_theatre_mode')
864860
}
865861

866862
if (!props.autoplayPossible) {
867-
const index = elementList.indexOf('ft_autoplay_toggle')
868-
elementList.splice(index, 1)
863+
removeFromArrayIfExists(elementList, 'ft_autoplay_toggle')
869864
}
870865

871866
if (props.format === 'audio') {
872-
const index = elementList.indexOf('picture_in_picture')
873-
elementList.splice(index, 1)
867+
removeFromArrayIfExists(elementList, 'picture_in_picture')
874868
}
875869

876870
if (isLive.value) {
877-
const index = elementList.indexOf('loop')
878-
elementList.splice(index, 1)
871+
removeFromArrayIfExists(uiConfig.overflowMenuButtons, 'loop')
879872
}
880873

881874
if (!useVrMode.value) {
882-
const indexRecenterVr = uiConfig.overflowMenuButtons.indexOf('recenter_vr')
883-
uiConfig.overflowMenuButtons.splice(indexRecenterVr, 1)
884-
885-
const indexToggleStereoscopic = uiConfig.overflowMenuButtons.indexOf('toggle_stereoscopic')
886-
uiConfig.overflowMenuButtons.splice(indexToggleStereoscopic, 1)
875+
removeFromArrayIfExists(uiConfig.overflowMenuButtons, 'recenter_vr')
876+
removeFromArrayIfExists(uiConfig.overflowMenuButtons, 'toggle_stereoscopic')
887877
}
888878

889879
return uiConfig

src/renderer/helpers/utils.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,19 @@ export function randomArrayItem(array) {
831831
return array[Math.floor(Math.random() * array.length)]
832832
}
833833

834+
/**
835+
* @template T
836+
* @param {T[]} array
837+
* @param {T} entry
838+
*/
839+
export function removeFromArrayIfExists(array, entry) {
840+
const index = array.indexOf(entry)
841+
842+
if (index !== -1) {
843+
array.splice(index, 1)
844+
}
845+
}
846+
834847
/**
835848
* @param {string} text
836849
*/

src/renderer/views/Channel/Channel.vue

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ import {
290290
extractNumberFromString,
291291
showToast,
292292
getChannelPlaylistId,
293-
getIconForSortPreference
293+
getIconForSortPreference,
294+
removeFromArrayIfExists
294295
} from '../../helpers/utils'
295296
import { isNullOrEmpty } from '../../helpers/strings'
296297
import {
@@ -472,19 +473,6 @@ const hideChannelCommunity = computed(() => store.getters.getHideChannelCommunit
472473
/** @type {import('vue').ComputedRef<boolean>} */
473474
const hideWatchedSubs = computed(() => store.getters.getHideWatchedSubs)
474475
475-
/**
476-
* @template T
477-
* @param {T[]} array
478-
* @param {T} entry
479-
*/
480-
function removeFromArrayIfExists(array, entry) {
481-
const index = array.indexOf(entry)
482-
483-
if (index !== -1) {
484-
array.splice(index, 1)
485-
}
486-
}
487-
488476
const tabInfoValues = computed(() => {
489477
const values = [...channelTabs.value]
490478

0 commit comments

Comments
 (0)