Skip to content

Commit

Permalink
feat: [useMessages] add resetList method
Browse files Browse the repository at this point in the history
  • Loading branch information
akai committed Apr 14, 2021
1 parent 935d074 commit 5371ea5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/hooks/useMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export default function useMessages(initialState: MessageWithoutId[] = []) {
setMessages((prev) => prev.filter((t) => t._id !== id));
}, []);

const resetList = useCallback((list = []) => {
setMessages(list);
}, []);

const setTyping = useCallback(
(typing: boolean) => {
if (typing === isTypingRef.current) return;
Expand All @@ -83,6 +87,7 @@ export default function useMessages(initialState: MessageWithoutId[] = []) {
appendMsg,
updateMsg,
deleteMsg,
resetList,
setTyping,
};
}

0 comments on commit 5371ea5

Please sign in to comment.