-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Button } from './ui/button'; | ||
import { useState } from 'react'; | ||
import { Dialog, DialogContent, DialogHeader, DialogTrigger } from './ui/dialog'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { MessageCirclePlusIcon } from 'lucide-react'; | ||
import { cn } from '@/lib/utils'; | ||
import { HandleInput } from './ui/HandleInput'; | ||
import { useBlueskyStore } from '@/lib/bluesky/store'; | ||
import { useNavigate } from '@tanstack/react-router'; | ||
|
||
export function CreateConvo() { | ||
const agent = useBlueskyStore((state) => state.agent); | ||
const { t } = useTranslation(['app', 'post']); | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [value, setValue] = useState<string>(''); | ||
const isPending = false; | ||
const navigate = useNavigate(); | ||
|
||
const onClickCancel = () => { | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<Dialog open={isOpen} onOpenChange={setIsOpen}> | ||
<DialogTrigger asChild> | ||
<Button | ||
variant="outline" | ||
className={cn( | ||
// mobile | ||
'fixed bottom-16 right-2 rounded-full aspect-square size-16', | ||
// tablet | ||
'md:bottom-2', | ||
// desktop | ||
'xl:static xl:aspect-auto xl:size-auto', | ||
)} | ||
> | ||
<span className="hidden xl:block">{t('post:createPost')}</span> | ||
<MessageCirclePlusIcon className="block xl:hidden" /> | ||
</Button> | ||
</DialogTrigger> | ||
<DialogContent className="[&>button]:hidden p-0 border"> | ||
<DialogHeader className="justify-between w-full p-2"> | ||
<Button type="button" variant="ghost" onClick={onClickCancel} disabled={isPending} className="text-gray-500"> | ||
{t('cancel')} | ||
</Button> | ||
</DialogHeader> | ||
<div className="p-2"> | ||
<HandleInput | ||
value={value} | ||
onChange={setValue} | ||
onSelect={async (profile) => { | ||
const proxy = agent.withProxy('bsky_chat', 'did:web:api.bsky.chat'); | ||
const convo = await proxy.api.chat.bsky.convo.getConvoForMembers({ | ||
members: [profile.did], | ||
}); | ||
|
||
navigate({ | ||
to: '/messages/$convoId', | ||
params: { | ||
convoId: convo.data.convo.id, | ||
}, | ||
}); | ||
}} | ||
/> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters