Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[![NPM](https://img.shields.io/npm/v/stream-chat-react-native.svg)](https://www.npmjs.com/package/stream-chat-react-native)
[![Build Status](https://github.com/GetStream/stream-chat-react-native/actions/workflows/release.yml/badge.svg)](https://github.com/GetStream/stream-chat-react-native/actions)
[![Component Reference](https://img.shields.io/badge/docs-component%20reference-blue.svg)](https://getstream.io/chat/docs/sdk/reactnative)
![JS Bundle Size](https://img.shields.io/badge/js_bundle_size-290%20KB-blue)
![JS Bundle Size](https://img.shields.io/badge/js_bundle_size-291%20KB-blue)

<img align="right" src="https://getstream.imgix.net/images/ios-chat-tutorial/[email protected]?auto=format,enhance" width="50%" />

Expand Down
10 changes: 8 additions & 2 deletions examples/ExpoMessaging/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Alert, Image, Pressable, StyleSheet, View } from 'react-native';
import { ChannelList } from 'stream-chat-expo';
import { ChannelList, SqliteClient } from 'stream-chat-expo';
import { useCallback, useContext, useMemo } from 'react';
import { Stack, useRouter } from 'expo-router';
import { ChannelSort } from 'stream-chat';
Expand All @@ -19,7 +19,13 @@ const LogoutButton = () => {
const onLogoutHandler = useCallback(() => {
Alert.alert('Logout', 'Are you sure you want to logout?', [
{ text: 'Cancel', style: 'cancel' },
{ text: 'Logout', onPress: logOut },
{
text: 'Logout',
onPress: () => {
SqliteClient.resetDB();
logOut();
},
},
]);
}, [logOut]);

Expand Down
2 changes: 1 addition & 1 deletion examples/ExpoMessaging/components/ChatWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const ChatWrapper = ({ children }: PropsWithChildren<{}>) => {

return (
<OverlayProvider i18nInstance={streami18n} value={{ style: theme }}>
<Chat client={chatClient} i18nInstance={streami18n}>
<Chat client={chatClient} i18nInstance={streami18n} enableOfflineSupport>
{children}
</Chat>
</OverlayProvider>
Expand Down
24 changes: 23 additions & 1 deletion examples/SampleApp/src/utils/messageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Alert } from 'react-native';
import { StreamChat } from 'stream-chat';
import {
Colors,
Delete,
messageActions,
MessageActionsParams,
Time,
Expand All @@ -20,7 +21,7 @@ export function channelMessageActions({
t: TranslationContextValue['t'];
colors?: typeof Colors;
}) {
const { dismissOverlay } = params;
const { dismissOverlay, deleteForMeMessage } = params;
const actions = messageActions(params);

// We cannot use the useMessageReminder hook here because it is a hook.
Expand Down Expand Up @@ -88,6 +89,27 @@ export function channelMessageActions({
title: reminder ? 'Remove Reminder' : 'Remind Me',
icon: <Bell height={24} width={24} />,
});
actions.push({
action: async () => {
Alert.alert('Delete for me', 'Are you sure you want to delete this message for me?', [
{
text: 'Cancel',
style: 'cancel',
},
{
text: 'Delete',
onPress: async () => {
await deleteForMeMessage?.action();
dismissOverlay();
},
style: 'destructive',
},
]);
},
actionType: 'deleteForMe',
icon: <Delete fill={colors?.accent_red} size={24} />,
title: t('Delete for me'),
});

return actions;
}
2 changes: 1 addition & 1 deletion examples/TypeScriptMessaging/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3248,4 +3248,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 6b7a4b74915b42bfe4ffddaf67cbf5e7a2bfeab3

COCOAPODS: 1.16.2
COCOAPODS: 1.14.3
19 changes: 14 additions & 5 deletions examples/TypeScriptMessaging/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2734,6 +2734,15 @@ available-typed-arrays@^1.0.7:
dependencies:
possible-typed-array-names "^1.0.0"

axios@^1.12.2:
version "1.12.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.12.2.tgz#6c307390136cf7a2278d09cec63b136dfc6e6da7"
integrity sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.4"
proxy-from-env "^1.1.0"

axios@^1.6.0:
version "1.7.9"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.9.tgz#d7d071380c132a24accda1b2cfc1535b79ec650a"
Expand Down Expand Up @@ -7319,14 +7328,14 @@ [email protected]:
version "0.0.0"
uid ""

stream-chat@^9.17.0:
version "9.17.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.17.0.tgz#540cf1ea03b08a394d6140696aae8528e9ba9ce2"
integrity sha512-ys6K73wIVWs5+qsfPJ9wumEUtgbMXYVbH1dhmAZ1oYtQ01dY/avsvt25PYDakVjKeyrnT+y8T/xEzfeF/WDJsg==
stream-chat@^9.23.0:
version "9.24.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.24.0.tgz#e6af5d4b0eb396e24e0ab7f852719581c39f18bc"
integrity sha512-zLtguYRqxeEc/Cjw8Zp00u/wTrqFg4gFPKdj3mvl/Jq1Pt95mY9nMc38KW0GOu/2quIAAar0NNMq8fsXl4jupQ==
dependencies:
"@types/jsonwebtoken" "^9.0.8"
"@types/ws" "^8.5.14"
axios "^1.6.0"
axios "^1.12.2"
base64-js "^1.5.1"
form-data "^4.0.4"
isomorphic-ws "^5.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let FileSystem;

try {
FileSystem = require('expo-file-system');
FileSystem = require('expo-file-system/legacy');
} catch (e) {
// do nothing
}
Expand Down
4 changes: 3 additions & 1 deletion package/expo-package/src/optionalDependencies/pickImage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Platform } from 'react-native';
import { PickImageOptions } from 'stream-chat-react-native-core';
let ImagePicker;

try {
Expand All @@ -14,7 +15,7 @@ if (!ImagePicker) {
}

export const pickImage = ImagePicker
? async () => {
? async ({ maxNumberOfFiles }: PickImageOptions = {}) => {
try {
let permissionGranted = true;
if (Platform.OS === 'ios') {
Expand All @@ -35,6 +36,7 @@ export const pickImage = ImagePicker
allowsMultipleSelection: true,
mediaTypes: ['images', 'videos'],
preferredAssetRepresentationMode: 'current',
selectionLimit: maxNumberOfFiles,
});

const canceled = result.canceled;
Expand Down
2 changes: 1 addition & 1 deletion package/expo-package/src/optionalDependencies/saveFile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let FileSystem;

try {
FileSystem = require('expo-file-system');
FileSystem = require('expo-file-system/legacy');
} catch (e) {
// do nothing
}
Expand Down
4 changes: 3 additions & 1 deletion package/native-package/src/optionalDependencies/pickImage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Platform } from 'react-native';
import { PickImageOptions } from 'stream-chat-react-native-core';
let ImagePicker;

try {
Expand All @@ -8,11 +9,12 @@ try {
}

export const pickImage = ImagePicker
? async () => {
? async ({ maxNumberOfFiles }: PickImageOptions = {}) => {
try {
const result = await ImagePicker.launchImageLibrary({
assetRepresentationMode: 'current',
mediaType: 'mixed',
selectionLimit: maxNumberOfFiles,
});
const canceled = result.didCancel;
const errorCode = result.errorCode;
Expand Down
26 changes: 21 additions & 5 deletions package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Channel as ChannelClass,
ChannelState,
Channel as ChannelType,
DeleteMessageOptions,
EventHandler,
LocalMessage,
localMessageToNewMessagePayload,
Expand Down Expand Up @@ -259,7 +260,9 @@ const debounceOptions = {
};

export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
Partial<Pick<AttachmentPickerContextValue, 'bottomInset' | 'topInset'>> &
Partial<
Pick<AttachmentPickerContextValue, 'bottomInset' | 'topInset' | 'disableAttachmentPicker'>
> &
Partial<
Pick<
AttachmentPickerProps,
Expand Down Expand Up @@ -324,6 +327,7 @@ export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
| 'handleBan'
| 'handleCopy'
| 'handleDelete'
| 'handleDeleteForMe'
| 'handleEdit'
| 'handleFlag'
| 'handleMarkUnread'
Expand Down Expand Up @@ -556,6 +560,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
customMessageSwipeAction,
DateHeader = DateHeaderDefault,
deletedMessagesVisibilityType = 'always',
disableAttachmentPicker = !isImageMediaLibraryAvailable(),
disableKeyboardCompatibleView = false,
disableTypingIndicator,
dismissKeyboardOnMessageTouch = true,
Expand All @@ -582,6 +587,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
handleBan,
handleCopy,
handleDelete,
handleDeleteForMe,
handleEdit,
handleFlag,
handleMarkUnread,
Expand Down Expand Up @@ -1515,7 +1521,15 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
});

const deleteMessage: MessagesContextValue['deleteMessage'] = useStableCallback(
async (message, hardDelete = false) => {
async (message, optionsOrHardDelete = false) => {
let options: DeleteMessageOptions = {};
if (typeof optionsOrHardDelete === 'boolean') {
options = optionsOrHardDelete ? { hardDelete: true } : {};
} else if (optionsOrHardDelete?.deleteForMe) {
options = { deleteForMe: true };
} else if (optionsOrHardDelete?.hardDelete) {
options = { hardDelete: true };
}
if (!channel.id) {
throw new Error('Channel has not been initialized yet');
}
Expand All @@ -1534,7 +1548,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =

threadInstance?.upsertReplyLocally({ message: updatedMessage });

const data = await client.deleteMessage(message.id, hardDelete);
const data = await client.deleteMessage(message.id, options);

if (data?.message) {
updateMessage({ ...data.message });
Expand Down Expand Up @@ -1679,10 +1693,11 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
bottomInset,
bottomSheetRef,
closePicker: () => closePicker(bottomSheetRef),
disableAttachmentPicker,
openPicker: () => openPicker(bottomSheetRef),
topInset,
}),
[bottomInset, bottomSheetRef, closePicker, openPicker, topInset],
[bottomInset, bottomSheetRef, closePicker, openPicker, topInset, disableAttachmentPicker],
);

const ownCapabilitiesContext = useCreateOwnCapabilitiesContext({
Expand Down Expand Up @@ -1845,6 +1860,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
handleBan,
handleCopy,
handleDelete,
handleDeleteForMe,
handleEdit,
handleFlag,
handleMarkUnread,
Expand Down Expand Up @@ -1980,7 +1996,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
<MessageComposerProvider value={messageComposerContext}>
<MessageInputProvider value={inputMessageInputContext}>
<View style={{ height: '100%' }}>{children}</View>
{isImageMediaLibraryAvailable() && (
{!disableAttachmentPicker && (
<AttachmentPicker ref={bottomSheetRef} {...attachmentPickerProps} />
)}
</MessageInputProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const useCreateMessagesContext = ({
handleBan,
handleCopy,
handleDelete,
handleDeleteForMe,
handleEdit,
handleFlag,
handleMarkUnread,
Expand Down Expand Up @@ -150,6 +151,7 @@ export const useCreateMessagesContext = ({
handleBan,
handleCopy,
handleDelete,
handleDeleteForMe,
handleEdit,
handleFlag,
handleMarkUnread,
Expand Down
2 changes: 1 addition & 1 deletion package/src/components/ImageGallery/ImageGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export const ImageGallery = (props: Props) => {
);

/**
* This transition and scaleX reverse lets use scroll left
* This transition and scaleX reverse lets use scroll right
*/
const pagerStyle = useAnimatedStyle<ImageStyle>(
() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ export const useAnimatedGalleryStyle = ({
{
scale: selected ? scale.value / 8 : oneEighth,
},
{ scaleX: -1 },
{ scaleX: 1 },
],
};
}, [previous, selected]);

const animatedStyles = useAnimatedStyle(() => {
const xScaleOffset = -7 * screenWidth * (0.5 + index);
const xScaleOffset = 7 * screenWidth * (0.5 + index);
const yScaleOffset = -screenHeight * 3.5;
return {
transform: [
{ scaleX: -1 },
{ scaleX: 1 },
{ translateY: yScaleOffset },
{
translateX: -xScaleOffset,
Expand Down
Loading
Loading