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

Open
#1,777 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
typescript
Domain
api

Research direction

Start by reproducing the sequence with channel.hide(currentUserId, true), channel.show(currentUserId), and client.queryChannels(..., { message_limit: 30 }) using stream-chat 9.35.1. Compare the pre-clear messages returned by ch.state.messages with the intended per-user history boundary, then establish whether show() should preserve clearHistory and whether queryChannels preload should honor it; the issue is done when the behavior is clarified or corrected.

Written by the indexing model from the issue text.

Description

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!

Dominant language
TypeScript
Stars
211
Forks
84
Avg merge
1d 2h
Merged PRs (30d)
89

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GetStream/stream-chat-js

All issues in GetStream/stream-chat-js

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.