-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chat: reply menu item, show reply in ui, cleanups
- Loading branch information
Showing
11 changed files
with
231 additions
and
73 deletions.
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
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
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 |
---|---|---|
@@ -1,56 +1,62 @@ | ||
import { YStack } from 'tamagui' | ||
import { Configuration, YStack } from 'tamagui' | ||
import { updateUserCurrentChannel, useCurrentThread } from '~/state/user' | ||
import { animationsCSS } from '~/tamagui/animations.css' | ||
import { ButtonClose } from '../ButtonClose' | ||
import { MessagesList } from '../messages/MessagesList' | ||
import { MessageInput } from '../messages/MessageInput' | ||
import { MessagesList } from '../messages/MessagesList' | ||
|
||
export const MainOpenThread = () => { | ||
const thread = useCurrentThread() | ||
|
||
return ( | ||
<YStack | ||
bg="$color2" | ||
shadowColor="$shadowColor" | ||
shadowRadius={10} | ||
animation={[ | ||
'quicker', | ||
{ | ||
opacity: { | ||
overshootClamping: true, | ||
<Configuration animationDriver={animationsCSS}> | ||
<YStack | ||
bg="$color2" | ||
shadowColor="$shadowColor" | ||
shadowRadius={10} | ||
animation={[ | ||
'quickest', | ||
{ | ||
opacity: { | ||
overshootClamping: true, | ||
}, | ||
}, | ||
}, | ||
]} | ||
pos="absolute" | ||
t={0} | ||
r={0} | ||
b={0} | ||
w="70%" | ||
zi={1000} | ||
{...(thread | ||
? {} | ||
: { | ||
opacity: 0, | ||
pe: 'none', | ||
x: 7, | ||
})} | ||
> | ||
<ButtonClose | ||
]} | ||
pos="absolute" | ||
t={0} | ||
r={0} | ||
b={0} | ||
w="70%" | ||
zi={1000} | ||
t={10} | ||
l={-20} | ||
onPress={() => { | ||
updateUserCurrentChannel({ | ||
openedThreadId: undefined, | ||
}) | ||
}} | ||
/> | ||
{thread && ( | ||
<> | ||
<MessagesList messages={thread?.messages || []} /> | ||
<MessageInput inThread /> | ||
</> | ||
)} | ||
</YStack> | ||
{...(thread | ||
? { | ||
opacity: 1, | ||
x: 0, | ||
} | ||
: { | ||
opacity: 0, | ||
pe: 'none', | ||
x: 7, | ||
})} | ||
> | ||
<ButtonClose | ||
pos="absolute" | ||
zi={1000} | ||
t={10} | ||
l={-20} | ||
onPress={() => { | ||
updateUserCurrentChannel({ | ||
openedThreadId: undefined, | ||
}) | ||
}} | ||
/> | ||
{thread && ( | ||
<> | ||
<MessagesList messages={thread?.messages || []} /> | ||
<MessageInput inThread /> | ||
</> | ||
)} | ||
</YStack> | ||
</Configuration> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { X } from '@tamagui/lucide-icons' | ||
import { useState } from 'react' | ||
import { Button, SizableText, XStack } from 'tamagui' | ||
import { useQuery } from '~/zero' | ||
import { Avatar } from '../Avatar' | ||
import { showToast } from '../toast/Toast' | ||
import { messageInputEmitter, messageReplyEmitter } from './emitters' | ||
|
||
export const MessageInputReply = () => { | ||
const [replyId, setReplyId] = useState('') | ||
const message = useQuery((q) => | ||
q.message.where('id', replyId).related('sender', (q) => q.one()) | ||
)[0][0] | ||
const sender = message?.sender | ||
|
||
messageReplyEmitter.use((value) => { | ||
switch (value.type) { | ||
case 'reply': { | ||
setReplyId(value.messageId) | ||
messageInputEmitter.emit({ type: 'focus' }) | ||
break | ||
} | ||
case 'cancel': { | ||
setReplyId('') | ||
break | ||
} | ||
} | ||
}) | ||
|
||
if (!message || !sender) { | ||
return null | ||
} | ||
|
||
return ( | ||
<XStack bg="$color6" py="$1.5" px="$2" ai="center" gap="$3" br="$3"> | ||
<Button | ||
onPress={() => { | ||
messageReplyEmitter.emit({ type: 'cancel' }) | ||
}} | ||
size="$1" | ||
circular | ||
icon={X} | ||
/> | ||
|
||
<SizableText size="$3">Replying to</SizableText> | ||
|
||
<XStack gap="$2"> | ||
<Avatar size={24} image={sender.image} /> | ||
<SizableText size="$3" fow="500"> | ||
{sender.name || sender.username} | ||
</SizableText> | ||
</XStack> | ||
</XStack> | ||
) | ||
} |
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
Oops, something went wrong.