jbilcke-hf HF staff commited on
Commit
cfbfdc3
1 Parent(s): 6836dc7

tentative fix for mobile

Browse files
src/app/firehose/page.tsx CHANGED
@@ -13,17 +13,20 @@ import Link from "next/link"
13
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
14
  import { getLatestPosts } from "@/app/server/actions/community"
15
 
 
 
16
  export default function FirehosePage() {
17
  const searchParams = useSearchParams()
18
  const [_isPending, startTransition] = useTransition()
19
  const [posts, setPosts] = useState<Post[]>([])
20
  const moderationKey = (searchParams.get("moderationKey") as string) || ""
 
21
  const [toDelete, setToDelete] = useState<Post>()
22
 
23
  useEffect(() => {
24
  startTransition(async () => {
25
  const newPosts = await getLatestPosts({
26
- maxNbPosts: 80,
27
  shuffle: false,
28
  })
29
  setPosts(newPosts)
 
13
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
14
  import { getLatestPosts } from "@/app/server/actions/community"
15
 
16
+ const defaultLimit = 200
17
+
18
  export default function FirehosePage() {
19
  const searchParams = useSearchParams()
20
  const [_isPending, startTransition] = useTransition()
21
  const [posts, setPosts] = useState<Post[]>([])
22
  const moderationKey = (searchParams.get("moderationKey") as string) || ""
23
+ const limit = Number((searchParams.get("limit") as string) || defaultLimit)
24
  const [toDelete, setToDelete] = useState<Post>()
25
 
26
  useEffect(() => {
27
  startTransition(async () => {
28
  const newPosts = await getLatestPosts({
29
+ maxNbPosts: isNaN(limit) || !isFinite(limit) ? defaultLimit : limit,
30
  shuffle: false,
31
  })
32
  setPosts(newPosts)
src/app/interface/generate/index.tsx CHANGED
@@ -37,6 +37,7 @@ export function Generate() {
37
  const [_isPending, startTransition] = useTransition()
38
 
39
  const scrollRef = useRef<HTMLDivElement>(null)
 
40
 
41
  const [isLocked, setLocked] = useState(false)
42
  const [promptDraft, setPromptDraft] = useState("")
@@ -59,7 +60,7 @@ export function Generate() {
59
  const { progressPercent, remainingTimeInSec } = useCountdown({
60
  isActive: isLocked,
61
  timerId: runs, // everytime we change this, the timer will reset
62
- durationInSec: /*stage === "interpolate" ? 30 :*/ 80, // it usually takes 40 seconds, but there might be lag
63
  onEnd: () => {}
64
  })
65
 
@@ -173,7 +174,11 @@ export function Generate() {
173
 
174
  setLocked(false)
175
  setStage("generate")
176
-
 
 
 
 
177
  try {
178
  const post = await postToCommunity({
179
  prompt: promptDraft,
@@ -318,6 +323,10 @@ export function Generate() {
318
  }
319
  }
320
 
 
 
 
 
321
  return (
322
  <div
323
  ref={scrollRef}
@@ -336,7 +345,7 @@ export function Generate() {
336
 
337
  className={cn(
338
  `flex flex-col`,
339
- `w-full md:max-w-4xl lg:max-w-5xl xl:max-w-6xl max-h-[80vh]`,
340
  `space-y-8`,
341
  // `transition-all duration-300 ease-in-out`,
342
  )}>
@@ -360,10 +369,12 @@ export function Generate() {
360
  )}>
361
  {assetUrl.startsWith("data:video/mp4") || assetUrl.endsWith(".mp4")
362
  ? <video
 
363
  muted
364
  autoPlay
365
  loop
366
  src={assetUrl}
 
367
  className="rounded-md overflow-hidden md:h-[400px] lg:h-[500px] xl:h-[560px]"
368
  /> :
369
  <img
 
37
  const [_isPending, startTransition] = useTransition()
38
 
39
  const scrollRef = useRef<HTMLDivElement>(null)
40
+ const videoRef = useRef<HTMLVideoElement>(null)
41
 
42
  const [isLocked, setLocked] = useState(false)
43
  const [promptDraft, setPromptDraft] = useState("")
 
60
  const { progressPercent, remainingTimeInSec } = useCountdown({
61
  isActive: isLocked,
62
  timerId: runs, // everytime we change this, the timer will reset
63
+ durationInSec: /*stage === "interpolate" ? 30 :*/ 90, // it usually takes 40 seconds, but there might be lag
64
  onEnd: () => {}
65
  })
66
 
 
174
 
175
  setLocked(false)
176
  setStage("generate")
177
+
178
+ if (process.env.NEXT_PUBLIC_ENABLE_COMMUNITY_SHARING !== "true") {
179
+ return
180
+ }
181
+
182
  try {
183
  const post = await postToCommunity({
184
  prompt: promptDraft,
 
323
  }
324
  }
325
 
326
+ const handleClickPlay = () => {
327
+ videoRef.current?.play()
328
+ }
329
+
330
  return (
331
  <div
332
  ref={scrollRef}
 
345
 
346
  className={cn(
347
  `flex flex-col`,
348
+ `w-full md:max-w-4xl lg:max-w-5xl xl:max-w-6xl max-h-[85vh]`,
349
  `space-y-8`,
350
  // `transition-all duration-300 ease-in-out`,
351
  )}>
 
369
  )}>
370
  {assetUrl.startsWith("data:video/mp4") || assetUrl.endsWith(".mp4")
371
  ? <video
372
+ ref={videoRef}
373
  muted
374
  autoPlay
375
  loop
376
  src={assetUrl}
377
+ onClick={handleClickPlay}
378
  className="rounded-md overflow-hidden md:h-[400px] lg:h-[500px] xl:h-[560px]"
379
  /> :
380
  <img