[Bug]: File Gallery loses selected file-type filter when new messages arrive

未关闭 适合新手
#1,477 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@PritamMishra065 已经在做这个了。

开始于 2026年12月4日。

  • #1488 来自 @PritamMishra065 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript, react
领域
frontend

调研方向

从 packages/react/src/views/MessageAggregators/FileGallery.js 开始,追踪消息发生变化以及 getAllFiles() 刷新列表时 selectedFilter 的使用方式。添加一个回归测试,覆盖选中某种文件类型时消息列表发生变化的情况。新消息到达后,下拉菜单和显示的文件仍保持同步,即为完成。

由索引模型根据 Issue 内容生成。

描述

bug
Description

The File Gallery does not preserve the selected file-type filter when new messages arrive in the chat.

When the message list updates, FileGallery fetches all files without considering the currently selected filter. As a result, files of other types may appear while the dropdown continues to display the selected file type.

Steps to reproduce
  1. Open EmbeddedChat and navigate to a channel containing different types of file attachments.
  2. Open the Files sidebar.
  3. Select a specific file type, such as Images.
  4. Send or receive a new message in the channel.
  5. Observe the files displayed in the sidebar.
Expected behavior

The File Gallery should preserve the selected file-type filter when new messages arrive and display only files matching the selected type.

Actual behavior

Based on source code inspection, the file list is refreshed without applying the selected filter, potentially displaying files of all types.

Root cause

The useEffect in FileGallery.js calls getAllFiles() with an empty type filter whenever the messages array changes, regardless of the selectedFilter state.

Proposed solution
  • Preserve the selected file-type filter during automatic refreshes.
  • Keep the filter dropdown and displayed file list synchronized.
  • Add regression tests to verify filter persistence.
Relevant file

packages/react/src/views/MessageAggregators/FileGallery.js

Additional context

I would like to work on this issue and submit a PR if the maintainers approve the proposed solution.

主要语言
JavaScript
星标
171
派生
421
平均合并
3 天 6 小时
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RocketChat/EmbeddedChat 的其他 Issue

查看 RocketChat/EmbeddedChat 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。