Browse Source

Merge branch 'some-bugs' into 'master'

FIX | Groups on home page, replied message styles, scroll to replied forwarded...

See merge request jetup/rws/rws-appication!364
merge-requests/365/merge
Coder 2 years ago
parent
commit
e78bfc3f9f
  1. 14
      src/modules/chats/hooks/use-chat-messages.hook.ts
  2. 2
      src/modules/chats/screens/chat.tsx
  3. 2
      src/modules/contacts/screens/contact-detail.screen.tsx
  4. 4
      src/modules/groups/smart-components/groups-slider-list.smart-component.tsx
  5. 8
      src/shared/components/plugins/chat/chat-item-audio.component.tsx
  6. 15
      src/shared/components/plugins/chat/replied-message-info.component.tsx
  7. 13
      src/shared/hooks/use-ids-list.hook.ts

14
src/modules/chats/hooks/use-chat-messages.hook.ts

@ -20,8 +20,8 @@ import { selectAccount, selectId } from '@/store/account' @@ -20,8 +20,8 @@ import { selectAccount, selectId } from '@/store/account'
import { UnselectChat } from '@/store/chats'
import { simpleDispatch } from '@/store/store-helpers'
import _ from 'lodash'
import { Alert, Platform } from 'react-native'
import { useCallback, useState } from 'react'
import { Platform } from 'react-native'
import { useCallback, useEffect, useState } from 'react'
import { useSelector } from 'react-redux'
import { getChatMessageMenuOptions } from '../configs'
import { ChatMessageActionEnum } from '../enums'
@ -54,6 +54,7 @@ export const useChatMessages = ( @@ -54,6 +54,7 @@ export const useChatMessages = (
firstMessageLoaded,
resetList,
_setItems,
loadItems
} = useIdsList<
Omit<IChatMessage, 'id'> & { id: number },
IFetchChatMessages
@ -62,14 +63,19 @@ export const useChatMessages = ( @@ -62,14 +63,19 @@ export const useChatMessages = (
req: chatMessageManager.getChatMessages.bind(chatMessageManager),
loadParams: {
sortField: 'id',
chatId: chatId?.toString(),
// chatId: chatId?.toString(),
},
needInit: true,
needInit: false,
clearWhenReload: false,
lastMessageId,
firstMessageId,
})
useEffect(() => {
if (chatId)
loadItems({chatId}, true)
}, [chatId])
const onCopy = useCallback((message: IChatMessage) => {
if (message.type === MessageType.Image) {
Clipboard.setString(message.content.fileUrl)

2
src/modules/chats/screens/chat.tsx

@ -76,7 +76,7 @@ export const ChatConversation = ({ navigation }: IProps) => { @@ -76,7 +76,7 @@ export const ChatConversation = ({ navigation }: IProps) => {
const replyToMessage =
replyTo?.type === MessageType.Forwarded
? replyTo?.content?.originalMessage
? { ...replyTo?.content?.originalMessage, id: replyTo.id }
: replyTo
const role = useMemo(() => {

2
src/modules/contacts/screens/contact-detail.screen.tsx

@ -43,6 +43,8 @@ export const ContactDetailScreen: FC<IProps> = ({ navigation, route }) => { @@ -43,6 +43,8 @@ export const ContactDetailScreen: FC<IProps> = ({ navigation, route }) => {
contact?.chatId,
)
simpleDispatch(new SelectChat({ id: chatId }))
chatManager.readChat.bind(chatManager)(chatId)
navigation.navigate(RouteKey.Conversation)
} catch (e) {
appEvents.emit('openInfoModal', {

4
src/modules/groups/smart-components/groups-slider-list.smart-component.tsx

@ -49,11 +49,11 @@ export const GroupsSliderList: FC<GroupsSliderListProps> = ({ @@ -49,11 +49,11 @@ export const GroupsSliderList: FC<GroupsSliderListProps> = ({
fetchItems: taxonomiesService.fetchGroupsWithTasksCount,
needInit: false,
loadParams: {
withoutEmpty: true,
// withoutEmpty: true,
sort: 'DESC',
sortField: 'id',
},
limit: 30,
limit: 35,
defaultLoading: false,
skeletonDataKey: SkeletonDataKey.HomeGroups,
clearWhenReload: false,

8
src/shared/components/plugins/chat/chat-item-audio.component.tsx

@ -115,6 +115,10 @@ export const ChatItemAudio: FC<ChatItemAudioProps> = props => { @@ -115,6 +115,10 @@ export const ChatItemAudio: FC<ChatItemAudioProps> = props => {
mediaService.seekToPlayer(position[0])
}
thumbStyle={styles.thumbStyle}
thumbTouchSize={{
width: $size(30),
height: $size(30),
}}
minimumTrackTintColor={
chats.voiceMsg.progressLine.$activeBg
}
@ -150,8 +154,8 @@ const createStyles = ({ chats: { voiceMsg } }: PartialTheme) => @@ -150,8 +154,8 @@ const createStyles = ({ chats: { voiceMsg } }: PartialTheme) =>
marginLeft: $size(10),
},
thumbStyle: {
width: $size(14),
height: $size(14),
width: $size(16),
height: $size(16),
backgroundColor: voiceMsg.progressLine.$indicatorBg,
borderWidth: 2,
borderColor: voiceMsg.progressLine.$indicatorBorder,

15
src/shared/components/plugins/chat/replied-message-info.component.tsx

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import { $size, IChatMessage, Txt, useTheme } from '@/shared'
import { $size, IChatMessage, MessageType, Txt, useTheme } from '@/shared'
import { getMessagePreviewText } from '@/shared/helpers'
import { PartialTheme } from '@/shared/themes/interfaces'
import React, { useMemo } from 'react'
@ -18,7 +18,6 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => { @@ -18,7 +18,6 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => {
const { styles, theme } = useTheme(createStyles)
if (!repliedMessage) return null
const text = useMemo(() => {
if (repliedMessage?.isDeleted) return 'Видалене повідомлення'
@ -26,7 +25,14 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => { @@ -26,7 +25,14 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => {
}, [repliedMessage])
return (
<TouchableOpacity style={styles.container} onPress={onPress}>
<TouchableOpacity
style={[
styles.container,
repliedMessage?.type === MessageType.Text
? { height: 'auto' }
: { height: $size(40, 30) },
]}
onPress={onPress}>
<MessageMediaPreview
type={repliedMessage?.type}
uri={repliedMessage?.content?.fileUrl}
@ -44,7 +50,7 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => { @@ -44,7 +50,7 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => {
style={[styles.txt, styles.name]}>
{repliedMessage?.userName}
</Txt>
<Txt numberOfLines={1} style={styles.txt}>
<Txt numberOfLines={3} style={styles.txt}>
{text}
</Txt>
</View>
@ -55,7 +61,6 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => { @@ -55,7 +61,6 @@ export const RepliedMessageInfo = ({ onPress, repliedMessage }: IProps) => {
const createStyles = (theme: PartialTheme) =>
StyleSheet.create({
container: {
height: $size(40, 30),
alignItems: 'center',
flexDirection: 'row',
marginLeft: $size(3),

13
src/shared/hooks/use-ids-list.hook.ts

@ -183,6 +183,18 @@ export const useIdsList = <T extends BaseItem, K extends Record<any, any>>( @@ -183,6 +183,18 @@ export const useIdsList = <T extends BaseItem, K extends Record<any, any>>(
if (params.needInit) load({})
}, [])
const loadItems = (params: Record<string, any>, clearPrevItems: boolean = false) => {
loadParams.current = {
...loadParams.current,
...params,
}
if (clearPrevItems)
clear()
load({})
}
return {
items,
loadNew,
@ -194,6 +206,7 @@ export const useIdsList = <T extends BaseItem, K extends Record<any, any>>( @@ -194,6 +206,7 @@ export const useIdsList = <T extends BaseItem, K extends Record<any, any>>(
firstMessageLoaded: listEnd.current.endOld,
_setItems: setItems,
resetList: resetFlatList,
loadItems
}
}

Loading…
Cancel
Save