diff --git a/source/src/pages/api/subscription/add.astro b/source/src/pages/api/subscription/add.astro new file mode 100644 index 0000000..93c14f8 --- /dev/null +++ b/source/src/pages/api/subscription/add.astro @@ -0,0 +1,24 @@ +--- +import Base from "@layouts/Default.astro" +const CreatorId = Astro.url.href.split("add?=").pop() +import { supabase } from "@library/supabase" +const { data: { user } } = await supabase.auth.getUser() +const { data, error } = await supabase + .from('subs') + .insert([ + { + UserSubscribed: user?.id, + Id: CreatorId, + Platform: "YouTube" + }, + ]) + .select() + +return Astro.redirect("/channel/" + CreatorId) +--- + + +
+

One moment...

+
+ \ No newline at end of file diff --git a/source/src/pages/api/subscription/remove.astro b/source/src/pages/api/subscription/remove.astro new file mode 100644 index 0000000..25f467a --- /dev/null +++ b/source/src/pages/api/subscription/remove.astro @@ -0,0 +1,21 @@ +--- +import Base from "@layouts/Default.astro" +const CreatorId = Astro.url.href.split("remove?=").pop() +import { supabase } from "@library/supabase" +const { data: { user } } = await supabase.auth.getUser() +const id = user?.id +const { data, error } = await supabase + .from('subs') + .delete() + .eq('UserSubscribed', id) + .eq('Id', CreatorId) + .eq('Platform', 'YouTube') + +return Astro.redirect("/channel/" + CreatorId) +--- + + +
+

One moment...

+
+ \ No newline at end of file diff --git a/source/src/pages/channel/[...slug].astro b/source/src/pages/channel/[...slug].astro index 5cd8e72..dde71c4 100755 --- a/source/src/pages/channel/[...slug].astro +++ b/source/src/pages/channel/[...slug].astro @@ -13,15 +13,36 @@ import { BrightStar, Donate, Download, ShareIos, ThumbsUp } from "@iconoir/vue"; import Video from '@components/VideoItem.astro' // Fetch -const SWV = Astro.url.href.split("channel/").pop(); -const channel = await fetch(DEFAULT_MEDIA_DATA_PROXY + "/api/v1/channels/" + SWV).then((response) => response.json()); +const CreatorId = Astro.url.href.split("channel/").pop(); +const channel = await fetch(DEFAULT_MEDIA_DATA_PROXY + "/api/v1/channels/" + CreatorId).then((response) => response.json()); const DescriptionFormat = channel.descriptionHtml.replaceAll("\n", "
"); + +// User Subscription +import { supabase } from "@library/supabase" +const { data: { user } } = await supabase.auth.getUser() +const id = user?.id +let { data: subs } = await supabase + .from('subs') + .select("*") + .eq('UserSubscribed', id) + .eq('Id', CreatorId) + +if (subs[0] === undefined) { + var Subbed = false +} else { + var Subbed = true +} ---
+ {Subbed ? + Unfollow + : + Follow + }
@@ -29,7 +50,7 @@ const DescriptionFormat = channel.descriptionHtml.replaceAll("\n", "
");
- +

{channel.author}

{channel.subCountText}