Bug: Unused media visibility check and missing useMemo dependencies cause stale/invalid actions in MessageToolbox.js

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

维护者通常 1 天内回复

@yashsarvaiya45 已经在做这个了。

开始于 2026年11月17日。

  • #1438 来自 @yashsarvaiya45 —— 未关闭

评估

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

调研方向

从 packages/react/src/views/Message/MessageToolbox.js 开始,重点检查可见性判断、options useMemo 依赖数组以及 surfaceOptions 映射。确认音频和视频消息的编辑与复制操作应如何表现,以及活动编辑状态如何表示。修复报告的三个问题,并确保权限加载时工具箱操作能够正确更新,即为完成。

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

描述

Description

In packages/react/src/views/Message/MessageToolbox.js, there are three bugs affecting message action visibility and state updates:

  1. Unused isVisibleForMessageType check & missing optional chaining: isVisibleForMessageType is computed on lines 93–95 to hide text-only actions (edit and copy) on audio/mpeg and video/mp4 messages, but it is never applied to options.edit.visible or options.copy.visible. Additionally, message.files?.[0].type lacks optional chaining on [0], which can throw a TypeError when message.files is an empty array [].
  2. Stale useMemo dependencies for role permissions: The options useMemo hook omits isAllowedToEditMessage, canDeleteMessage, isAllowedToReport, isVisibleForMessageType, and handleCopyMessageLink from its dependency array. When user roles and permissions load asynchronously, the memoized options object fails to recompute, leaving Edit, Delete, and Report actions hidden or stale.
  3. Dropped color and ghost props in surfaceOptions: options.edit defines color and ghost properties to highlight active editing state (isEditing), but surfaceOptions omits these properties when mapping items for SurfaceMenu.
Affected File
  • packages/react/src/views/Message/MessageToolbox.js (lines 93–218)
Expected Behavior
  • Apply isVisibleForMessageType (with safe optional chaining message.files?.[0]?.type) to edit and copy visibility.
  • Include all permission flags and handlers in the options useMemo dependency array so toolbox actions update when roles resolve.
  • Forward color and ghost properties in surfaceOptions.
主要语言
JavaScript
星标
170
派生
397
平均合并
8 天 20 小时
30 天内合并 PR
6

环境准备

  • 没有 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 摘要。