Skip to content

Commit

Permalink
Local API: Add support for home tab on channels (#6033)
Browse files Browse the repository at this point in the history
* Add support for home tab on channels

* Remove some unneeded code

* Add setting to hide channel home tab

* Switch to Composition API

* Add Play All link when possible, parse more types

* fix typo for home tab aria-controls

Co-Authored-By: absidue <48293849+absidue@users.noreply.github.com>

* move distraction free hide home setting

* Filter home data for setting featured channels

* fix publish date parsing

* Add support for shelf subtitle

* run lint-fix

* add jsdoc for added function

* implement code suggestions, fix lockupview

* add support for parsing subtitle and playlistId for richshelf

* exclude home tab for IV

* implement code suggestions, change `Play all` to `View playlist`

Co-Authored-By: PikachuEXE <1018543+PikachuEXE@users.noreply.github.com>

* remove lockupview case since #6196 will handle parsing it in this function

* use list icon instead of bookmark icon

Co-Authored-By: PikachuEXE <1018543+PikachuEXE@users.noreply.github.com>

* open all details by default

* add case 'ALBUM' for lockupView parsing

* change default page to home page when local api is enabled and home page isnt hidden when entering a channel url

---------

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
Co-authored-by: PikachuEXE <1018543+PikachuEXE@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent c2217d1 commit 719fcc0
Show file tree
Hide file tree
Showing 15 changed files with 458 additions and 122 deletions.
16 changes: 16 additions & 0 deletions src/renderer/components/ChannelDetails/ChannelDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@
role="tablist"
:aria-label="$t('Channel.Channel Tabs')"
>
<!-- eslint-disable-next-line vuejs-accessibility/interactive-supports-focus -->
<div
v-if="visibleTabs.includes('home')"
id="homeTab"
class="tab"
:class="{ selectedTab: currentTab === 'home' }"
role="tab"
:aria-selected="String(currentTab === 'home')"
aria-controls="homePanel"
:tabindex="(currentTab === 'home' || currentTab === 'search') ? 0 : -1"
@click="changeTab('home')"
@keydown.left.right="focusTab('home', $event)"
@keydown.enter.space.prevent="changeTab('home')"
>
{{ $t("Channel.Home.Home").toUpperCase() }}
</div>
<!-- eslint-disable-next-line vuejs-accessibility/interactive-supports-focus -->
<div
v-if="visibleTabs.includes('videos')"
Expand Down
35 changes: 35 additions & 0 deletions src/renderer/components/ChannelHome/ChannelHome.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.shelfTitle {
font-size: 24px;
cursor: pointer;
}

.shelfTitle::marker {
font-size: 20px;
color: var(--accent-color);
}

.shelfUnderline {
border-color: var(--primary-color);
}

.playAllSpan {
font-size: 18px;
margin-inline-start: 10px;
}

.playAllLink {
font-style: italic;
padding-block: 5px;
padding-inline: 7px;
border-radius: 10px;
text-decoration: none;
}

.playAllLink:hover {
background-color: var(--bg-color);
}

.shelfSubtitle {
font-style: italic;
color: var(--tertiary-text-color);
}
77 changes: 77 additions & 0 deletions src/renderer/components/ChannelHome/ChannelHome.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<template>
<div>
<div
v-for="(shelf, index) in filteredShelves"
:key="index"
>
<details
open
>
<summary
class="shelfTitle"
>
{{ shelf.title }}
<span
v-if="shelf.playlistId"
class="playAllSpan"
>
<router-link
class="playAllLink"
:to="{
path: `/playlist/${shelf.playlistId}`
}"
>
<FontAwesomeIcon
class="thumbnail"
:icon="['fas', 'list']"
/>
{{ $t('Channel.Home.View Playlist') }}
</router-link>
</span>
<hr class="shelfUnderline">
</summary>
<p
v-if="shelf.subtitle"
class="shelfSubtitle"
>
{{ shelf.subtitle }}
</p>
<FtElementList
:data="shelf.content"
:use-channels-hidden-preference="false"
:display="shelf.isCommunity ? 'list' : null"
/>
</details>
</div>
</div>
</template>

<script setup>
import { computed } from 'vue'
import FtElementList from '../FtElementList/FtElementList.vue'
import store from '../../store/index'
const props = defineProps({
shelves: {
type: Array,
default: () => []
}
})
/** @type {import('vue').ComputedRef<bool>} */
const hideFeaturedChannels = computed(() => {
return store.getters.getHideFeaturedChannels
})
const filteredShelves = computed(() => {
let shelves = props.shelves
if (hideFeaturedChannels.value) {
shelves = shelves.filter(shelf => shelf.content[0].type !== 'channel')
}
return shelves.filter(shelf => shelf.content.length > 0)
})
</script>

<style scoped src="./ChannelHome.css" />
4 changes: 3 additions & 1 deletion src/renderer/components/FtListChannel/FtListChannel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
>
<img
:src="thumbnail"
class="channelImage"
:class="!isGame ? 'channelImage' : 'gameImage'"
alt=""
>
</router-link>
Expand Down Expand Up @@ -116,6 +116,7 @@ let videoCount = null
/** @type {string?} */
let handle = null
let description = ''
let isGame = null
if (process.env.SUPPORTS_LOCAL_API && props.data.dataSource === 'local') {
parseLocalData()
Expand Down Expand Up @@ -157,6 +158,7 @@ function parseLocalData() {
}
description = props.data.descriptionShort
isGame = props.data.isGame
}
function parseInvidiousData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export default defineComponent({
hideChannelCommunity: function () {
return this.$store.getters.getHideChannelCommunity
},
hideChannelHome: function () {
return this.$store.getters.getHideChannelHome
},
hideSubscriptionsVideos: function () {
return this.$store.getters.getHideSubscriptionsVideos
},
Expand Down Expand Up @@ -218,6 +221,7 @@ export default defineComponent({
'updateHideChannelShorts',
'updateHideChannelPlaylists',
'updateHideChannelCommunity',
'updateHideChannelHome',
'updateHideChannelPodcasts',
'updateHideChannelReleases',
'updateHideSubscriptionsVideos',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
</h4>
<div class="switchColumnGrid">
<div class="switchColumn">
<ft-toggle-switch
:label="$t('Settings.Distraction Free Settings.Hide Channel Home')"
:compact="true"
:default-value="hideChannelHome"
@change="updateHideChannelHome"
/>
<ft-toggle-switch
:label="$t('Settings.Distraction Free Settings.Hide Channel Shorts')"
:compact="true"
Expand Down
Loading

0 comments on commit 719fcc0

Please sign in to comment.