Skip to content

Commit

Permalink
[Issue ViewTube#2487] Remove unused import and require the videoId pr…
Browse files Browse the repository at this point in the history
…op. Fix formatting
  • Loading branch information
chonsser committed Jan 31, 2024
1 parent 3d2e3f7 commit 9ca716d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions client/components/watch/ShareOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<ShareOptionEntry class="share-option" option-name="Copy YouTube Link" :click="shareCopyYouTubeLink">
<VTIcon name="mdi:youtube" class="copy-icon" />
</ShareOptionEntry>
<ShareOptionEntry class="share-option" option-name="Copy ViewTube Link at Current Timestamp" :click="shareCopyLinkAtCurrentTimestamp">
<ShareOptionEntry class="share-option" option-name="Copy ViewTube Link at Current Timestamp"
:click="shareCopyLinkAtCurrentTimestamp">
<VTIcon name="mdi:clipboard-text-time-outline" class="copy-icon" />
</ShareOptionEntry>
<ShareOptionEntry class="share-option" option-name="Open QR-Code" :click="qrOpen">
Expand All @@ -34,7 +35,6 @@
import QrPopUp from '@/components/popup/QrPopUp.vue';
import ShareOptionEntry from '@/components/list/ShareOptionEntry.vue';
import { useVideoPlayerStore } from '@/store/videoPlayer';
import type { Result } from 'ytpl';
export default defineComponent({
name: 'ShareOptions',
Expand All @@ -43,7 +43,10 @@ export default defineComponent({
QrPopUp
},
props: {
videoId: String
videoId: {
type: String,
required: true
}
},
setup(props) {
const qrPopUpOpen = ref(false);
Expand All @@ -54,24 +57,24 @@ export default defineComponent({
};
// shareReddit() {},
const shareCopyViewTubeLink = () => {
writeToClipboard(url())
writeToClipboard(url());
};
const shareCopyYouTubeLink = () => {
const url = `https://youtu.be/${props.videoId}`
writeToClipboard(url)
const url = `https://youtu.be/${props.videoId}`;
writeToClipboard(url);
};
const writeToClipboard = (text: string) => {
if(!navigator.clipboard) {
alert('Unable to copy (running ViewTube on non-https website).')
if (!navigator.clipboard) {
alert('Unable to copy (running ViewTube on non-https website).');
return;
}
navigator.clipboard.writeText(text);
}
};
const shareCopyLinkAtCurrentTimestamp = () => {
const currentHref = new URL(url())
currentHref.searchParams.set('t', Math.round(videoPlayerStore.currentTime).toString())
writeToClipboard(currentHref.href)
}
const currentHref = new URL(url());
currentHref.searchParams.set('t', Math.round(videoPlayerStore.currentTime).toString());
writeToClipboard(currentHref.href);
};
const saveToPocket = () => {
window.open(`https://getpocket.com/save?url=${encodedUrl}`, '_blank');
};
Expand Down Expand Up @@ -108,6 +111,7 @@ export default defineComponent({
<style lang="scss">
.share-options {
height: 60px;
.share-options-container {
display: flex;
flex-direction: row;
Expand Down

0 comments on commit 9ca716d

Please sign in to comment.