Files
zulip/docs/subsystems/unread_messages.md
David Rosa Tamsen 7072fa5b37 docs: Reorganize developer docs to improve navigation.
This commit helps reduce clutter on the navigation sidebar.
Creates new directories and moves relevant files into them.
Modifies index.rst, symlinks, and image paths accordingly.

This commit also enables expandable/collapsible navigation items,
renames files in docs/development and docs/production,
modifies /tools/test-documentation so that it overrides a theme setting,
Also updates links to other docs, file paths in the codebase that point
to developer documents, and files that should be excluded from lint tests.

Note that this commit does not update direct links to
zulip.readthedocs.io in the codebase; those will be resolved in an
upcoming follow-up commit (it'll be easier to verify all the links
once this is merged and ReadTheDocs is updated).

Fixes #5265.
2017-11-16 09:45:08 -08:00

1.5 KiB

Unread message synchronization

In general displaying unread counts for all streams and topics may require downloading an unbounded number of messages. Consider a user who has a muted stream or topic and has not read the backlog in a month; to have an accurate unread count we would need to load all messages this user has received in the past month. This is inefficient for web clients and even more for mobile devices.

We work around this by including a list of unread message ids in the initial state grouped by relevant conversation keys. This data is included in the unread_msgs key if both update_message_flags and message are required in the register call.

{
    "count": 4,
    "huddles": [
        {
            "user_ids_string": "3,4,6",
            "unread_message_ids": [
                34
            ]
        }
    ],
    "streams": [
        {
            "stream_id": 1,
            "topic": "test",
            "unread_message_ids": [
                33
            ]
        }
    ],
    "pms": [
        {
            "sender_id": 3,
            "unread_message_ids": [
                31,
                32
            ]
        }
    ],
    "mentions": [31, 34]
}

Three event types are required to correctly maintain the unread_msgs. New messages can be created without the unread flag by the message event type. The unread flag can be added and removed by the update_message_flags event, and the subject of unread messages can be updated by the update_message event type.