Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1414 share channels #2859

Merged
merged 5 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion src/renderer/components/ft-share-button/ft-share-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export default Vue.extend({
'ft-toggle-switch': FtToggleSwitch
},
props: {
shareTargetType: {
/**
* Allows to render the dropdown conditionally
* 'Channel' will exclude embed links
* 'Video' (default) keeps the original behaviour
**/
type: String,
default: 'Video'
},
id: {
type: String,
required: true
Expand All @@ -25,7 +34,7 @@ export default Vue.extend({
},
getTimestamp: {
type: Function,
required: true
default: null
}
},
data: function () {
Expand All @@ -34,11 +43,22 @@ export default Vue.extend({
}
},
computed: {
isChannel: function() {
return this.shareTargetType === 'Channel'
},

isVideo: function() {
return this.shareTargetType === 'Video'
},

currentInvidiousInstance: function () {
return this.$store.getters.getCurrentInvidiousInstance
},

invidiousURL() {
if (this.isChannel) {
return `${this.currentInvidiousInstance}/channel/${this.id}`
}
let videoUrl = `${this.currentInvidiousInstance}/watch?v=${this.id}`
// `playlistId` can be undefined
if (this.playlistId && this.playlistId.length !== 0) {
Expand All @@ -52,7 +72,14 @@ export default Vue.extend({
return `${this.currentInvidiousInstance}/embed/${this.id}`
},

youtubeChannelUrl() {
return `https://www.youtube.com/channel/${this.id}`
},

youtubeURL() {
if (this.isChannel) {
return this.youtubeChannelUrl
}
let videoUrl = `https://www.youtube.com/watch?v=${this.id}`
// `playlistId` can be undefined
if (this.playlistId && this.playlistId.length !== 0) {
Expand All @@ -63,6 +90,9 @@ export default Vue.extend({
},

youtubeShareURL() {
if (this.isChannel) {
return this.youtubeChannelUrl
}
// `playlistId` can be undefined
if (this.playlistId && this.playlistId.length !== 0) {
// `index` seems can be ignored
Expand All @@ -75,6 +105,12 @@ export default Vue.extend({
return `https://www.youtube-nocookie.com/embed/${this.id}`
}
},
mounted() {
// Prevents to instantiate a ft-share-button for a video without a get-timestamp function
if (this.isVideo && !this.getTimestamp) {
console.error('Error in props validation: A Video ft-share-button requires a valid get-timestamp function.')
}
},
methods: {

openInvidious() {
Expand Down Expand Up @@ -122,6 +158,9 @@ export default Vue.extend({
},

getFinalUrl(url) {
if (this.isChannel) {
return url
}
if (url.indexOf('?') === -1) {
return this.includeTimestamp ? `${url}?t=${this.getTimestamp()}` : url
}
Expand Down
9 changes: 7 additions & 2 deletions src/renderer/components/ft-share-button/ft-share-button.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<template>
<ft-icon-button
ref="iconButton"
:title="$t('Share.Share Video')"
theme="secondary"
:title="$t(`Share.Share ${shareTargetType}`)"
:theme="isVideo?'secondary':'base-no-default'"
:icon="['fas', 'share-alt']"
dropdown-position-x="left"
:force-dropdown="true"
>
<ft-flex-box>
<ft-toggle-switch
v-if="isVideo"
:label="$t('Share.Include Timestamp')"
:compact="true"
:default-value="includeTimestamp"
Expand Down Expand Up @@ -42,6 +43,7 @@
{{ $t("Share.Open Link") }}
</ft-button>
<ft-button
v-if="isVideo"
class="action"
background-color="var(--accent-color-active)"
@click="copyYoutubeEmbed()"
Expand All @@ -50,6 +52,7 @@
{{ $t("Share.Copy Embed") }}
</ft-button>
<ft-button
v-if="isVideo"
class="action"
background-color="var(--accent-color-active)"
@click="openYoutubeEmbed()"
Expand Down Expand Up @@ -81,6 +84,7 @@
{{ $t("Share.Open Link") }}
</ft-button>
<ft-button
v-if="isVideo"
class="action"
background-color="var(--accent-color-active)"
@click="copyInvidiousEmbed()"
Expand All @@ -89,6 +93,7 @@
{{ $t("Share.Copy Embed") }}
</ft-button>
<ft-button
v-if="isVideo"
class="action"
background-color="var(--accent-color-active)"
@click="openInvidiousEmbed()"
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/views/Channel/Channel.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@
left: 120px;
}

.channelInfoActionsContainer {
display: flex;
min-width: 230px;
justify-content: space-between;
}

.subscribeButton {
height: 50px;
min-width: 150px;
align-self: center;
margin-bottom: 10px;
}

.shareIcon {
align-items: center;
}

.channelSearch {
width: 200px;
align-self: flex-end;
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import FtChannelBubble from '../../components/ft-channel-bubble/ft-channel-bubbl
import FtLoader from '../../components/ft-loader/ft-loader.vue'
import FtElementList from '../../components/ft-element-list/ft-element-list.vue'
import FtAgeRestricted from '../../components/ft-age-restricted/ft-age-restricted.vue'
import FtShareButton from '../../components/ft-share-button/ft-share-button.vue'

import ytch from 'yt-channel-info'
import autolinker from 'autolinker'
Expand All @@ -27,7 +28,8 @@ export default Vue.extend({
'ft-channel-bubble': FtChannelBubble,
'ft-loader': FtLoader,
'ft-element-list': FtElementList,
'ft-age-restricted': FtAgeRestricted
'ft-age-restricted': FtAgeRestricted,
'ft-share-button': FtShareButton
},
data: function () {
return {
Expand Down
24 changes: 16 additions & 8 deletions src/renderer/views/Channel/Channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,22 @@
</div>
</div>

<ft-button
v-if="!hideUnsubscribeButton"
:label="subscribedText"
background-color="var(--primary-color)"
text-color="var(--text-with-main-color)"
class="subscribeButton"
@click="handleSubscription"
/>
<div class="channelInfoActionsContainer">
<ft-share-button
:id="id"
share-target-type="Channel"
class="shareIcon"
/>

<ft-button
v-if="!hideUnsubscribeButton"
:label="subscribedText"
background-color="var(--primary-color)"
text-color="var(--text-with-main-color)"
class="subscribeButton"
@click="handleSubscription"
/>
</div>
</div>

<ft-flex-box
Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ Change Format:
for this video
Share:
Share Video: Share Video
Share Channel: Share Channel
Include Timestamp: Include Timestamp
Copy Link: Copy Link
Open Link: Open Link
Expand Down
1 change: 1 addition & 0 deletions static/locales/en_GB.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ Change Format:
for this video'
Share:
Share Video: 'Share Video'
Share Channel: 'Share Channel'
Include Timestamp: 'Include Timestamp'
Copy Link: 'Copy Link'
Open Link: 'Open Link'
Expand Down