fix: Fix if vote is undefined
This commit is contained in:
1 parent
ff3246c0a6
commit
5f4c32fe2c
4 files changed
+25
-7
No files matched your search
@@ -35,6 +35,19 @@
|
|||||||
post_id: postRes.post.id,
|
post_id: postRes.post.id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function youtubeToPiped(url: string): string {
|
||||||
|
const youtubeDomainsRegex =
|
||||||
|
/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\//i
|
||||||
|
|
||||||
|
if (youtubeDomainsRegex.test(url)) {
|
||||||
|
return url
|
||||||
|
.replace(youtubeDomainsRegex, '$1$2invidious.io.lol/')
|
||||||
|
.replace('www.', '')
|
||||||
|
}
|
||||||
|
|
||||||
|
return url
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card class="bg-white flex flex-col overflow-hidden w-full relative p-5 gap-2">
|
<Card class="bg-white flex flex-col overflow-hidden w-full relative p-5 gap-2">
|
||||||
@@ -87,14 +100,18 @@
|
|||||||
src="{postRes.post.url}?thumbnail=1024&format=webp"
|
src="{postRes.post.url}?thumbnail=1024&format=webp"
|
||||||
alt={postRes.post.name}
|
alt={postRes.post.name}
|
||||||
class="rounded-md max-h-[32rem] w-full max-w-full"
|
class="rounded-md max-h-[32rem] w-full max-w-full"
|
||||||
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{:else if postRes.post.embed_video_url}
|
{:else if postRes.post.embed_video_url}
|
||||||
<div class="self-start" class:blur-3xl={postRes.post.nsfw}>
|
<div class="self-start" class:blur-3xl={postRes.post.nsfw}>
|
||||||
<!-- svelte-ignore a11y-media-has-caption -->
|
<!-- svelte-ignore a11y-media-has-caption -->
|
||||||
<video class="rounded-md max-h-[32rem] w-full max-w-full" controls>
|
{#if postRes.post.embed_video_url}
|
||||||
<source src={postRes.post.embed_video_url} />
|
<embed
|
||||||
</video>
|
class="rounded-md max-h-[32rem] w-full max-w-full"
|
||||||
|
src={youtubeToPiped(postRes.post.embed_video_url)}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else if postRes.post.thumbnail_url}
|
{:else if postRes.post.thumbnail_url}
|
||||||
<div class="self-start" class:blur-3xl={postRes.post.nsfw}>
|
<div class="self-start" class:blur-3xl={postRes.post.nsfw}>
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
async function upvote() {
|
async function upvote() {
|
||||||
if (!$authData) return
|
if (!$authData) return
|
||||||
|
|
||||||
|
if (vote == undefined) vote = 0
|
||||||
|
|
||||||
const upvoted = vote == 1
|
const upvoted = vote == 1
|
||||||
|
|
||||||
if (vote == -1) {
|
if (vote == -1) {
|
||||||
@@ -36,6 +38,8 @@
|
|||||||
async function downvote() {
|
async function downvote() {
|
||||||
if (!$authData) return
|
if (!$authData) return
|
||||||
|
|
||||||
|
if (vote == undefined) vote = 0
|
||||||
|
|
||||||
const upvoted = vote == -1
|
const upvoted = vote == -1
|
||||||
|
|
||||||
if (vote == -1) {
|
if (vote == -1) {
|
||||||
|
|||||||
@@ -77,11 +77,8 @@ authData.subscribe(async (data) => {
|
|||||||
const site = await getClient().getSite({
|
const site = await getClient().getSite({
|
||||||
auth: data.token,
|
auth: data.token,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!site?.my_user) throw Error('Missing user')
|
if (!site?.my_user) throw Error('Missing user')
|
||||||
|
|
||||||
user.set({ ...site.my_user.local_user_view, unreads: 0 })
|
user.set({ ...site.my_user.local_user_view, unreads: 0 })
|
||||||
|
|
||||||
if (typeof localStorage != 'undefined') {
|
if (typeof localStorage != 'undefined') {
|
||||||
localStorage.setItem('user', JSON.stringify(data))
|
localStorage.setItem('user', JSON.stringify(data))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ const config = {
|
|||||||
csp: {
|
csp: {
|
||||||
directives: {
|
directives: {
|
||||||
'script-src': ['self'],
|
'script-src': ['self'],
|
||||||
'object-src': ['none'],
|
// 'object-src': ['none'],
|
||||||
'base-uri': ['none']
|
'base-uri': ['none']
|
||||||
},
|
},
|
||||||
mode: 'nonce'
|
mode: 'nonce'
|
||||||
|
|||||||
Reference in new issue
Block a user