Skip to content

Commit

Permalink
Fix thread creation modal redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
fjsj committed Feb 4, 2025
1 parent 45935b8 commit 6665c4d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions components/CreateThreadModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { View } from "@/components/ui/view";
interface CreateThreadModalProps {
isOpen: boolean;
onClose: () => void;
onCreate: (topic: string) => Promise<void>;
onCreateThread: (topic: string) => Promise<string | undefined>;
}

export function CreateThreadModal({ isOpen, onClose, onCreate }: CreateThreadModalProps) {
export function CreateThreadModal({ isOpen, onClose, onCreateThread }: CreateThreadModalProps) {
const [topic, setTopic] = useState("");
const [isCreating, setIsCreating] = useState(false);
const { colorScheme } = useColorScheme();
Expand All @@ -22,10 +22,12 @@ export function CreateThreadModal({ isOpen, onClose, onCreate }: CreateThreadMod
const handleCreate = async () => {
setIsCreating(true);
try {
await onCreate(topic);
setTopic("");
onClose();
router.push(`/thread/${topic}`);
const threadId = await onCreateThread(topic);
if (threadId) {
setTopic("");
onClose();
router.push(`/thread/${threadId}`);
}
} finally {
setIsCreating(false);
}
Expand Down

0 comments on commit 6665c4d

Please sign in to comment.