Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jan 23, 2024
1 parent f3a2117 commit 88d51bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/new-feed.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"

import { useState, useTransition } from "react"
import { useRef, useState, useTransition } from "react"
import { useFormStatus } from "react-dom"
import { toast } from "sonner"

Expand Down Expand Up @@ -29,6 +29,8 @@ function ParseButton() {
export function NewFeedDialog() {
const [isPending, startTransition] = useTransition()
const [feedInfo, setFeedInfo] = useState<FeedInfoWithoutId | undefined>()
const feedUrlInputRef = useRef<HTMLInputElement>(null)

function addFeed() {
if (!feedInfo) return
startTransition(async () => {
Expand All @@ -39,6 +41,11 @@ export function NewFeedDialog() {
} else {
toast.success("Feed added")
}
setFeedInfo(undefined)
if (feedUrlInputRef.current) {
feedUrlInputRef.current.value = ""
feedUrlInputRef.current.focus()
}
})
}

Expand All @@ -62,7 +69,7 @@ export function NewFeedDialog() {
setFeedInfo(response)
}}
>
<Input name="feedUrl" className="col-span-3" />
<Input name="feedUrl" ref={feedUrlInputRef} />
<ParseButton />
</form>
<pre className="text-xs overflow-auto">
Expand Down

0 comments on commit 88d51bb

Please sign in to comment.