Add optional parameters object to `getPeertubeVideoURL`

At first I just wanted to make the isEmbed optional (default `false`), but I
thought it would be more future-proof to wrap it in an object. Now when it's not
needed, it's not there, and when it is, it's clear what it does.
This commit is contained in:
Ealhad 2019-02-18 16:17:37 +01:00
parent 104598477e
commit bcec17a0a2
4 changed files with 5 additions and 5 deletions

View File

@ -47,7 +47,7 @@ const redirectYoutube = async (r) => {
const title = await getTitle(query);
const video = await searchByName(title);
const url = getPeertubeVideoURL(video, prefs, isEmbed);
const url = getPeertubeVideoURL(video, prefs, { isEmbed });
return {
redirectUrl: url
@ -77,7 +77,7 @@ const redirectPeertube = async (r) => {
return {}; // Don't redirect if original instance
}
const url = getPeertubeVideoURL(video, prefs, isEmbed);
const url = getPeertubeVideoURL(video, prefs, { isEmbed });
return {
redirectUrl: url

View File

@ -48,7 +48,7 @@ async function peertubeify() {
case RedirectType.Show: {
searchVideo()
.then(async video => {
const link = videoLink(getPeertubeVideoURL(video, prefs, false), video);
const link = videoLink(getPeertubeVideoURL(video, prefs), video);
removeVideoLink();
document.querySelector('body').appendChild(link);
}).catch(removeVideoLink);

View File

@ -4,7 +4,7 @@ export function htmlToElement(html: string): Element {
return template.content.firstElementChild;
}
export function getPeertubeVideoURL(video, prefs, isEmbed) {
export function getPeertubeVideoURL(video, prefs, { isEmbed = false } = {}) {
const endpoint = isEmbed ? 'embed' : 'watch';
return `https://${getPeertubeHost(video.account.host, prefs)}/videos/${endpoint}/${video.uuid}`;

View File

@ -39,7 +39,7 @@ async function peertubeify(query: String) {
case RedirectType.Show: {
searchVideo(query)
.then(async video => {
const url = getPeertubeVideoURL(video, prefs, false)
const url = getPeertubeVideoURL(video, prefs)
const link = videoLink(url, video);
removeVideoLink();