Skip to content

Commit

Permalink
Merge pull request #2707 from GetStream/develop
Browse files Browse the repository at this point in the history
Next Release
  • Loading branch information
khushal87 authored Oct 14, 2024
2 parents 28b4198 + dbfc01e commit 6d0a8a8
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ index.android.bundle
*.app
*.DSYM.zip
**/metrics/

#docusaurus
docusaurus/shared
7 changes: 6 additions & 1 deletion .styles/Vocab/Base/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ RNCLI
CDNs
haptics
async
Podfile
Podfile
boolean
Async
subscribable
memoizing
Boolean
2 changes: 1 addition & 1 deletion docusaurus/docs/reactnative/basics/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ useEffect(() => {
}, [setTopInset, finalHeaderHeight]);
```

This can also be passed to the `topInset` prop of of `OverlayProvider`.
This can also be passed to the `topInset` prop of `OverlayProvider`.

It is important to note that since Expo 38 `true` is the default for transparent on Android.

Expand Down
27 changes: 11 additions & 16 deletions docusaurus/docs/reactnative/contexts/message-input-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,15 @@ const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();

<SendMessage />

{/* ### setInputRef */}

{/* ### setQuotedMessageState */}
[//]: # '### setInputRef'
[//]: # '### setQuotedMessageState'

### `appendText`

<AppendText />

{/* ### asyncIds */}

{/* ### asyncUploads */}
[//]: # '### asyncIds'
[//]: # '### asyncUploads'

### closeAttachmentPicker

Expand Down Expand Up @@ -290,9 +288,8 @@ const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();

<NumberOfUploads />

{/* ### onChange */}

{/* ### onSelectItem */}
[//]: # '### onChange'
[//]: # '### onSelectItem'

### openAttachmentPicker

Expand All @@ -314,7 +311,7 @@ const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();

<PickAndUploadImageFromNativePicker />

{/* ### pickFile */}
[//]: # '### pickFile'

### `removeFile`

Expand All @@ -332,17 +329,15 @@ const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();

<SelectedPicker />

{/* ### sending */}

{/* ### sendMessageAsync */}
[//]: # '### sending'
[//]: # '### sendMessageAsync'

### sendThreadMessageInChannel

<SendThreadMessageInChannel />

{/* ### setAsyncIds */}

{/* ### setAsyncUploads */}
[//]: # '### setAsyncIds'
[//]: # '### setAsyncUploads'

### setFileUploads

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You can customize each one of the default actions using props on the [`Channel c

The channel component accepts a prop called `messageActions`. You can use this prop as a callback function to render message actions selectively.

The arguments to this function is an object with all the default message actions as [`MessageAction`](#messageaction) objects. The function should return an array of MessageAction objects to render in a [MessageActionList](../common-content/ui-components/overlay-provider/props/message_action_list.mdx) within the message overlay, that is shown when a user long presses a message in a MessageList.
The arguments to this function is an object with all the default message actions as [`MessageAction`](#messageaction) objects. The function should return an array of MessageAction objects to render in a [MessageActionList](../core-components/overlay-provider.mdx#messageactionlist) within the message overlay, that is shown when a user long presses a message in a MessageList.

You can also customize each one of the default actions using the `messageActions` prop passed to the OverlayProvider as shown in the example below. The OverlayProvider component makes these props available in the `MessageOverlayContext` context.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ const Component3 = ({ userId }: { userId: string }) => {
};
```

3. Break your components down to the smallest reasonable parts that each take care of the apropriate piece of state if it makes sense to do so.
3. Break your components down to the smallest reasonable parts that each take care of the appropriate piece of state if it makes sense to do so.

### Accessing Reactive State

Expand Down Expand Up @@ -344,7 +344,7 @@ thread?.state.getLatestValue(/*...*/);

#### useStateStore Hook

For the ease of use - the React SDK comes with the appropriate state acesss hook which wraps `SimpleStateStore.subscribeWithSelector` API for the React-based applications.
For the ease of use - the React SDK comes with the appropriate state access hook which wraps `SimpleStateStore.subscribeWithSelector` API for the React-based applications.

```tsx
import { useStateStore } from 'stream-chat-react-native';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You can customize each one of the default actions using props on the [`Channel c

The channel component accepts a prop called `messageActions`. You can use this prop as a callback function to render message actions selectively.

The arguments to this function is an object with all the default message actions as [`MessageAction`](../object-types/message_action.mdx) objects. The function should return an array of MessageAction objects to render in a [MessageActionList](../common-content/core-components/overlay-provider/props/message_action_list.mdx) within the message overlay, that is shown when a user long presses a message in a MessageList.
The arguments to this function is an object with all the default message actions as [`MessageAction`](../object-types/message_action.mdx) objects. The function should return an array of MessageAction objects to render in a [MessageActionList](../core-components/overlay_provider.mdx#messageactionlist) within the message overlay, that is shown when a user long presses a message in a MessageList.

You can also customize each one of the default actions using the `messageActions` prop passed to the OverlayProvider as shown in the example below. The OverlayProvider component makes these props available in the `MessageOverlayContext` context.

Expand Down
1 change: 0 additions & 1 deletion docusaurus/shared

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Alert, ImageBackground, Platform, StyleSheet, Text, View } from 'react-
import { TouchableOpacity } from '@gorhom/bottom-sheet';
import { lookup } from 'mime-types';

import { useTranslationContext } from '../../../contexts';
import { AttachmentPickerContextValue } from '../../../contexts/attachmentPickerContext/AttachmentPickerContext';
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
import { useViewport } from '../../../hooks/useViewport';
Expand Down Expand Up @@ -39,6 +40,7 @@ const AttachmentVideo = (props: AttachmentVideoProps) => {
setSelectedFiles,
} = props;
const { vw } = useViewport();
const { t } = useTranslationContext();

const {
theme: {
Expand Down Expand Up @@ -76,7 +78,7 @@ const AttachmentVideo = (props: AttachmentVideoProps) => {

const updateSelectedFiles = async () => {
if (numberOfUploads >= maxNumberOfFiles) {
Alert.alert('Maximum number of files reached');
Alert.alert(t('Maximum number of files reached'));
return;
}
const files = await patchVideoFile(selectedFiles);
Expand Down Expand Up @@ -143,6 +145,7 @@ const AttachmentImage = (props: AttachmentImageProps) => {
},
} = useTheme();
const { vw } = useViewport();
const { t } = useTranslationContext();

const size = vw(100) / (numberOfAttachmentPickerImageColumns || 3) - 2;

Expand All @@ -165,7 +168,7 @@ const AttachmentImage = (props: AttachmentImageProps) => {

const updateSelectedImages = async () => {
if (numberOfUploads >= maxNumberOfFiles) {
Alert.alert('Maximum number of files reached');
Alert.alert(t('Maximum number of files reached'));
return;
}
const images = await patchImageFile(selectedImages);
Expand Down
8 changes: 8 additions & 0 deletions package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,14 @@ const ChannelWithContext = <
) {
loadChannelAtFirstUnreadMessage();
}
// If the messageId is undefined and the last message and the current message id do not match we load the channel at the very bottom.
else if (
channel.state.messages?.[channel.state.messages.length - 1]?.id !==
channel.state.latestMessages?.[channel.state.latestMessages.length - 1]?.id &&
!messageId
) {
await loadChannel();
}
};

initChannel();
Expand Down
1 change: 1 addition & 0 deletions package/src/components/ChannelList/ChannelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export const ChannelList = <

useUserPresence({
setChannels,
setForceUpdate,
});

const channelIdsStr = channels?.reduce((acc, channel) => `${acc}${channel.cid}`, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
{
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
setForceUpdate: React.Dispatch<React.SetStateAction<number>>;
};

export const useUserPresence = <
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
>({
setChannels,
setForceUpdate,
}: Parameters<StreamChatGenerics>) => {
const { client } = useChatContext<StreamChatGenerics>();

Expand All @@ -33,6 +35,7 @@ export const useUserPresence = <

return [...newChannels];
});
setForceUpdate((u) => u + 1);
};

const listeners = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';

import type { Channel, StreamChat } from 'stream-chat';

import { useChannelsContext } from '../../../contexts';
import { useChatContext } from '../../../contexts/chatContext/ChatContext';

import type { DefaultStreamChatGenerics } from '../../../types/types';
Expand Down Expand Up @@ -37,6 +38,7 @@ export const useChannelPreviewDisplayPresence = <
channel: Channel<StreamChatGenerics>,
) => {
const { client } = useChatContext<StreamChatGenerics>();
const { forceUpdate } = useChannelsContext<StreamChatGenerics>();

const currentUserId = client.userID;
const members = Object.values(channel.state.members).filter(
Expand All @@ -48,8 +50,7 @@ export const useChannelPreviewDisplayPresence = <

useEffect(() => {
setDisplayPresence(getChannelPreviewDisplayPresence(channel, client));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [channelMemberOnline]);
}, [channel, channelMemberOnline, client, forceUpdate]);

return displayPresence;
};
14 changes: 13 additions & 1 deletion package/src/contexts/messageInputContext/MessageInputContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,19 @@ export const MessageInputProvider = <
],
);
}

// RN CLI
if (numberOfUploads >= value.maxNumberOfFiles) {
Alert.alert(t('Maximum number of files reached'));
return;
}

if (result.assets && result.assets.length > 0) {
// Expo
if (result.assets.length > value.maxNumberOfFiles) {
Alert.alert(t('Maximum number of files reached'));
return;
}
result.assets.forEach(async (asset) => {
if (asset.type.includes('image')) {
await uploadNewImage(asset);
Expand Down Expand Up @@ -746,7 +758,7 @@ export const MessageInputProvider = <
}

if (numberOfUploads >= value.maxNumberOfFiles) {
Alert.alert('Maximum number of files reached');
Alert.alert(t('Maximum number of files reached'));
return;
}

Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Loading messages...",
"Loading threads...": "Loading threads...",
"Loading...": "Loading...",
"Maximum number of files reached": "Maximum number of files reached",
"Message Reactions": "Message Reactions",
"Message deleted": "Message deleted",
"Message flagged": "Message flagged",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Cargando mensajes...",
"Loading threads...": "Cargando hilos...",
"Loading...": "Cargando...",
"Maximum number of files reached": "Número máximo de archivos alcanzado",
"Message Reactions": "Reacciones al mensaje",
"Message deleted": "Mensaje eliminado",
"Message flagged": "Mensaje reportado",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Chargement des messages...",
"Loading threads...": "Chargement des fils...",
"Loading...": "Chargement...",
"Maximum number of files reached": "Nombre maximal de fichiers atteint",
"Message Reactions": "Réactions aux messages",
"Message deleted": "Message supprimé",
"Message flagged": "Message signalé",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "ההודעות בטעינה..",
"Loading threads...": "טוען שרשורים...",
"Loading...": "טוען...",
"Maximum number of files reached": "הגעת למספר המרבי של קבצים",
"Message Reactions": "תגובות להודעה",
"Message deleted": "ההודעה נמחקה",
"Message flagged": "ההודעה סומנה",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "मेसेजस लोड हो रहे हैं...",
"Loading threads...": "थ्रेड्स लोड हो रहे हैं...",
"Loading...": "लोड हो रहा है...",
"Maximum number of files reached": "फ़ाइलों की अधिकतम संख्या पहुँच गई",
"Message Reactions": "संदेश प्रतिक्रियाएँ",
"Message deleted": "मैसेज हटा दिया गया",
"Message flagged": "संदेश को ध्वजांकित किया गया",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Caricamento messaggi...",
"Loading threads...": "Caricamento dei thread...",
"Loading...": "Caricamento...",
"Maximum number of files reached": "Numero massimo di file raggiunto",
"Message Reactions": "Reazioni ai Messaggi",
"Message deleted": "Messaggio cancellato",
"Message flagged": "Messaggio contrassegnato",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "メッセージを読み込み中。。。",
"Loading threads...": "スレッドを読み込み中...",
"Loading...": "読み込み中。。。",
"Maximum number of files reached": "ファイルの最大数に達しました",
"Message Reactions": "メッセージのリアクション",
"Message deleted": "メッセージが削除されました",
"Message flagged": "メッセージにフラグが付けられました",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "메시지를 로딩 중...",
"Loading threads...": "스레드 로딩 중...",
"Loading...": "로딩 중...",
"Maximum number of files reached": "최대 파일 수에 도달했습니다",
"Message Reactions": "메시지의 리액션",
"Message deleted": "메시지가 삭제되었습니다.",
"Message flagged": "메시지에 플래그가 지정되었습니다",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Berichten aan het laden...",
"Loading threads...": "Threads laden...",
"Loading...": "Aan het laden...",
"Maximum number of files reached": "Maximaal aantal bestanden bereikt",
"Message Reactions": "Bericht Reacties",
"Message deleted": "Bericht verwijderd",
"Message flagged": "Bericht gemarkeerd",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Carregando mensagens...",
"Loading threads...": "Carregando tópicos...",
"Loading...": "Carregando...",
"Maximum number of files reached": "Número máximo de arquivos atingido",
"Message Reactions": "Reações à Mensagem",
"Message deleted": "Mensagem excluída",
"Message flagged": "Mensagem sinalizada",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Загружаю сообщения...",
"Loading threads...": "Загрузка потоков...",
"Loading...": "Загружаю...",
"Maximum number of files reached": "Достигнуто максимальное количество файлов",
"Message Reactions": "Сообщения Реакции",
"Message deleted": "Сообщение удалено",
"Message flagged": "Сообщение отмечено",
Expand Down
1 change: 1 addition & 0 deletions package/src/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Loading messages...": "Mesajlar yükleniyor...",
"Loading threads...": "Akışlar yükleniyor...",
"Loading...": "Yükleniyor...",
"Maximum number of files reached": "Maksimum dosya sayısına ulaşıldı",
"Message Reactions": "Mesaj Tepkileri",
"Message deleted": "Mesaj silindi",
"Message flagged": "Mesaj işaretlendi",
Expand Down

0 comments on commit 6d0a8a8

Please sign in to comment.