Skip to content

[CLNP-6719] feat: mark-as-unread #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:

deploy-android:
docker:
- image: cimg/android:2023.10-node
- image: cimg/android:2025.04.1-node
resource_class: xlarge
environment:
APP_VERSION: << pipeline.parameters.version >>
Expand All @@ -109,6 +109,12 @@ jobs:
- save_cache: *save_node_modules_base
- save_cache: *save_node_modules_packages
- run: *create_app_env
- run:
name: Set up trusted certificates
command: |
sudo apt-get update
sudo apt-get install -y ca-certificates
echo 'export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt' >> $BASH_ENV
- run:
name: Create service-account.json
environment:
Expand Down
30 changes: 21 additions & 9 deletions .github/workflows/publish-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,27 @@ jobs:
execute:
runs-on: ubuntu-latest
steps:
- run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: '[${{ github.event.inputs.platform }}] Deploy trigger'
if: ${{github.event.inputs.platform}}
uses: promiseofcake/circleci-trigger-action@v1
with:
user-token: ${{ secrets.CIRCLECI_PERSONAL_API_TOKEN }}
project-slug: sendbird/sendbird-uikit-react-native
branch: ${{ env.BRANCH_NAME }}
payload: '{"platform": "${{ github.event.inputs.platform }}", "version": "${{ github.event.inputs.version }}" }'
- name: Set BRANCH_NAME env
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV

- name: '[${{ github.event.inputs.platform }}] Deploy trigger (CircleCI REST API)'
if: ${{ github.event.inputs.platform }}
env:
CIRCLECI_PERSONAL_API_TOKEN: ${{ secrets.CIRCLECI_PERSONAL_API_TOKEN }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
PLATFORM: ${{ github.event.inputs.platform }}
VERSION: ${{ github.event.inputs.version }}
run: |
curl -u ${CIRCLECI_PERSONAL_API_TOKEN}: \
-X POST "https://circleci.com/api/v2/project/gh/sendbird/sendbird-uikit-react-native/pipeline" \
-H "Content-Type: application/json" \
-d '{
"branch": "'"${BRANCH_NAME}"'",
"parameters": {
"platform": "'"${PLATFORM}"'",
"version": "'"${VERSION}"'"
}
}'

#env:
# CACHE_NODE_MODULES_PATH: |
Expand Down
35 changes: 35 additions & 0 deletions docs-validation/2_features/UnreadMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { StringSet } from '@sendbird/uikit-react-native';

/**
* String resource
* {@link https://sendbird.com/docs/chat/uikit/v3/react-native/features/reactions}
* */
function _stringResource(str: StringSet) {
str.GROUP_CHANNEL.LIST_NEW_LINE;
str.GROUP_CHANNEL.LIST_FLOATING_UNREAD_MSG;
str.LABELS.CHANNEL_MESSAGE_MARK_AS_UNREAD;
}
/** ------------------ **/
// interface StringSet {
// GROUP_CHANNEL: {
// LIST_NEW_LINE: string;
// LIST_FLOATING_UNREAD_MSG: (unreadMessageCount: number) => string;
// };
// }

// interface StringSet {
// LABELS: {
// CHANNEL_MESSAGE_MARK_AS_UNREAD: string;
// };
// }

/** ------------------ **/

/**
* Icon resource
* {@link https://sendbird.com/docs/chat/uikit/v3/react-native/features/reactions#mark-as-unread-icon-resource}
* */
import { Icon } from '@sendbird/uikit-react-native-foundation';

Icon.Assets['mark-as-unread'] = require('your_icons/icon-mark-as-unread.png');
/** ------------------ **/
2 changes: 1 addition & 1 deletion docs-validation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@react-native-firebase/messaging": "^14.7.0",
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.10.0",
"@sendbird/chat": "^4.16.0",
"@sendbird/chat": "^4.19.2",
"date-fns": "^4.1.0",
"react": "18.2.0",
"react-native": "0.74.3",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
]
},
"resolutions": {
"@sendbird/chat": "4.16.5",
"@sendbird/chat": "4.19.2",
"@types/react": "^18"
}
}
2 changes: 1 addition & 1 deletion packages/uikit-chat-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@sendbird/chat": "^4.16.0",
"@sendbird/chat": "^4.19.2",
"react": ">=16.13.1"
},
"react-native-builder-bob": {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const IconAssets = {
'gif': require('./icon-gif.png'),
'info': require('./icon-info.png'),
'leave': require('./icon-leave.png'),
'mark-as-unread': require('./icon-mark-as-unread.png'),
'members': require('./icon-members.png'),
'message': require('./icon-message.png'),
'moderation': require('./icon-moderation.png'),
Expand Down
5 changes: 3 additions & 2 deletions packages/uikit-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@openspacelabs/react-native-zoomable-view": "^2.1.5",
"@sendbird/uikit-chat-hooks": "3.9.6",
"@sendbird/uikit-react-native-foundation": "3.9.6",
"@sendbird/uikit-tools": "0.0.7",
"@sendbird/uikit-tools": "0.0.10",
"@sendbird/uikit-utils": "3.9.6"
},
"devDependencies": {
Expand Down Expand Up @@ -111,7 +111,8 @@
"@react-native-community/netinfo": ">=9.3.0",
"@react-native-documents/picker": ">=10.0.0",
"@react-native-firebase/messaging": ">=14.4.0",
"@sendbird/chat": "^4.16.0",
"@sendbird/chat": "^4.19.2",
"@sendbird/uikit-tools": ">=0.0.10",
"@sendbird/react-native-scrollview-enhancer": "*",
"date-fns": ">=2.28.0",
"expo-av": ">=12.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
import SBUUtils from '../../libs/SBUUtils';
import ChatFlatList from '../ChatFlatList';
import { ReactionAddons } from '../ReactionAddons';
import { UnreadMessagesFloatingProps } from '../UnreadMessagesFloating';

type PressActions = { onPress?: () => void; onLongPress?: () => void; bottomSheetItem?: BottomSheetItem };
type HandleableMessage = SendbirdUserMessage | SendbirdFileMessage;
Expand All @@ -50,6 +51,7 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
channel: T;
messages: SendbirdMessage[];
newMessages: SendbirdMessage[];
unreadFirstMessage?: SendbirdMessage;
searchItem?: { startingPoint: number };

scrolledAwayFromBottom: boolean;
Expand All @@ -68,6 +70,7 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
onResendFailedMessage: (failedMessage: HandleableMessage) => Promise<HandleableMessage | void>;
onPressParentMessage?: (parentMessage: SendbirdMessage, childMessage: HandleableMessage) => void;
onPressMediaMessage?: (message: SendbirdFileMessage, deleteMessage: () => Promise<void>, uri: string) => void;
onPressMarkAsUnreadMessage?: (message: HandleableMessage) => void;

renderMessage: (props: {
focused: boolean;
Expand All @@ -84,14 +87,18 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
enableMessageGrouping: ChannelMessageListProps<T>['enableMessageGrouping'];
bottomSheetItem?: BottomSheetItem;
isFirstItem: boolean;
isFirstUnreadMessage?: boolean;
hideParentMessage?: boolean;
}) => React.ReactElement | null;
renderNewMessagesButton:
| null
| ((props: { visible: boolean; onPress: () => void; newMessages: SendbirdMessage[] }) => React.ReactElement | null);
renderScrollToBottomButton: null | ((props: { visible: boolean; onPress: () => void }) => React.ReactElement | null);
renderUnreadMessagesFloating?: null | ((props: UnreadMessagesFloatingProps) => React.ReactElement | null);
unreadMessagesFloatingProps?: UnreadMessagesFloatingProps;
flatListComponent?: React.ComponentType<FlatListProps<SendbirdMessage>>;
flatListProps?: Omit<FlatListProps<SendbirdMessage>, 'data' | 'renderItem'>;
onViewableItemsChanged?: FlatListProps<SendbirdMessage>['onViewableItemsChanged'];
} & {
ref?: Ref<FlatList<SendbirdMessage>> | undefined;
};
Expand All @@ -108,21 +115,26 @@ const ChannelMessageList = <T extends SendbirdGroupChannel | SendbirdOpenChannel
onResendFailedMessage,
onPressMediaMessage,
onPressParentMessage,
onPressMarkAsUnreadMessage,
currentUserId,
renderUnreadMessagesFloating,
renderNewMessagesButton,
renderScrollToBottomButton,
renderMessage,
messages,
newMessages,
unreadFirstMessage,
enableMessageGrouping,
onScrolledAwayFromBottom,
scrolledAwayFromBottom,
onBottomReached,
onTopReached,
flatListComponent,
flatListProps,
onViewableItemsChanged,
onPressNewMessagesButton,
onPressScrollToBottomButton,
unreadMessagesFloatingProps,
}: ChannelMessageListProps<T>,
ref: React.ForwardedRef<FlatList<SendbirdMessage>>,
) => {
Expand All @@ -139,6 +151,7 @@ const ChannelMessageList = <T extends SendbirdGroupChannel | SendbirdOpenChannel
onDeleteMessage,
onResendFailedMessage,
onPressMediaMessage,
onPressMarkAsUnreadMessage,
});

const renderItem: ListRenderItem<SendbirdMessage> = useFreshCallback(({ item, index }) => {
Expand All @@ -147,6 +160,7 @@ const ChannelMessageList = <T extends SendbirdGroupChannel | SendbirdOpenChannel
message: item,
prevMessage: messages[index + 1],
nextMessage: messages[index - 1],
isFirstUnreadMessage: unreadFirstMessage?.messageId === item.messageId,
onPress,
onLongPress,
onPressParentMessage,
Expand All @@ -166,9 +180,21 @@ const ChannelMessageList = <T extends SendbirdGroupChannel | SendbirdOpenChannel
{channel.isFrozen && (
<ChannelFrozenBanner style={styles.frozenBanner} text={STRINGS.LABELS.CHANNEL_MESSAGE_LIST_FROZEN} />
)}
{renderUnreadMessagesFloating && (
<View
style={[channel.isFrozen ? styles.unreadMsgFloatingWhenFrozen : styles.unreadMsgFloating, safeAreaLayout]}
>
{renderUnreadMessagesFloating({
visible: unreadMessagesFloatingProps?.visible ?? false,
onPressClose: () => unreadMessagesFloatingProps?.onPressClose(),
unreadMessageCount: unreadMessagesFloatingProps?.unreadMessageCount ?? 0,
})}
</View>
)}
<ChatFlatList
flatListComponent={flatListComponent}
{...flatListProps}
onViewableItemsChanged={onViewableItemsChanged}
onTopReached={onTopReached}
onBottomReached={onBottomReached}
onScrolledAwayFromBottom={onScrolledAwayFromBottom}
Expand Down Expand Up @@ -212,6 +238,7 @@ const useCreateMessagePressActions = <T extends SendbirdGroupChannel | SendbirdO
onReplyInThreadMessage,
onDeleteMessage,
onPressMediaMessage,
onPressMarkAsUnreadMessage,
}: Pick<
ChannelMessageListProps<T>,
| 'channel'
Expand All @@ -222,6 +249,7 @@ const useCreateMessagePressActions = <T extends SendbirdGroupChannel | SendbirdO
| 'onDeleteMessage'
| 'onResendFailedMessage'
| 'onPressMediaMessage'
| 'onPressMarkAsUnreadMessage'
>): CreateMessagePressActions => {
const handlers = useSBUHandlers();
const { colors } = useUIKitTheme();
Expand Down Expand Up @@ -281,6 +309,10 @@ const useCreateMessagePressActions = <T extends SendbirdGroupChannel | SendbirdO
}
};

const onMarkAsUnread = (message: HandleableMessage) => {
onPressMarkAsUnreadMessage?.(message);
};

const openSheetForFailedMessage = (message: HandleableMessage) => {
openSheet({
sheetItems: [
Expand Down Expand Up @@ -323,6 +355,11 @@ const useCreateMessagePressActions = <T extends SendbirdGroupChannel | SendbirdO
title: STRINGS.LABELS.CHANNEL_MESSAGE_COPY,
onPress: () => onCopyText(message),
}),
markAsUnread: (message: HandleableMessage) => ({
icon: 'mark-as-unread' as const,
title: STRINGS.LABELS.CHANNEL_MESSAGE_MARK_AS_UNREAD,
onPress: () => onMarkAsUnread(message),
}),
edit: (message: HandleableMessage) => ({
icon: 'edit' as const,
title: STRINGS.LABELS.CHANNEL_MESSAGE_EDIT,
Expand Down Expand Up @@ -356,9 +393,19 @@ const useCreateMessagePressActions = <T extends SendbirdGroupChannel | SendbirdO
if (message.isUserMessage()) {
sheetItems.push(menu.copy(message));
if (!channel.isEphemeral) {
if (isMyMessage(message, currentUserId) && message.sendingStatus === 'succeeded') {
sheetItems.push(menu.edit(message));
sheetItems.push(menu.delete(message));
if (message.sendingStatus === 'succeeded') {
const isMyMsg = isMyMessage(message, currentUserId);
if (isMyMsg) {
sheetItems.push(menu.edit(message));
}

if (channel.isGroupChannel() && sbOptions.uikit.groupChannel.channel.enableMarkAsUnread) {
sheetItems.push(menu.markAsUnread(message));
}

if (isMyMsg) {
sheetItems.push(menu.delete(message));
}
}
if (channel.isGroupChannel()) {
if (sbOptions.uikit.groupChannel.channel.replyType === 'thread' && onReplyInThreadMessage !== undefined) {
Expand All @@ -375,9 +422,16 @@ const useCreateMessagePressActions = <T extends SendbirdGroupChannel | SendbirdO
sheetItems.push(menu.download(message));
}
if (!channel.isEphemeral) {
if (isMyMessage(message, currentUserId) && message.sendingStatus === 'succeeded') {
sheetItems.push(menu.delete(message));
if (message.sendingStatus === 'succeeded') {
if (channel.isGroupChannel() && sbOptions.uikit.groupChannel.channel.enableMarkAsUnread) {
sheetItems.push(menu.markAsUnread(message));
}

if (isMyMessage(message, currentUserId)) {
sheetItems.push(menu.delete(message));
}
}

if (channel.isGroupChannel()) {
if (sbOptions.uikit.groupChannel.channel.replyType === 'thread' && onReplyInThreadMessage !== undefined) {
sheetItems.push(menu.replyInThread(message));
Expand Down Expand Up @@ -446,6 +500,18 @@ const styles = createStyleSheet({
frozenListPadding: {
paddingBottom: 32,
},
unreadMsgFloating: {
position: 'absolute',
zIndex: 999,
top: 12,
alignSelf: 'center',
},
unreadMsgFloatingWhenFrozen: {
position: 'absolute',
zIndex: 999,
top: 40,
alignSelf: 'center',
},
newMsgButton: {
position: 'absolute',
zIndex: 999,
Expand Down
Loading