You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { ExpirableReadableMessage } from './ExpirableReadableMessage';
|
|
import { NotificationBubble } from './notification-bubble/NotificationBubble';
|
|
import { Localizer } from '../../../basic/Localizer';
|
|
import { useMessageAuthor, useMessageDataExtractionType } from '../../../../state/selectors';
|
|
import { useNicknameOrProfileNameOrShortenedPubkey } from '../../../../hooks/useParamSelector';
|
|
import type { WithMessageId } from '../../../../session/types/with';
|
|
import { SignalService } from '../../../../protobuf';
|
|
|
|
export const DataExtractionNotification = (props: WithMessageId) => {
|
|
const { messageId } = props;
|
|
const author = useMessageAuthor(messageId);
|
|
const authorName = useNicknameOrProfileNameOrShortenedPubkey(author);
|
|
|
|
const dataExtractionType = useMessageDataExtractionType(messageId);
|
|
|
|
if (!author || !dataExtractionType) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ExpirableReadableMessage
|
|
messageId={messageId}
|
|
dataTestId="data-extraction-notification"
|
|
key={`readable-message-${messageId}`}
|
|
isControlMessage={true}
|
|
>
|
|
<NotificationBubble iconType="save">
|
|
<Localizer
|
|
token={
|
|
dataExtractionType === SignalService.DataExtractionNotification.Type.MEDIA_SAVED
|
|
? 'attachmentsMediaSaved'
|
|
: 'screenshotTaken'
|
|
}
|
|
args={{ name: authorName }}
|
|
/>
|
|
</NotificationBubble>
|
|
</ExpirableReadableMessage>
|
|
);
|
|
};
|