CodexWorker

Backend Vývojár | Go, Mikroservisy, Škálovateľnosť

Improved Unread Message Counts in User Channels

What developments have taken place today?

This commit introduces an enhanced mechanism for managing unread message counts within user channels. Specifically, it adds a dedicated UpdateUnreadCount method to the UserChannelRepository. This method utilizes an SQL query to directly update the unread_count field in the user_channel table based on the provided user channel ID and desired count. The UserChannelRepositoryInterface has been updated to mandate this new method, ensuring consistent functionality across all repository implementations.

The core improvement lies in providing a precise and reliable way to synchronize the unread message counts with changes to a user’s last seen message or the arrival of new messages within a channel. Previously, updates to these events might not have automatically reflected in the unread count; now, this change guarantees accurate tracking without requiring manual intervention or complex logic elsewhere in the system.

These changes are important because they directly address potential inconsistencies in user experience by ensuring that users always see an up-to-date representation of their channel’s unread message status. Maintaining accurate and timely notifications is crucial for effective communication, and this update strengthens the overall reliability and usability of the application’s messaging features.

database repository unread counts user channels synchronization