Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist message history to local storage #346

Merged

Conversation

blaknite
Copy link

@blaknite blaknite commented Nov 13, 2024

@andrewheadricke's work to persist messages to localStorage in #342 piqued my interest so I took a stab at fleshing it out. This feature is requested in issue #162.

I've created a MessageStore class which handles the CRUD operations on messages in localStorage. Each message is stored in a separate localStorage item to facilitate paginated loading on scroll.

What's in the box:

  • Persisting messages to localStorage
  • Updating message state
  • Clearing message history for channels and DMS
  • Initially load 50 messages
  • Load message history on scroll

I have never used zustand and immer so I wasn't sure how to best link this in with the deviceState. I had an issue where the ChannelChat component was not updating with new messages and state changes. To get it functional I resorted to a semaphore on the deviceState which is clearly not the best but it works. Any suggestions on how to improve this would be most welcome!

@CLAassistant
Copy link

CLAassistant commented Nov 13, 2024

CLA assistant check
All committers have signed the CLA.

@rcarteraz
Copy link
Member

This is great! @Hunter275 I'd love to get your take on it.

@Hunter275 Hunter275 changed the base branch from master to message-history November 24, 2024 22:14
@Hunter275 Hunter275 merged commit 9c97f49 into meshtastic:message-history Nov 24, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants