Skip to content

Commit

Permalink
fix: remove deprecated code from v6 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Oct 9, 2024
1 parent f66b4a0 commit 2462b7f
Show file tree
Hide file tree
Showing 36 changed files with 21 additions and 946 deletions.
22 changes: 0 additions & 22 deletions docusaurus/docs/reactnative/contexts/channel-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,6 @@ loadChannelAroundMessage({
| -------- |
| function |

### loadChannelAtMessage

Function to reload channel at particular message in history.

:::caution

This function is deprecated. Use [loadChannelAroundMessage](#loadchannelaroundmessage) instead.

:::

```tsx
loadChannelAtMessage({
before: 10, // Number of messages to load before messageId
after: 10, // Number of messages to load after messageId
messageId,
});
```

| Type |
| -------- |
| function |

### loading

True if channel is loading messages during first load.
Expand Down
48 changes: 0 additions & 48 deletions docusaurus/docs/reactnative/contexts/message-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,54 +90,6 @@ True if one of the following condition is true:

<HandleAction />

### handleDeleteMessage

Callback function for "Delete Message" action.

| Type |
| -------- |
| function |

### handleEditMessage

Callback function for "Edit Message" action.

| Type |
| -------- |
| function |

### handleQuotedReplyMessage

Callback function for "Quoted Reply" action.

| Type |
| -------- |
| function |

### handleResendMessage

Callback function for "Resend Message" (for failed message) action.

| Type |
| -------- |
| function |

### handleToggleBanUser

Callback function for "Ban/Unban User" action.

| Type |
| -------- |
| function |

### handleToggleMuteUser

Callback function for "Mute/Unmute User" action.

| Type |
| -------- |
| function |

### handleToggleReaction

Callback function for toggling reaction from reaction selector.
Expand Down
5 changes: 0 additions & 5 deletions docusaurus/docs/reactnative/contexts/messages-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Gallery from '../common-content/ui-components/channel/props/gallery.mdx';
import Giphy from '../common-content/ui-components/channel/props/giphy.mdx';
import GiphyVersion from '../common-content/ui-components/channel/props/giphy_version.mdx';
import HandleBan from '../common-content/ui-components/channel/props/handle_ban.mdx';
import HandleBlock from '../common-content/ui-components/channel/props/handle_block.mdx';
import HandleCopy from '../common-content/ui-components/channel/props/handle_copy.mdx';
import HandleDelete from '../common-content/ui-components/channel/props/handle_delete.mdx';
import HandleEdit from '../common-content/ui-components/channel/props/handle_edit.mdx';
Expand Down Expand Up @@ -115,10 +114,6 @@ Id of current channel.

<HandleBan />

### <div class="label description">_forwarded from [Channel](../../core-components/channel#handleblock)_ props</div> `handleBlock` {#handleblock}

<HandleBlock />

### <div class="label description">_forwarded from [Channel](../../core-components/channel#handlecopy)_ props</div> `handleCopy` {#handlecopy}

<HandleCopy />
Expand Down
15 changes: 0 additions & 15 deletions docusaurus/docs/reactnative/core-components/channel-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,6 @@ Override for the default Event Listener behavior when a channel is updated. Th
| setChannels | Setter function for the internal channels state |
| event | [Event Object](https://getstream.io/chat/docs/react/event_object/#event-object) corresponding to channel.deleted |

### `onMessageNew`

Override for the default Event Listener behavior when a message is received on a channel that is not being watched. The default behavior adds the channel to the list.

> Warning: This function is deprecated. Use **[`onNewMessageNotification`](#onNewMessageNotification)** instead.
| Type |
| -------- |
| Function |

| Parameter | Description |
| ----------- | ---------------------------------------------------------------------------------------------------------------- |
| setChannels | Setter function for the internal channels state |
| event | [Event Object](https://getstream.io/chat/docs/react/event_object/#event-object) corresponding to channel.deleted |

### **`onNewMessageNotification`**

Override for the default Event Listener behavior when a message is received on a channel that is not being watched. The default behavior adds the channel to the list.
Expand Down
5 changes: 0 additions & 5 deletions docusaurus/docs/reactnative/core-components/channel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import GiphyEnabled from '../common-content/ui-components/channel/props/giphy_en
import GiphyVersion from '../common-content/ui-components/channel/props/giphy_version.mdx';
import HandleAttachButtonPress from '../common-content/ui-components/channel/props/handle_attach_button_press.mdx';
import HandleBan from '../common-content/ui-components/channel/props/handle_ban.mdx';
import HandleBlock from '../common-content/ui-components/channel/props/handle_block.mdx';
import HandleCopy from '../common-content/ui-components/channel/props/handle_copy.mdx';
import HandleDelete from '../common-content/ui-components/channel/props/handle_delete.mdx';
import HandleEdit from '../common-content/ui-components/channel/props/handle_edit.mdx';
Expand Down Expand Up @@ -491,10 +490,6 @@ The max allowable is 255, which when reached displays as `255+`.

<HandleBan />

### `handleBlock`

<HandleBlock />

### `handleCopy`

<HandleCopy />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ Please note that these intercepts will neither change the standard functions nor
:::
- `handleBan`
- `handleBlock`(deprecated)
- `handleCopy`
- `handleDelete`
- `handleEdit`
Expand Down
112 changes: 0 additions & 112 deletions package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1082,28 +1082,6 @@ const ChannelWithContext = <
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [targetedMessage]);

/**
* @deprecated use loadChannelAroundMessage instead
*
* Loads channel at specific message
*
* @param messageId If undefined, channel will be loaded at most recent message.
* @param before Number of message to query before messageId
* @param after Number of message to query after messageId
*/
const loadChannelAtMessage: ChannelContextValue<StreamChatGenerics>['loadChannelAtMessage'] = ({
after = 2,
before = 30,
messageId,
}) =>
channelQueryCallRef.current(async () => {
await queryAtMessage({ after, before, messageId });

if (messageId) {
setTargetedMessage(messageId);
}
});

/**
* Utility method to mark that current set if latest into two.
* With an empty latest set
Expand Down Expand Up @@ -1399,95 +1377,6 @@ const ChannelWithContext = <
setHasNoMoreRecentMessagesToLoad(true);
});

/**
* @deprecated
* Makes a query to load messages at particular message id.
*
* @param messageId Targeted message id
* @param before Number of messages to load before messageId
* @param after Number of messages to load after messageId
*/
const queryAtMessage = async ({
after = 10,
before = 10,
messageId,
}: Parameters<ChannelContextValue<StreamChatGenerics>['loadChannelAtMessage']>[0]) => {
if (!channel) return;
channel.state.setIsUpToDate(false);
hasOverlappingRecentMessagesRef.current = false;
clearInterval(mergeSetsIntervalRef.current);
channel.state.clearMessages();
setMessages([]);
if (!messageId) {
await channel.query({
messages: {
limit: before,
},
watch: true,
});

channel.state.setIsUpToDate(true);
return;
}

await queryBeforeMessage(messageId, before);
await queryAfterMessage(messageId, after);
};

/**
* @deprecated
* Makes a query to load messages before particular message id.
*
* @param messageId Targeted message id
* @param limit Number of messages to load
*/
const queryBeforeMessage = async (messageId: string, limit = 5) => {
if (!channel) return;

await channel.query({
messages: {
id_lt: messageId,
limit,
},
watch: true,
});

channel.state.setIsUpToDate(false);
};

/**
* @deprecated
* Makes a query to load messages later than particular message id.
*
* @param messageId Targeted message id
* @param limit Number of messages to load.
*/
const queryAfterMessage = async (messageId: string, limit = 5) => {
if (!channel) return;
const state = await channel.query({
messages: {
id_gte: messageId,
limit,
},
watch: true,
});

if (state.messages.length < limit) {
// make current set as the latest
const currentSet = channel.state.messageSets.find((set) => set.isCurrent);
if (currentSet && !currentSet.isLatest) {
channel.state.messageSets = channel.state.messageSets.filter((set) => !set.isLatest);
currentSet.isLatest = true;
}
channel.state.setIsUpToDate(true);
setHasNoMoreRecentMessagesToLoad(true);
} else {
splitLatestCurrentMessageSetRef.current();
channel.state.setIsUpToDate(false);
setHasNoMoreRecentMessagesToLoad(false);
}
};

// In case the channel is disconnected which may happen when channel is deleted,
// underlying js client throws an error. Following function ensures that Channel component
// won't result in error in such a case.
Expand Down Expand Up @@ -2209,7 +2098,6 @@ const ChannelWithContext = <
isOwner,
lastRead,
loadChannelAroundMessage,
loadChannelAtMessage,
loading,
LoadingIndicator,
markRead,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const useCreateChannelContext = <
isOwner,
lastRead,
loadChannelAroundMessage,
loadChannelAtMessage,
loading,
LoadingIndicator,
markRead,
Expand Down Expand Up @@ -65,7 +64,6 @@ export const useCreateChannelContext = <
isOwner,
lastRead,
loadChannelAroundMessage,
loadChannelAtMessage,
loading,
LoadingIndicator,
markRead,
Expand Down
17 changes: 0 additions & 17 deletions package/src/components/ChannelList/ChannelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,6 @@ export type ChannelListProps<
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
event: Event<StreamChatGenerics>,
) => void;
/**
* @deprecated use onNewMessageNotification instead
*
* Override the default listener/handler for event `notification.message_new`
* This event is received on channel, which is not being watched.
*
* @param setChannels Setter for internal state property - `channels`. It's created from useState() hook.
* @param event An [Event object](https://getstream.io/chat/docs/event_object) corresponding to `notification.message_new` event
*
* @overrideType Function
* */
onMessageNew?: (
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
event: Event<StreamChatGenerics>,
) => void;
/**
* Override the default listener/handler for event `message.new`
* This event is received on channel, when a new message is added on a channel.
Expand Down Expand Up @@ -262,7 +247,6 @@ export const ChannelList = <
onChannelTruncated,
onChannelUpdated,
onChannelVisible,
onMessageNew,
onNewMessage,
onNewMessageNotification,
onRemovedFromChannel,
Expand Down Expand Up @@ -342,7 +326,6 @@ export const ChannelList = <
});

useNewMessageNotification({
onMessageNew,
onNewMessageNotification,
setChannels,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { getChannel } from '../../utils';
type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
{
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>;
onMessageNew?: (
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
event: Event<StreamChatGenerics>,
) => void;

onNewMessageNotification?: (
setChannels: React.Dispatch<React.SetStateAction<Channel<StreamChatGenerics>[] | null>>,
event: Event<StreamChatGenerics>,
Expand All @@ -25,20 +22,14 @@ type Parameters<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultSt
export const useNewMessageNotification = <
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
>({
onMessageNew,
onNewMessageNotification,
setChannels,
}: Parameters<StreamChatGenerics>) => {
const { client } = useChatContext<StreamChatGenerics>();

useEffect(() => {
const handleEvent = async (event: Event<StreamChatGenerics>) => {
if (typeof onMessageNew === 'function') {
onMessageNew(setChannels, event);
console.warn(
'onMessageNew is deprecated and will be removed in future release. Please use onNewMessageNotification to establish the same behaviour',
);
} else if (typeof onNewMessageNotification === 'function') {
if (typeof onNewMessageNotification === 'function') {
onNewMessageNotification(setChannels, event);
} else {
if (event.channel?.id && event.channel?.type) {
Expand Down
1 change: 1 addition & 0 deletions package/src/components/ImageGallery/ImageGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ const styles = StyleSheet.create({
animatedContainer: {
alignItems: 'center',
flexDirection: 'row',
backgroundColor: 'red',
},
});

Expand Down
Loading

0 comments on commit 2462b7f

Please sign in to comment.