jbilcke-hf HF staff commited on
Commit
4fe04e4
β€’
1 Parent(s): e047739

fixed (maybe)

Browse files
Files changed (3) hide show
  1. src/app/page.tsx +21 -3
  2. src/server/actions.ts +4 -0
  3. src/server/index.ts +1 -0
src/app/page.tsx CHANGED
@@ -1,9 +1,27 @@
1
  "use client"
2
 
3
- import { redirect } from "next/navigation"
4
  import { v4 as uuidv4 } from "uuid"
5
 
 
 
6
  export default function Index() {
7
- const uuid = uuidv4()
8
- redirect(`/studio/${uuid}`)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
 
1
  "use client"
2
 
3
+ import { useEffect, useState } from "react"
4
  import { v4 as uuidv4 } from "uuid"
5
 
6
+ const key = "VideoChain-UI-Owner-ID"
7
+
8
  export default function Index() {
9
+ const [uuid, setUuid] = useState<string>()
10
+
11
+ useEffect(() => {
12
+ if (uuid) {
13
+ window.location.href = `/studio/${uuid}`
14
+ } else {
15
+ const existingUuid = `${localStorage.getItem(key)} || ""`
16
+ if (existingUuid?.length > 10) {
17
+ setUuid(existingUuid)
18
+ } else {
19
+ const newUuid = uuidv4()
20
+ setUuid(newUuid)
21
+ localStorage.setItem(key, newUuid)
22
+ }
23
+ }
24
+ }, [uuid])
25
+
26
+ return <div>Loading..</div>
27
  }
src/server/actions.ts CHANGED
@@ -3,6 +3,10 @@
3
  import { revalidatePath } from "next/cache"
4
  import { createNewVideo } from "."
5
 
 
 
 
 
6
  export async function handleFormSubmit(formData: FormData) {
7
  const ownerId = `${formData.get("ownerId") || ""}`
8
  await createNewVideo(ownerId, {
 
3
  import { revalidatePath } from "next/cache"
4
  import { createNewVideo } from "."
5
 
6
+ export async function isAdmin(adminSecret: string) {
7
+ return adminSecret === process.env.ADMIN_SECRET
8
+ }
9
+
10
  export async function handleFormSubmit(formData: FormData) {
11
  const ownerId = `${formData.get("ownerId") || ""}`
12
  await createNewVideo(ownerId, {
src/server/index.ts CHANGED
@@ -6,6 +6,7 @@ import { Video, VideoAPIRequest, GenericAPIResponse, VideoStatusRequest, VideoSt
6
 
7
  import { GET, POST, DELETE, PATCH } from "./base"
8
 
 
9
  // note: for security purposes we do not directly expose the VideoChain API:
10
  // all calls are protected with a token, that way it the VideooChain API can stay
11
  // lightweight, security and quotas are handled outside
 
6
 
7
  import { GET, POST, DELETE, PATCH } from "./base"
8
 
9
+
10
  // note: for security purposes we do not directly expose the VideoChain API:
11
  // all calls are protected with a token, that way it the VideooChain API can stay
12
  // lightweight, security and quotas are handled outside