From 5eb9851eafd7e2342f6a6a217fadbac2c0df2f6b Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 5 Aug 2024 08:00:14 +0200 Subject: [PATCH] bugfixing video streamer --- src/lib/components/Input.svelte | 6 ++--- src/lib/components/PostSection.svelte | 25 ++++--------------- .../community/post/[postId]/+page.svelte | 2 +- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/lib/components/Input.svelte b/src/lib/components/Input.svelte index 5ba2b4a5..5f02c20b 100644 --- a/src/lib/components/Input.svelte +++ b/src/lib/components/Input.svelte @@ -28,7 +28,8 @@ const files = target.files; if (files.length > 0) { - if (['.mp4', '.webm'].some(format => files[0]?.name?.includes(format)) ) + + if (files[0]?.name?.toLowerCase()?.includes('.mp4')) { videoInput = URL.createObjectURL(files[0]); } @@ -67,8 +68,7 @@ function handleInput(event) { inputValue = event.target.value; - - if(inputValue.includes('.mp4')) + if(inputValue?.toLowerCase()?.includes('.mp4')) { showVideo = true; } diff --git a/src/lib/components/PostSection.svelte b/src/lib/components/PostSection.svelte index cc909066..7d459df7 100644 --- a/src/lib/components/PostSection.svelte +++ b/src/lib/components/PostSection.svelte @@ -6,7 +6,7 @@ import Downvote from '$lib/components/Downvote.svelte'; import Upvote from '$lib/components/Upvote.svelte'; - import {userRegion, postVote, tagList, postIdDeleted} from '$lib/store'; + import {postVote, tagList, postIdDeleted} from '$lib/store'; import toast from 'svelte-french-toast'; @@ -14,21 +14,6 @@ export let moderators; export let data; - const usRegion = ['cle1','iad1','pdx1','sfo1']; - - let apiURL = import.meta.env.VITE_EU_API_URL; // Set a default API URL - - let fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL; - userRegion.subscribe(value => { - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL; - } - }); - let deletePostId = posts?.id @@ -89,7 +74,7 @@ 'userId': posts?.user }; - const response = await fetch(fastifyURL+'/delete-post', { + const response = await fetch(data?.fastifyURL+'/delete-post', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -147,7 +132,7 @@ const handleUpvote = async (event) => { $postVote = {'id': postId, 'upvote': upvoteCounter[postId], 'downvote': downvoteCounter[postId], 'upvoteClicked': upvoteButtonClicked[postId], 'downvoteClicked': downvoteButtonClicked[postId]}; - const response = await fetch(fastifyURL+'/upvote', { + const response = await fetch(data?.fastifyURL+'/upvote', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -183,7 +168,7 @@ const handleDownvote = async (event) => { $postVote = {'id': postId, 'upvote': upvoteCounter[postId], 'downvote': downvoteCounter[postId], 'upvoteClicked': upvoteButtonClicked[postId], 'downvoteClicked': downvoteButtonClicked[postId]}; - const response = await fetch(fastifyURL+'/downvote', { + const response = await fetch(data?.fastifyURL+'/downvote', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -457,7 +442,7 @@ $: {
- {#if posts?.thumbnail && !['webm', 'mp4']?.some(format => posts?.thumbnail?.includes(format))} + {#if posts?.thumbnail && !posts?.thumbnail?.toLowerCase()?.includes('mp4')}
diff --git a/src/routes/community/post/[postId]/+page.svelte b/src/routes/community/post/[postId]/+page.svelte index 2273ce9d..ce51bbf8 100644 --- a/src/routes/community/post/[postId]/+page.svelte +++ b/src/routes/community/post/[postId]/+page.svelte @@ -714,7 +714,7 @@ function updateVote(postVote) { {#if post?.thumbnail?.length !==0} - {#if !['webm', 'mp4'].some(format => post?.thumbnail?.includes(format))} + {#if !post?.thumbnail?.toLowerCase()?.includes('mp4')}