Skip to content

Fix: Include pinned messages from threads in the main chat interface#854

Closed
smritidoneria wants to merge 9 commits intoRocketChat:developfrom
smritidoneria:pinnedMessage
Closed

Fix: Include pinned messages from threads in the main chat interface#854
smritidoneria wants to merge 9 commits intoRocketChat:developfrom
smritidoneria:pinnedMessage

Conversation

@smritidoneria
Copy link
Contributor

@smritidoneria smritidoneria commented Jan 9, 2025

Brief Title

This pull request addresses the issue where pinned messages in threads do not appear in the main chat interface. The solution involves fetching pinned messages from both the main chat and threads and combining them to ensure they are all displayed in the main chat interface.

Fixes #853

Video/Screenshots

Screen.Recording.2025-01-09.at.9.46.00.PM.mov

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-<pr_number> after approval. Contributors are requested to replace <pr_number> with the actual PR number.

const sortedMessages = messages.sort(
(a, b) => new Date(b.ts) - new Date(a.ts)
);
console.log(sortedMessages);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove log

@smritidoneria
Copy link
Contributor Author

Done

return;
}
const { messages } = await RCInstance.getPinnedMessages();
const sortedMessages = messages.sort(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need sorting, if messages are lot, this will take time right ?

@smritidoneria
Copy link
Contributor Author

Sorting can be time-consuming if there are a large number of pinned messages. However, to maintain consistency with Rocket.Chat, I have implemented sorting since pinned messages in Rocket.Chat are sorted.

Alternatively, we have two other approaches:

Implement pagination to fetch messages dynamically as the user scrolls to the bottom of the interface, ensuring only the required messages are loaded.
Fetch messages directly from the server without sorting them at all.
Which approach do you think would be best, @Spiral-Memory?

@smritidoneria
Copy link
Contributor Author

hey @Spiral-Memory , can you please take a look at this and let me know which approach would be suitable?

github-actions bot added a commit that referenced this pull request Mar 21, 2026
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.

Pinned messages in threads do not appear in the main chat interface

2 participants