Delete Message Modal: Hotfix for delete selected message (#4803)
This commit is contained in:
parent
51e978af60
commit
527e4644e2
@ -17,7 +17,7 @@ import {
|
|||||||
getHasAdminRight,
|
getHasAdminRight,
|
||||||
getPrivateChatUserId,
|
getPrivateChatUserId,
|
||||||
getUserFirstOrLastName, getUserFullName,
|
getUserFirstOrLastName, getUserFullName,
|
||||||
isChatBasicGroup, isChatChannel,
|
isChatBasicGroup,
|
||||||
isChatSuperGroup, isOwnMessage,
|
isChatSuperGroup, isOwnMessage,
|
||||||
isUserId,
|
isUserId,
|
||||||
} from '../../global/helpers';
|
} from '../../global/helpers';
|
||||||
@ -52,7 +52,6 @@ export type OwnProps = {
|
|||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
chat?: ApiChat;
|
chat?: ApiChat;
|
||||||
isChannel?: boolean;
|
|
||||||
isGroup?: boolean;
|
isGroup?: boolean;
|
||||||
isSuperGroup?: boolean;
|
isSuperGroup?: boolean;
|
||||||
sender: ApiPeer | undefined;
|
sender: ApiPeer | undefined;
|
||||||
@ -75,7 +74,6 @@ type StateProps = {
|
|||||||
const DeleteMessageModal: FC<OwnProps & StateProps> = ({
|
const DeleteMessageModal: FC<OwnProps & StateProps> = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
chat,
|
chat,
|
||||||
isChannel,
|
|
||||||
isGroup,
|
isGroup,
|
||||||
isSuperGroup,
|
isSuperGroup,
|
||||||
sender,
|
sender,
|
||||||
@ -226,7 +224,7 @@ const DeleteMessageModal: FC<OwnProps & StateProps> = ({
|
|||||||
: [message!.id];
|
: [message!.id];
|
||||||
if (isSchedule) {
|
if (isSchedule) {
|
||||||
deleteScheduledMessages({ messageIds });
|
deleteScheduledMessages({ messageIds });
|
||||||
} else if (!isOwn && (isChannel || isGroup || isSuperGroup)) {
|
} else if (!isOwn && (chosenSpanOption || chosenDeleteOption || chosenBanOption) && (isGroup || isSuperGroup)) {
|
||||||
if (chosenSpanOption) {
|
if (chosenSpanOption) {
|
||||||
const filteredMessageIdList = filterMessageIdByUserId(chosenSpanOption, messageIdList!);
|
const filteredMessageIdList = filterMessageIdByUserId(chosenSpanOption, messageIdList!);
|
||||||
if (filteredMessageIdList && filteredMessageIdList.length) {
|
if (filteredMessageIdList && filteredMessageIdList.length) {
|
||||||
@ -367,7 +365,7 @@ const DeleteMessageModal: FC<OwnProps & StateProps> = ({
|
|||||||
>
|
>
|
||||||
<div className={buildClassName(styles.mainContainer, 'custom-scroll')}>
|
<div className={buildClassName(styles.mainContainer, 'custom-scroll')}>
|
||||||
{renderHeader()}
|
{renderHeader()}
|
||||||
{(shouldShowAdditionalOptions && !canDeleteForAll && !isSchedule && (isChannel || isGroup || isSuperGroup)) && (
|
{(shouldShowAdditionalOptions && !canDeleteForAll && !isSchedule && (isGroup || isSuperGroup)) && (
|
||||||
<>
|
<>
|
||||||
<p className={styles.actionTitle}>{lang('DeleteAdditionalActions')}</p>
|
<p className={styles.actionTitle}>{lang('DeleteAdditionalActions')}</p>
|
||||||
{renderAdditionalActionOptions()}
|
{renderAdditionalActionOptions()}
|
||||||
@ -438,7 +436,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
&& selectAllowedMessageActions(global, deleteMessageModal.message, threadId)) || {};
|
&& selectAllowedMessageActions(global, deleteMessageModal.message, threadId)) || {};
|
||||||
const adminMembersById = chatFullInfo && chatFullInfo?.adminMembersById;
|
const adminMembersById = chatFullInfo && chatFullInfo?.adminMembersById;
|
||||||
const messageIdList = chat && selectCurrentMessageIds(global, chat.id, threadId!, type!);
|
const messageIdList = chat && selectCurrentMessageIds(global, chat.id, threadId!, type!);
|
||||||
const isChannel = Boolean(chat) && isChatChannel(chat);
|
|
||||||
const isGroup = Boolean(chat) && isChatBasicGroup(chat);
|
const isGroup = Boolean(chat) && isChatBasicGroup(chat);
|
||||||
const isSuperGroup = Boolean(chat) && isChatSuperGroup(chat);
|
const isSuperGroup = Boolean(chat) && isChatSuperGroup(chat);
|
||||||
const sender = deleteMessageModal && chat && deleteMessageModal.message
|
const sender = deleteMessageModal && chat && deleteMessageModal.message
|
||||||
@ -457,7 +454,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
chat,
|
chat,
|
||||||
isChannel,
|
|
||||||
isGroup,
|
isGroup,
|
||||||
isSuperGroup,
|
isSuperGroup,
|
||||||
currentUserId: global.currentUserId,
|
currentUserId: global.currentUserId,
|
||||||
|
|||||||
@ -15,8 +15,7 @@ import {
|
|||||||
getPrivateChatUserId,
|
getPrivateChatUserId,
|
||||||
getUserFirstOrLastName,
|
getUserFirstOrLastName,
|
||||||
getUserFullName,
|
getUserFullName,
|
||||||
isChatBasicGroup,
|
isChatBasicGroup, isChatChannel,
|
||||||
isChatChannel,
|
|
||||||
isChatSuperGroup,
|
isChatSuperGroup,
|
||||||
isUserId,
|
isUserId,
|
||||||
} from '../../global/helpers';
|
} from '../../global/helpers';
|
||||||
@ -60,8 +59,8 @@ export type OwnProps = {
|
|||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
chat?: ApiChat;
|
chat?: ApiChat;
|
||||||
isChannel?: boolean;
|
|
||||||
isGroup?: boolean;
|
isGroup?: boolean;
|
||||||
|
isChannel?: boolean;
|
||||||
isSuperGroup?: boolean;
|
isSuperGroup?: boolean;
|
||||||
selectedMessageIds?: number[];
|
selectedMessageIds?: number[];
|
||||||
canDeleteForAll?: boolean;
|
canDeleteForAll?: boolean;
|
||||||
@ -117,9 +116,12 @@ const DeleteSelectedMessageModal: FC<OwnProps & StateProps> = ({
|
|||||||
const [isAdditionalOptionsVisible, setIsAdditionalOptionsVisible] = useState(false);
|
const [isAdditionalOptionsVisible, setIsAdditionalOptionsVisible] = useState(false);
|
||||||
|
|
||||||
const senderList = useMemo(() => {
|
const senderList = useMemo(() => {
|
||||||
|
if (isChannel) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return selectSendersFromSelectedMessages(getGlobal(), chat);
|
return selectSendersFromSelectedMessages(getGlobal(), chat);
|
||||||
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps
|
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps
|
||||||
}, [chat, isOpen]);
|
}, [chat, isChannel, isOpen]);
|
||||||
|
|
||||||
const isSenderOwner = useMemo(() => {
|
const isSenderOwner = useMemo(() => {
|
||||||
if (!senderList) {
|
if (!senderList) {
|
||||||
@ -245,7 +247,8 @@ const DeleteSelectedMessageModal: FC<OwnProps & StateProps> = ({
|
|||||||
const handleDeleteMessageForSelf = useLastCallback(() => {
|
const handleDeleteMessageForSelf = useLastCallback(() => {
|
||||||
if (isSchedule) {
|
if (isSchedule) {
|
||||||
deleteScheduledMessages({ messageIds: selectedMessageIds! });
|
deleteScheduledMessages({ messageIds: selectedMessageIds! });
|
||||||
} else if (!isSenderOwner && (isChannel || isSuperGroup)) {
|
} else if (!isSenderOwner
|
||||||
|
&& (chosenSpanOption || chosenDeleteOption || chosenBanOption) && (isGroup || isSuperGroup)) {
|
||||||
if (chosenSpanOption) {
|
if (chosenSpanOption) {
|
||||||
const userIdList = chosenSpanOption.filter((option) => !Number.isNaN(Number(option)));
|
const userIdList = chosenSpanOption.filter((option) => !Number.isNaN(Number(option)));
|
||||||
const filteredMessageIdList = filterMessageIdByUserId(userIdList, selectedMessageIds!);
|
const filteredMessageIdList = filterMessageIdByUserId(userIdList, selectedMessageIds!);
|
||||||
@ -392,7 +395,7 @@ const DeleteSelectedMessageModal: FC<OwnProps & StateProps> = ({
|
|||||||
<div className={styles.main}>
|
<div className={styles.main}>
|
||||||
{renderHeader()}
|
{renderHeader()}
|
||||||
{!showAdditionalOptions && <p>{lang('AreYouSureDeleteFewMessages')}</p>}
|
{!showAdditionalOptions && <p>{lang('AreYouSureDeleteFewMessages')}</p>}
|
||||||
{(showAdditionalOptions && !canDeleteForAll && !isSchedule && (isChannel || isGroup || isSuperGroup)) && (
|
{(showAdditionalOptions && !canDeleteForAll && !isSchedule && (isGroup || isSuperGroup)) && (
|
||||||
<>
|
<>
|
||||||
<p className={styles.actionTitle}>{oldLang('DeleteAdditionalActions')}</p>
|
<p className={styles.actionTitle}>{oldLang('DeleteAdditionalActions')}</p>
|
||||||
{renderAdditionalActionOptions()}
|
{renderAdditionalActionOptions()}
|
||||||
@ -458,8 +461,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
chat,
|
chat,
|
||||||
isChannel,
|
|
||||||
isGroup,
|
isGroup,
|
||||||
|
isChannel,
|
||||||
isSuperGroup,
|
isSuperGroup,
|
||||||
selectedMessageIds,
|
selectedMessageIds,
|
||||||
currentUserId: global.currentUserId,
|
currentUserId: global.currentUserId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user