Skip to content

Commit 977ec39

Browse files
fix: adjust ChannelActionContextValue type (#2434)
### 🎯 Goal Adjust `ChannelActionContextValue` type to include new `highlightDuration` parameter, pair the types to the functions so that we don't forget in the future (in case we need to adjust).
1 parent 11e606f commit 977ec39

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/components/Channel/Channel.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,9 @@ const ChannelInner = <
757757

758758
const clearHighlightedMessageTimeoutId = useRef<ReturnType<typeof setTimeout> | null>(null);
759759

760-
const jumpToMessage = useCallback(
760+
const jumpToMessage: ChannelActionContextValue<StreamChatGenerics>['jumpToMessage'] = useCallback(
761761
async (
762-
messageId: string,
762+
messageId,
763763
messageLimit = DEFAULT_JUMP_TO_PAGE_SIZE,
764764
highlightDuration = DEFAULT_HIGHLIGHT_DURATION,
765765
) => {
@@ -794,7 +794,7 @@ const ChannelInner = <
794794
[channel, loadMoreFinished],
795795
);
796796

797-
const jumpToLatestMessage = useCallback(async () => {
797+
const jumpToLatestMessage: ChannelActionContextValue<StreamChatGenerics>['jumpToLatestMessage'] = useCallback(async () => {
798798
await channel.state.loadMessageIntoState('latest');
799799
// FIXME: we cannot rely on constant value 25 as the page size can be customized by integrators
800800
const hasMoreOlder = channel.state.messages.length >= 25;
@@ -804,7 +804,7 @@ const ChannelInner = <
804804
});
805805
}, [channel, loadMoreFinished]);
806806

807-
const jumpToFirstUnreadMessage = useCallback(
807+
const jumpToFirstUnreadMessage: ChannelActionContextValue<StreamChatGenerics>['jumpToFirstUnreadMessage'] = useCallback(
808808
async (
809809
queryMessageLimit = DEFAULT_JUMP_TO_PAGE_SIZE,
810810
highlightDuration = DEFAULT_HIGHLIGHT_DURATION,

src/context/ChannelActionContext.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ export type ChannelActionContextValue<
6868
message: UpdatedMessage<StreamChatGenerics>,
6969
options?: UpdateMessageOptions,
7070
) => Promise<UpdateMessageAPIResponse<StreamChatGenerics> | void>;
71-
jumpToFirstUnreadMessage: (queryMessageLimit?: number) => Promise<void>;
71+
jumpToFirstUnreadMessage: (
72+
queryMessageLimit?: number,
73+
highlightDuration?: number,
74+
) => Promise<void>;
7275
jumpToLatestMessage: () => Promise<void>;
73-
jumpToMessage: (messageId: string, limit?: number) => Promise<void>;
76+
jumpToMessage: (messageId: string, limit?: number, highlightDuration?: number) => Promise<void>;
7477
loadMore: (limit?: number) => Promise<number>;
7578
loadMoreNewer: (limit?: number) => Promise<number>;
7679
loadMoreThread: () => Promise<void>;

0 commit comments

Comments
 (0)