Skip to content

Commit

Permalink
Merge pull request #10 from AmityCo/feat/asc-22764-show-alert-block-l…
Browse files Browse the repository at this point in the history
…ist-and-link

feat: ASC-22764 - filter out unsynced message from message list
  • Loading branch information
ptchayap authored Aug 5, 2024
2 parents e050916 + 7b44a70 commit f35bf21
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/routes/ChatNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { ChatRoomSetting } from '../screens/ChatDetail/ChatRoomSetting';
import { EditChatRoomDetail } from '../screens/EditChatDetail/EditChatRoomDetail';
import MemberDetail from '../screens/MemberDetail/MemberDetail';
import ChatRoom from '../screens/ChatRoom/ChatRoom';
import useAuth from '../hooks/useAuth';

export default function ChatNavigator() {
const Stack = createNativeStackNavigator<RootStackParamList>();
Expand Down
23 changes: 15 additions & 8 deletions src/screens/ChatRoom/ChatRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,22 @@ const ChatRoom: ChatRoomScreenComponentType = ({ route }) => {
disposers.push(
MessageRepository.getMessages(
{ subChannelId: channelId, limit: 10, includeDeleted: true },
(value) => {
const messages = value.data;

// mark the last message as read
if (messages.length > 0) {
const lastMessage = messages[0];
lastMessage.markRead();
({ data: messages, loading, error }) => {
if (!loading && messages) {
// filter syned message since UIKIT did not support unsync message yet
const syncedMessages = messages.filter(
(message) =>
!message.syncState || message.syncState === 'synced'
);

// mark the last message as read
if (syncedMessages.length > 0) {
const lastMessage = messages[0];
lastMessage.markRead();
}

setMessagesData({ data: syncedMessages, loading, error });
}
setMessagesData(value);
}
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/RecentChat/RecentChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ChatList, {
} from '../../components/ChatList/index';
import useAuth from '../../hooks/useAuth';
import { useEffect, useState } from 'react';
import moment, { locale } from 'moment';
import moment from 'moment';

import { useStyles } from './styles';
import CustomText from '../../components/CustomText';
Expand Down

0 comments on commit f35bf21

Please sign in to comment.