11import { useMemo } from '../lib/teact/teact' ;
22import { getActions } from '../global' ;
33
4+ import type { ApiChat , ApiTopic , ApiUser } from '../api/types' ;
45import type { MenuItemContextAction } from '../components/ui/ListItem' ;
5- import { type ApiChat , type ApiUser } from '../api/types' ;
66
77import { SERVICE_NOTIFICATIONS_USER_ID } from '../config' ;
88import {
@@ -23,6 +23,7 @@ const useChatContextActions = ({
2323 isSavedDialog,
2424 currentUserId,
2525 isPreview,
26+ topics,
2627 handleDelete,
2728 handleMute,
2829 handleChatFolderChange,
@@ -37,6 +38,7 @@ const useChatContextActions = ({
3738 isSavedDialog ?: boolean ;
3839 currentUserId ?: string ;
3940 isPreview ?: boolean ;
41+ topics ?: Record < number , ApiTopic > ;
4042 handleDelete ?: NoneToVoidFunction ;
4143 handleMute ?: NoneToVoidFunction ;
4244 handleChatFolderChange : NoneToVoidFunction ;
@@ -149,8 +151,9 @@ const useChatContextActions = ({
149151 return compact ( [ actionOpenInNewTab , actionPin , actionAddToFolder , actionMute ] ) as MenuItemContextAction [ ] ;
150152 }
151153
152- const actionMaskAsRead = ( chat . unreadCount || chat . hasUnreadMark )
153- ? { title : lang ( 'MarkAsRead' ) , icon : 'readchats' , handler : ( ) => markChatMessagesRead ( { id : chat . id } ) }
154+ const actionMaskAsRead = (
155+ chat . unreadCount || chat . hasUnreadMark || Object . values ( topics || { } ) . some ( ( { unreadCount } ) => unreadCount )
156+ ) ? { title : lang ( 'MarkAsRead' ) , icon : 'readchats' , handler : ( ) => markChatMessagesRead ( { id : chat . id } ) }
154157 : undefined ;
155158 const actionMarkAsUnread = ! ( chat . unreadCount || chat . hasUnreadMark ) && ! chat . isForum
156159 ? { title : lang ( 'MarkAsUnread' ) , icon : 'unread' , handler : ( ) => markChatUnread ( { id : chat . id } ) }
@@ -181,7 +184,7 @@ const useChatContextActions = ({
181184 } , [
182185 chat , user , canChangeFolder , lang , handleChatFolderChange , isPinned , isInSearch , isMuted , currentUserId ,
183186 handleDelete , handleMute , handleReport , folderId , isSelf , isServiceNotifications , isSavedDialog , deleteTitle ,
184- isPreview ,
187+ isPreview , topics ,
185188 ] ) ;
186189} ;
187190
0 commit comments