forked from TeamPiped/Piped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request TeamPiped#3346 from Bnyro/subscribe-channel-on-fly
feat: support for subscribing to channels in search results
- Loading branch information
Showing
4 changed files
with
96 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,72 @@ | ||
<template> | ||
<div class="flex flex-col flex-justify-between"> | ||
<router-link :to="props.item.url"> | ||
<router-link :to="item.url"> | ||
<div class="my-4 flex justify-center"> | ||
<img loading="lazy" class="aspect-square w-[50%] rounded-full" :src="props.item.thumbnail" /> | ||
<img loading="lazy" class="aspect-square w-[50%] rounded-full" :src="item.thumbnail" /> | ||
</div> | ||
<p> | ||
<span v-text="props.item.name" /> | ||
<font-awesome-icon v-if="props.item.verified" class="ml-1.5" icon="check" /> | ||
<span v-text="item.name" /> | ||
<font-awesome-icon v-if="item.verified" class="ml-1.5" icon="check" /> | ||
</p> | ||
</router-link> | ||
<p v-if="props.item.description" v-text="props.item.description" /> | ||
<router-link v-if="props.item.uploaderUrl" class="link" :to="props.item.uploaderUrl"> | ||
<p v-if="item.description" v-text="item.description" /> | ||
<router-link v-if="item.uploaderUrl" class="link" :to="item.uploaderUrl"> | ||
<p> | ||
<span v-text="props.item.uploader" /> | ||
<font-awesome-icon v-if="props.item.uploaderVerified" class="ml-1.5" icon="check" /> | ||
<span v-text="item.uploader" /> | ||
<font-awesome-icon v-if="item.uploaderVerified" class="ml-1.5" icon="check" /> | ||
</p> | ||
</router-link> | ||
|
||
<a v-if="props.item.uploaderName" class="link" v-text="props.item.uploaderName" /> | ||
<template v-if="props.item.videos >= 0"> | ||
<br v-if="props.item.uploaderName" /> | ||
<strong v-text="`${props.item.videos} ${$t('video.videos')}`" /> | ||
<a v-if="item.uploaderName" class="link" v-text="item.uploaderName" /> | ||
<template v-if="item.videos >= 0"> | ||
<br v-if="item.uploaderName" /> | ||
<strong v-text="`${item.videos} ${$t('video.videos')}`" /> | ||
</template> | ||
|
||
<button | ||
v-if="subscribed != null" | ||
class="btn w-max mt-2" | ||
Check warning on line 28 in src/components/ChannelItem.vue GitHub Actions / build
Check warning on line 28 in src/components/ChannelItem.vue GitHub Actions / build
Check warning on line 28 in src/components/ChannelItem.vue GitHub Actions / build-docker-image
|
||
@click="subscribeHandler" | ||
v-text=" | ||
$t('actions.' + (subscribed ? 'unsubscribe' : 'subscribe')) + ' - ' + numberFormat(item.subscribers) | ||
" | ||
/> | ||
|
||
<br /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const props = defineProps({ | ||
item: { | ||
type: Object, | ||
required: true, | ||
<script> | ||
export default { | ||
props: { | ||
item: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
subscribed: null, | ||
}; | ||
}, | ||
computed: { | ||
channelId(_this) { | ||
return _this.item.url.substr(-24); | ||
}, | ||
}, | ||
mounted() { | ||
this.updateSubscribedStatus(); | ||
}, | ||
methods: { | ||
async updateSubscribedStatus() { | ||
this.subscribed = await this.fetchSubscriptionStatus(this.channelId); | ||
console.log(this.subscribed); | ||
}, | ||
subscribeHandler() { | ||
this.toggleSubscriptionState(this.channelId, this.subscribed).then(success => { | ||
if (success) this.subscribed = !this.subscribed; | ||
}); | ||
}, | ||
}, | ||
}); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters