-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from ephemeraHQ/ar/pinned-unread
feat: Unread indicators on Pinned Chats
- Loading branch information
Showing
7 changed files
with
130 additions
and
84 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
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,43 @@ | ||
import { backgroundColor, badgeColor } from "@styles/colors"; | ||
import React, { memo } from "react"; | ||
import { | ||
useColorScheme, | ||
ColorSchemeName, | ||
StyleSheet, | ||
View, | ||
} from "react-native"; | ||
|
||
const IndicatorInner = ({ size }: { size: number }) => { | ||
const styles = getStyles(useColorScheme(), size); | ||
|
||
return ( | ||
<View style={styles.indicator}> | ||
<View style={styles.indicatorInner} /> | ||
</View> | ||
); | ||
}; | ||
|
||
export const Indicator = memo(IndicatorInner); | ||
|
||
const getStyles = (colorScheme: ColorSchemeName, size: number) => | ||
StyleSheet.create({ | ||
indicator: { | ||
position: "absolute", | ||
right: size / 20, | ||
bottom: size / 20, | ||
height: size / 5, | ||
width: size / 5, | ||
backgroundColor: backgroundColor(colorScheme), | ||
alignItems: "center", | ||
justifyContent: "center", | ||
borderRadius: size / 5, | ||
// borderWidth: 2, | ||
// borderColor: backgroundColor(colorScheme), | ||
}, | ||
indicatorInner: { | ||
height: size / 5 - 4, | ||
width: size / 5 - 4, | ||
backgroundColor: badgeColor(colorScheme), | ||
borderRadius: size / 5, | ||
}, | ||
}); |
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,23 @@ | ||
import { TopicsData } from "@data/store/chatStore"; | ||
import { | ||
ConversationWithLastMessagePreview, | ||
LastMessagePreview, | ||
} from "@utils/conversation"; | ||
|
||
export const showUnreadOnConversation = ( | ||
initialLoadDoneOnce: boolean, | ||
lastMessagePreview: LastMessagePreview | undefined, | ||
topicsData: TopicsData, | ||
conversation: ConversationWithLastMessagePreview, | ||
userAddress: string | ||
) => { | ||
if (!initialLoadDoneOnce) return false; | ||
if (!lastMessagePreview) return false; | ||
// Manually marked as unread | ||
if (topicsData[conversation.topic]?.status === "unread") return true; | ||
// If not manually markes as unread, we only show badge if last message | ||
// not from me | ||
if (lastMessagePreview.message.senderAddress === userAddress) return false; | ||
const readUntil = topicsData[conversation.topic]?.readUntil || 0; | ||
return readUntil < lastMessagePreview.message.sent; | ||
}; |