Clipclop tweaks (#3851)

* scroll on input resize

* add back the padding 🙊

* fix timestamps
zio/stable
Hailey 2024-05-03 15:08:59 -07:00 committed by GitHub
parent 876816675e
commit feff55a14a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 13 deletions

View File

@ -32,6 +32,11 @@ export let MessageItem = ({
next.sender?.did === currentAccount?.did next.sender?.did === currentAccount?.did
const isLastInGroup = useMemo(() => { const isLastInGroup = useMemo(() => {
// TODO this means it's a placeholder. Let's figure out the right way to do this though!
if (item.id.length > 13) {
return false
}
// if the next message is from a different sender, then it's the last in the group // if the next message is from a different sender, then it's the last in the group
if (isFromSelf ? !isNextFromSelf : isNextFromSelf) { if (isFromSelf ? !isNextFromSelf : isNextFromSelf) {
return true return true

View File

@ -18,10 +18,10 @@ import {PaperPlane_Stroke2_Corner0_Rounded as PaperPlane} from '#/components/ico
export function MessageInput({ export function MessageInput({
onSendMessage, onSendMessage,
onFocus, scrollToEnd,
}: { }: {
onSendMessage: (message: string) => void onSendMessage: (message: string) => void
onFocus?: () => void scrollToEnd: () => void
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
@ -54,8 +54,10 @@ export function MessageInput({
setMaxHeight(max) setMaxHeight(max)
setIsInputScrollable(availableSpace < 30) setIsInputScrollable(availableSpace < 30)
scrollToEnd()
}, },
[topInset], [scrollToEnd, topInset],
) )
return ( return (
@ -82,7 +84,7 @@ export function MessageInput({
keyboardAppearance={t.name === 'light' ? 'light' : 'dark'} keyboardAppearance={t.name === 'light' ? 'light' : 'dark'}
scrollEnabled={isInputScrollable} scrollEnabled={isInputScrollable}
blurOnSubmit={false} blurOnSubmit={false}
onFocus={onFocus} onFocus={scrollToEnd}
onContentSizeChange={onInputLayout} onContentSizeChange={onInputLayout}
ref={inputRef} ref={inputRef}
/> />

View File

@ -11,7 +11,7 @@ export function MessageInput({
onSendMessage, onSendMessage,
}: { }: {
onSendMessage: (message: string) => void onSendMessage: (message: string) => void
onFocus: () => void scrollToEnd: () => void
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()

View File

@ -168,9 +168,11 @@ export function MessagesList() {
[contentHeight.value, hasInitiallyScrolled, isAtBottom], [contentHeight.value, hasInitiallyScrolled, isAtBottom],
) )
const onInputFocus = React.useCallback(() => { const scrollToEnd = React.useCallback(() => {
flatListRef.current?.scrollToEnd({animated: true}) requestAnimationFrame(() =>
}, [flatListRef]) flatListRef.current?.scrollToEnd({animated: true}),
)
}, [])
const {bottom: bottomInset} = useSafeAreaInsets() const {bottom: bottomInset} = useSafeAreaInsets()
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
@ -200,6 +202,7 @@ export function MessagesList() {
maintainVisibleContentPosition={{ maintainVisibleContentPosition={{
minIndexForVisible: 1, minIndexForVisible: 1,
}} }}
contentContainerStyle={{paddingHorizontal: 10}}
removeClippedSubviews={false} removeClippedSubviews={false}
onContentSizeChange={onContentSizeChange} onContentSizeChange={onContentSizeChange}
onStartReached={onStartReached} onStartReached={onStartReached}
@ -215,10 +218,7 @@ export function MessagesList() {
/> />
</ScrollProvider> </ScrollProvider>
</View> </View>
<MessageInput <MessageInput onSendMessage={onSendMessage} scrollToEnd={scrollToEnd} />
onSendMessage={onSendMessage}
onFocus={isWeb ? onInputFocus : undefined}
/>
</KeyboardAvoidingView> </KeyboardAvoidingView>
) )
} }

View File

@ -786,7 +786,7 @@ export class Convo {
(ChatBskyConvoDefs.isMessageView(item.message) || (ChatBskyConvoDefs.isMessageView(item.message) ||
ChatBskyConvoDefs.isDeletedMessageView(item.message)) ChatBskyConvoDefs.isDeletedMessageView(item.message))
) { ) {
const next = items[i - 1] const next = items[i + 1]
if ( if (
isConvoItemMessage(next) && isConvoItemMessage(next) &&