session-desktop/ts/components/conversation/Message.tsx
Warrick 1d459ba533
Unsend messages (only message hashes saving for now is enabled) (#1891)
* WIP unsending message.

* retrieving message with hash from db on receiving unsend request.

* outgoing messages hashes updated on message sent success

* unsend messaging

* unsend message - deleting messages and marking as isDeleted.

* add msg hash to unprocessed records.

* Message unsending working for closed groups provided the message has been updated with a hash from server.

* adding 2-stage confirmation modal for message deletion

* adding rendering of removed incoming messages, disabling rendering of unsent outgoing messages in coversation screen.

* Adding logging

* debugging.

* outgoing only saved for sync message instead of regular message.

* deleting locally

* adding post unsend deletioncode.

* starting adding feature flag.

* Added feature flag.

* addding mandatory messageHash  pollling pipeline methods swarm polling.

* Conversation list item message preview showing deletion placeholder text if deleted.

* add condition to drop unsend requests not send by message author

* refactoring deleteMessage. Saving response hash for closed group message sending

* running yarn ready

* removing logging.

* Adding PR fixes

* Minor changes and running yarn ready

* fix typo

* Moved feature flag to lokiFeatureFlags. Fixing linting errors


Co-authored-by: Audric Ackermann <audric@loki.network>
2021-09-20 13:47:59 +10:00

42 lines
1.2 KiB
TypeScript

import React from 'react';
import _ from 'lodash';
import uuid from 'uuid';
import { QuoteClickOptions } from '../../models/messageType';
import { GenericReadableMessage } from './message/GenericReadableMessage';
import { useSelector } from 'react-redux';
import { getGenericReadableMessageSelectorProps } from '../../state/selectors/conversations';
// Same as MIN_WIDTH in ImageGrid.tsx
export const MINIMUM_LINK_PREVIEW_IMAGE_WIDTH = 200;
type Props = {
messageId: string;
isDetailView?: boolean; // when the detail is shown for a message, we disble click and some other stuff
onQuoteClick?: (options: QuoteClickOptions) => Promise<void>;
};
export const Message = (props: Props) => {
const msgProps = useSelector(state =>
getGenericReadableMessageSelectorProps(state as any, props.messageId)
);
const ctxMenuID = `ctx-menu-message-${uuid()}`;
const onQuoteClick = (quote: QuoteClickOptions) => {
void props.onQuoteClick?.(quote);
};
if (msgProps?.isDeleted && msgProps.direction === 'outgoing') {
return null;
}
return (
<GenericReadableMessage
onQuoteClick={onQuoteClick}
ctxMenuID={ctxMenuID}
messageId={props.messageId}
isDetailView={props.isDetailView}
/>
);
};