Spaces:
Running
Running
Commit
·
b710c3a
1
Parent(s):
7b89082
make sure we renew the cache
Browse files
src/app/main.tsx
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
import { useStore } from "./state/useStore"
|
4 |
import { HomeView } from "./views/home-view"
|
5 |
import { PublicChannelsView } from "./views/public-channels-view"
|
6 |
-
import { UserChannelsView } from "./views/user-channels-view"
|
7 |
import { PublicChannelView } from "./views/public-channel-view"
|
8 |
import { UserChannelView } from "./views/user-channel-view"
|
9 |
import { PublicVideoView } from "./views/public-video-view"
|
@@ -69,7 +68,6 @@ export function Main({
|
|
69 |
{view === "public_video" && <PublicVideoView />}
|
70 |
{view === "public_channels" && <PublicChannelsView />}
|
71 |
{view === "public_channel" && <PublicChannelView />}
|
72 |
-
{view === "user_channels" && <UserChannelsView />}
|
73 |
{/*view === "user_videos" && <UserVideosView />*/}
|
74 |
{view === "user_channel" && <UserChannelView />}
|
75 |
{view === "user_account" && <UserAccountView />}
|
|
|
3 |
import { useStore } from "./state/useStore"
|
4 |
import { HomeView } from "./views/home-view"
|
5 |
import { PublicChannelsView } from "./views/public-channels-view"
|
|
|
6 |
import { PublicChannelView } from "./views/public-channel-view"
|
7 |
import { UserChannelView } from "./views/user-channel-view"
|
8 |
import { PublicVideoView } from "./views/public-video-view"
|
|
|
68 |
{view === "public_video" && <PublicVideoView />}
|
69 |
{view === "public_channels" && <PublicChannelsView />}
|
70 |
{view === "public_channel" && <PublicChannelView />}
|
|
|
71 |
{/*view === "user_videos" && <UserVideosView />*/}
|
72 |
{view === "user_channel" && <UserChannelView />}
|
73 |
{view === "user_account" && <UserAccountView />}
|
src/app/server/actions/ai-tube-hf/getChannels.ts
CHANGED
@@ -38,7 +38,7 @@ export async function getChannels(options: {
|
|
38 |
? { owner } // search channels of a specific user
|
39 |
: prefix // global search (note: might be costly?)
|
40 |
|
41 |
-
|
42 |
for await (const { id, name, likes, updatedAt } of listDatasets({
|
43 |
search,
|
44 |
credentials,
|
|
|
38 |
? { owner } // search channels of a specific user
|
39 |
: prefix // global search (note: might be costly?)
|
40 |
|
41 |
+
console.log("search:", search)
|
42 |
for await (const { id, name, likes, updatedAt } of listDatasets({
|
43 |
search,
|
44 |
credentials,
|
src/app/views/user-account-view/index.tsx
CHANGED
@@ -28,7 +28,10 @@ export function UserAccountView() {
|
|
28 |
if (!isLoaded) {
|
29 |
startTransition(async () => {
|
30 |
try {
|
31 |
-
const channels = await getChannels({
|
|
|
|
|
|
|
32 |
setCurrentChannels(channels)
|
33 |
} catch (err) {
|
34 |
console.error("failed to load the channel for the current user:", err)
|
|
|
28 |
if (!isLoaded) {
|
29 |
startTransition(async () => {
|
30 |
try {
|
31 |
+
const channels = await getChannels({
|
32 |
+
apiKey: huggingfaceApiKey,
|
33 |
+
renewCache: true,
|
34 |
+
})
|
35 |
setCurrentChannels(channels)
|
36 |
} catch (err) {
|
37 |
console.error("failed to load the channel for the current user:", err)
|
src/app/views/user-channels-view/index.tsx
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
"use client"
|
2 |
-
|
3 |
-
import { useEffect, useState, useTransition } from "react"
|
4 |
-
import { useLocalStorage } from "usehooks-ts"
|
5 |
-
|
6 |
-
import { useStore } from "@/app/state/useStore"
|
7 |
-
import { cn } from "@/lib/utils"
|
8 |
-
import { getChannels } from "@/app/server/actions/ai-tube-hf/getChannels"
|
9 |
-
import { ChannelList } from "@/app/interface/channel-list"
|
10 |
-
import { localStorageKeys } from "@/app/state/localStorageKeys"
|
11 |
-
import { defaultSettings } from "@/app/state/defaultSettings"
|
12 |
-
import { Input } from "@/components/ui/input"
|
13 |
-
|
14 |
-
export function UserChannelsView() {
|
15 |
-
const [_isPending, startTransition] = useTransition()
|
16 |
-
const [huggingfaceApiKey, setHuggingfaceApiKey] = useLocalStorage<string>(
|
17 |
-
localStorageKeys.huggingfaceApiKey,
|
18 |
-
defaultSettings.huggingfaceApiKey
|
19 |
-
)
|
20 |
-
const setView = useStore(s => s.setView)
|
21 |
-
const setCurrentChannel = useStore(s => s.setCurrentChannel)
|
22 |
-
|
23 |
-
const currentChannels = useStore(s => s.currentChannels)
|
24 |
-
const setCurrentChannels = useStore(s => s.setCurrentChannels)
|
25 |
-
const [isLoaded, setLoaded] = useState(false)
|
26 |
-
|
27 |
-
useEffect(() => {
|
28 |
-
if (!isLoaded) {
|
29 |
-
startTransition(async () => {
|
30 |
-
try {
|
31 |
-
const channels = await getChannels({ apiKey: huggingfaceApiKey })
|
32 |
-
setCurrentChannels(channels)
|
33 |
-
} catch (err) {
|
34 |
-
console.error("failed to load the channel for the current user:", err)
|
35 |
-
setCurrentChannels([])
|
36 |
-
} finally {
|
37 |
-
setLoaded(true)
|
38 |
-
}
|
39 |
-
})
|
40 |
-
}
|
41 |
-
}, [isLoaded, huggingfaceApiKey])
|
42 |
-
|
43 |
-
return (
|
44 |
-
<div className={cn(`flex flex-col space-y-4`)}>
|
45 |
-
<h2 className="text-3xl font-bold">Want your own channels? Setup your account!</h2>
|
46 |
-
|
47 |
-
<div className="flex flex-col space-y-4 max-w-2xl">
|
48 |
-
<div className="flex flex-row space-x-2 items-center">
|
49 |
-
<label className="flex w-64">Hugging Face token:</label>
|
50 |
-
<Input
|
51 |
-
placeholder="Hugging Face token (with WRITE access)"
|
52 |
-
type="password"
|
53 |
-
className="font-mono"
|
54 |
-
onChange={(x) => {
|
55 |
-
setHuggingfaceApiKey(x.target.value)
|
56 |
-
}}
|
57 |
-
value={huggingfaceApiKey}
|
58 |
-
/>
|
59 |
-
</div>
|
60 |
-
<p className="text-neutral-100/70">
|
61 |
-
Note: your Hugging Face token must be a <span className="font-bold font-mono text-yellow-300">WRITE</span> access token.
|
62 |
-
</p>
|
63 |
-
{huggingfaceApiKey
|
64 |
-
? <p className="">Nice, looks like you are ready to go!</p>
|
65 |
-
: <p>Please setup your account (see above) to get started</p>}
|
66 |
-
</div>
|
67 |
-
|
68 |
-
{huggingfaceApiKey ?
|
69 |
-
<div className="flex flex-col space-y-4">
|
70 |
-
<h2 className="text-3xl font-bold">Your custom channels:</h2>
|
71 |
-
{currentChannels?.length ? <ChannelList
|
72 |
-
layout="grid"
|
73 |
-
channels={currentChannels}
|
74 |
-
onSelect={(channel) => {
|
75 |
-
setCurrentChannel(channel)
|
76 |
-
setView("user_channel")
|
77 |
-
}}
|
78 |
-
/> : <p>Ask <span className="font-mono">@jbilcke-hf</span> for help to create a channel!</p>}
|
79 |
-
</div> : null}
|
80 |
-
</div>
|
81 |
-
)
|
82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|