Skip to content

queryChannels({ message_limit }) returns history cleared via hide(clearHistory: true) after show() — expected? #1777

Description

@vivek-hilo

Summary

After clearing a 1:1 channel's history for the current user with channel.hide(userId, true) (clearHistory) and then making it visible again with channel.show(userId), a subsequent client.queryChannels(..., { message_limit: N }) returns messages that were created before the hide(clearHistory: true) call. It's unclear whether the per-user history clear is supposed to survive show(), so filing to confirm expected behavior.

Environment

  • stream-chat (JS client): 9.35.1
  • Platform: React Native (also reproducible from the JS client generally)

Steps to reproduce

For a 1:1 messaging channel that already has several messages, acting as the current user:

// 1. Clear history for the current user, then keep the channel visible in the list.
await channel.hide(currentUserId, true); // clearHistory: true
await channel.show(currentUserId);

// 2. Later (e.g. when the channel list mounts), query channels with a message preload:
const channels = await client.queryChannels(
  { type: 'messaging', members: { $in: [currentUserId] }, member_count: 2 },
  {},
  { limit: 30, message_limit: 30 },
);
const ch = channels.find(/* the same channel */);
console.log(ch.state.messages.map(m => m.created_at));

Expected

ch.state.messages contains no messages created before the hide(..., true) call (the history was cleared for this user), or the docs clarify that show() / a subsequent query is expected to restore the previously cleared history.

Actual

ch.state.messages contains the full set of pre-clear messages — every returned message has a created_at earlier than the moment hide(..., true) was called. The cleared history reappears via queryChannels with message_limit.

Notes / questions

  • Is clearHistory: true intended to be a durable per-user boundary, or is it only in effect while the channel remains hidden (i.e., does show() reset it)?
  • If it is meant to be durable, should queryChannels' message_limit preload respect that per-user cleared-history boundary the way a targeted message fetch does?
  • Use case: a "Clear chat" feature that must keep the conversation visible in the list afterward (so show() is required), which is why hide is immediately followed by show.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions