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

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

Loading…
Cancel
Save