Skip to content

Commit

Permalink
fix: prevent stored messages being reset in session storage (#359)
Browse files Browse the repository at this point in the history
Add a "messages.length" check to prevent stored messages being reset when refreshing the page.
  • Loading branch information
hfdem authored Aug 9, 2024
1 parent 358ea92 commit 713f355
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion client/src/pages/messaging/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Chat = () => {
}, [channelID, userId]);

useEffect(() => {
if (LS.get("store-chat-messages")) {
if (LS.get("store-chat-messages") && messages.length > 0) {
SS.set(`chat#${channelID}`, messages);
}
}, [channelID, messages]);
Expand Down

0 comments on commit 713f355

Please sign in to comment.