Skip to content

Commit

Permalink
Clean up unseen UI hints
Browse files Browse the repository at this point in the history
  • Loading branch information
rottabonus committed May 26, 2024
1 parent 447ac73 commit 649426b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
16 changes: 2 additions & 14 deletions src/Screens/Main/Chat/MessageList/MemoizedRenderItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import * as RN from 'react-native';

import Message, { MessageProps } from './Message';
import Message from './Message';
import DateBubble from './DateBubble';
import Spinner from 'src/Screens/components/Spinner';
import { Renderable } from '.';
Expand All @@ -27,19 +27,7 @@ const RenderItem: React.FC<Props> = ({ item }) => {
const equalProps = (
prevProps: React.ComponentProps<typeof RenderItem>,
nextProps: React.ComponentProps<typeof RenderItem>,
) => {
if (
Object.prototype.hasOwnProperty.call(nextProps.item, 'isSeen') &&
Object.prototype.hasOwnProperty.call(prevProps.item, 'isSeen')
) {
const prev = prevProps.item as MessageProps;
const next = nextProps.item as MessageProps;

return prev.id === next.id && prev.isSeen === next.isSeen;
}

return prevProps.item.id === nextProps.item.id;
};
) => prevProps.item.id === nextProps.item.id;

export const MemoizedRenderItem = React.memo(RenderItem, equalProps);

Expand Down
6 changes: 1 addition & 5 deletions src/Screens/Main/Chat/MessageList/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ const Message = ({ value: message }: MessageProps) => {
const bubbleStyle =
type === 'Received' ? styles.leftBubble : styles.rightBubble;

// TODO: Visual aid, remove this after review
const isSeenBorder = type === 'Received' &&
!message.isSeen && { borderWidth: 2, borderColor: colors.orangeLight };

const addZero = (n: number) => (n < 10 ? `0${n}` : `${n}`);
const date = new Date(sentTime);
const hours = addZero(date.getHours());
const minutes = addZero(date.getMinutes());
const timeText = `${hours}:${minutes}`;

return (
<RN.View style={[bubbleStyle, isSeenBorder, styles.bubble]}>
<RN.View style={[bubbleStyle, styles.bubble]}>
<RN.View>
<RN.Text style={styles.text}>{content}</RN.Text>
</RN.View>
Expand Down
2 changes: 0 additions & 2 deletions src/Screens/Main/Chat/MessageList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ export const MessageList = ({
const dispatch = useDispatch();

const getPreviousMessagesIfNotLoading = () => {
console.log('messageList.length', messageList.length);

if (isLoading || messageList.length < messageApi.MAX_MESSAGES_AT_ONCE) {
return;
}
Expand Down

0 comments on commit 649426b

Please sign in to comment.