Skip to content

Commit

Permalink
feat: add setting for close message context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Apr 14, 2024
1 parent a02ad80 commit 0107edf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/shared/i18n/langs/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
"kbe20d511": "The user information was not found, there may be some exceptions",
"kbef193d": "Invitation link copied to clipboard",
"kbef5b92e": "Copy Link",
"kbf38b110": "Close message context menu",
"kc14b2ea3": "Back",
"kc161f3a6": "1 hour",
"kc1a5303e": "Panel-based group space, highly customizable",
Expand Down
1 change: 1 addition & 0 deletions client/shared/i18n/langs/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
"kbe20d511": "没有找到该用户信息, 可能出现了一些异常",
"kbef193d": "邀请链接已复制到剪切板",
"kbef5b92e": "复制链接",
"kbf38b110": "关闭消息右键菜单",
"kc14b2ea3": "返回",
"kc161f3a6": "1小时",
"kc1a5303e": "基于面板的群组空间, 可高度自定义化",
Expand Down
5 changes: 5 additions & 0 deletions client/shared/model/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export interface UserSettings {
*/
groupOrderList?: string[];

/**
* 是否关闭消息右键菜单
*/
disableMessageContextMenu?: boolean;

/**
* 其他的设置项
*/
Expand Down
3 changes: 3 additions & 0 deletions client/web/src/components/ChatBox/ChatMessageList/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
showMessageTime,
useUserInfoList,
UserBaseInfo,
useUserSettings,
} from 'tailchat-shared';
import { useRenderPluginMessageInterpreter } from './useRenderPluginMessageInterpreter';
import { getMessageRender, pluginMessageExtraParsers } from '@/plugin/common';
Expand Down Expand Up @@ -66,6 +67,7 @@ export const NormalMessage: React.FC<ChatMessageItemProps> = React.memo(
const { showAvatar, payload, hideAction = false } = props;
const userInfo = useCachedUserInfo(payload.author ?? '');
const [isActionBtnActive, setIsActionBtnActive] = useState(false);
const { settings } = useUserSettings();

const reactions = useMessageReactions(payload);

Expand Down Expand Up @@ -124,6 +126,7 @@ export const NormalMessage: React.FC<ChatMessageItemProps> = React.memo(
menu={moreActions}
placement="bottomLeft"
trigger={['contextMenu']}
disabled={settings['disableMessageContextMenu']}
onOpenChange={setIsActionBtnActive}
>
<div
Expand Down
14 changes: 14 additions & 0 deletions client/web/src/components/modals/SettingsView/System.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ export const SettingsSystem: React.FC = React.memo(() => {
}
/>

<FullModalField
title={t('关闭消息右键菜单')}
content={
<Switch
checked={settings['disableMessageContextMenu'] ?? false}
onChange={(checked) =>
setSettings({
disableMessageContextMenu: checked,
})
}
/>
}
/>

{pluginSettings
.filter((item) => item.position === 'system')
.map((item) => {
Expand Down

0 comments on commit 0107edf

Please sign in to comment.