fix: add checks to deal with non server deletable messages

pull/3061/head
Audric Ackermann 1 year ago
parent 9b7908026f
commit 93211b1bf9

@ -53,11 +53,14 @@ import { LightboxGallery, MediaItemType } from '../lightbox/LightboxGallery';
import { NoMessageInConversation } from './SubtleNotification';
import { ConversationHeaderWithDetails } from './header/ConversationHeader';
import {
deleteMessagesById,
deleteMessagesByIdForEveryone,
} from '../../interactions/conversations/unsendingInteractions';
import { isAudio } from '../../types/MIME';
import { HTMLDirection } from '../../util/i18n';
import { NoticeBanner } from '../NoticeBanner';
import { SessionSpinner } from '../basic/SessionSpinner';
import { deleteMessagesByIdForEveryone } from '../../interactions/conversations/unsendingInteractions';
import { RightPanel, StyledRightPanelContainer } from './right-panel/RightPanel';
const DEFAULT_JPEG_QUALITY = 0.85;
@ -85,6 +88,7 @@ interface Props {
stagedAttachments: Array<StagedAttachmentType>;
isSelectedConvoInitialLoadingInProgress: boolean;
isPublic: boolean;
}
const StyledSpinnerContainer = styled.div`
@ -345,6 +349,7 @@ export class SessionConversation extends React.Component<Props, State> {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private onKeyDown(event: any) {
const selectionMode = !!this.props.selectedMessages.length;
const { selectedConversationKey, selectedMessages, isPublic } = this.props;
if (event.target.classList.contains('conversation-content')) {
switch (event.key) {
@ -355,11 +360,15 @@ export class SessionConversation extends React.Component<Props, State> {
break;
case 'Backspace':
case 'Delete':
if (selectionMode) {
void deleteMessagesByIdForEveryone(
this.props.selectedMessages,
this.props.selectedConversationKey
);
if (selectionMode && this.props.selectedConversationKey) {
if (isPublic) {
void deleteMessagesByIdForEveryone(selectedMessages, selectedConversationKey);
} else {
void deleteMessagesById(
this.props.selectedMessages,
this.props.selectedConversationKey
);
}
}
break;
default:

@ -12,7 +12,10 @@ import {
getSortedMessagesOfSelectedConversation,
isRightPanelShowing,
} from '../selectors/conversations';
import { getSelectedConversationKey } from '../selectors/selectedConversation';
import {
getSelectedConversationIsPublic,
getSelectedConversationKey,
} from '../selectors/selectedConversation';
import { getStagedAttachmentsForCurrentConversation } from '../selectors/stagedAttachments';
import { getTheme } from '../selectors/theme';
import { getOurDisplayNameInProfile, getOurNumber } from '../selectors/user';
@ -36,6 +39,7 @@ const mapStateToProps = (state: StateType, ownProps: SmartSessionConversationOwn
hasOngoingCallWithFocusedConvo: getHasOngoingCallWithFocusedConvo(state),
isSelectedConvoInitialLoadingInProgress: getIsSelectedConvoInitialLoadingInProgress(state),
htmlDirection: ownProps.htmlDirection,
isPublic: getSelectedConversationIsPublic(state),
};
};

Loading…
Cancel
Save