Skip to content

feat: implement offline message persistence and refined UI#1096

Open
deepak0x wants to merge 7 commits intoRocketChat:developfrom
deepak0x:feat/offline-message-handling
Open

feat: implement offline message persistence and refined UI#1096
deepak0x wants to merge 7 commits intoRocketChat:developfrom
deepak0x:feat/offline-message-handling

Conversation

@deepak0x
Copy link
Contributor

@deepak0x deepak0x commented Jan 23, 2026

This PR implements robust Offline Message Persistence along with a refined UI for failed message delivery. It ensures that messages sent while offline are not lost, allows users to recover them after a page reload, and provides a clear, intuitive interface for resending or deleting failed attempts.

Closes #1091


Screenshots/Video

Screencast.from.2026-01-23.22-34-23.online-video-cutter.com.mp4

Key Changes

1. Offline Persistence (localStorage)

  • Implemented localStorage-based caching for messages that fail to send.

  • Messages are partitioned by Room ID (rid), ensuring they only reappear in their respective channels.

  • Persisted messages are automatically re-injected into the message store during:

    • Initialization
    • Room switching
  • Added session cleanup logic to wipe offline caches on user logout.


2. Refined Message Sorting

  • Ensures global ordering consistency between:

    • Server-fetched messages
    • Locally recovered offline messages
  • Resend behavior: When a message is resent, its timestamp is updated to the current time, naturally moving it to the bottom of the chat.


3. UX & UI Improvements

  • Offline Indicator: Added a centered red RiWifiOffLine icon for messages that fail to send.

  • Custom Error Menu: Clicking the error icon opens an upward-positioned menu with:

    • Resend
    • Delete

deepak0x and others added 3 commits January 23, 2026 23:52
- Added localStorage-based message persistence partitioned by room ID.
- Implemented robust timestamp-based sorting for consistent message order.
- Added immediate offline detection and send failure handling.
- Introduced RiWifiOffLine icon with upward-opening Resend/Delete menu.
- Ensured resent messages move to the bottom of the chat list.
- Added session cleanup to clear offline messages on logout.
- Applied formatting and linting fixes.
@Spiral-Memory
Copy link
Collaborator

This looks good overall, but I’d prefer the Wi-Fi icon to be more understated - small and subtle, to give it a cleaner, more polished look.

@Spiral-Memory Spiral-Memory added the nudge minor tweaks suggested label Mar 21, 2026
@deepak0x
Copy link
Contributor Author

sure
will fix and commit

@deepak0x
Copy link
Contributor Author

deepak0x commented Mar 24, 2026

Hi @Spiral-Memory, addressed all three review comments:

1. PERSISTENCE_KEY moved globally
Created packages/react/src/lib/constants.js — exports EC_OFFLINE_MESSAGES_KEY. messageStore.js now imports it from there.

2 & 3. Replaced react-icons with built-in icon + made it more understated
Removed RiWifiOffLine from react-icons/ri entirely. Now using <Icon name="error-circle" /> from @embeddedchat/ui-elements — smaller (0.875em), subtle opacity (0.7), uses theme.colors.danger.

Before vs After:

IMG_1822

Please let me know if any further changes are needed!

@deepak0x
Copy link
Contributor Author

Also removed react-icons package entirely from packages/react/package.json — it was the only usage and is now replaced by the built-in icon system. yarn.lock updated accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nudge minor tweaks suggested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Offline Message Handling and Resend/Delete UI

2 participants