diff --git a/ts/components/conversation/SessionConversation.tsx b/ts/components/conversation/SessionConversation.tsx index f87b840f0..df5128e6a 100644 --- a/ts/components/conversation/SessionConversation.tsx +++ b/ts/components/conversation/SessionConversation.tsx @@ -128,10 +128,8 @@ export class SessionConversation extends React.Component { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public componentDidUpdate(prevProps: Props, _prevState: State) { - const { - selectedConversationKey: newConversationKey, - selectedConversation: newConversation, - } = this.props; + const { selectedConversationKey: newConversationKey, selectedConversation: newConversation } = + this.props; const { selectedConversationKey: oldConversationKey } = prevProps; // if the convo is valid, and it changed, register for drag events diff --git a/ts/components/conversation/message/message-content/MessageContent.tsx b/ts/components/conversation/message/message-content/MessageContent.tsx index a28d499a8..4b7551a65 100644 --- a/ts/components/conversation/message/message-content/MessageContent.tsx +++ b/ts/components/conversation/message/message-content/MessageContent.tsx @@ -145,15 +145,8 @@ export const MessageContent = (props: Props) => { return null; } - const { - direction, - text, - timestamp, - serverTimestamp, - previews, - quote, - attachments, - } = contentProps; + const { direction, text, timestamp, serverTimestamp, previews, quote, attachments } = + contentProps; const hasContentBeforeAttachment = !isEmpty(previews) || !isEmpty(quote) || !isEmpty(text); diff --git a/ts/components/conversation/message/message-content/MessageReactBar.tsx b/ts/components/conversation/message/message-content/MessageReactBar.tsx index dbd5a2bd6..63e24a7fa 100644 --- a/ts/components/conversation/message/message-content/MessageReactBar.tsx +++ b/ts/components/conversation/message/message-content/MessageReactBar.tsx @@ -21,7 +21,9 @@ type Props = { const StyledMessageReactBar = styled.div` background-color: var(--emoji-reaction-bar-background-color); border-radius: 25px; - box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.2), 0 0px 20px 0 rgba(0, 0, 0, 0.19); + box-shadow: + 0 2px 16px 0 rgba(0, 0, 0, 0.2), + 0 0px 20px 0 rgba(0, 0, 0, 0.19); padding: 4px 8px; white-space: nowrap; diff --git a/ts/components/conversation/message/message-item/ExpirableReadableMessage.tsx b/ts/components/conversation/message/message-item/ExpirableReadableMessage.tsx index 213df0b40..e24a5c44e 100644 --- a/ts/components/conversation/message/message-item/ExpirableReadableMessage.tsx +++ b/ts/components/conversation/message/message-item/ExpirableReadableMessage.tsx @@ -125,14 +125,8 @@ export const ExpirableReadableMessage = (props: ExpirableReadableMessageProps) = return null; } - const { - messageId, - direction, - receivedAt, - isUnread, - expirationDurationMs, - expirationTimestamp, - } = selected; + const { messageId, direction, receivedAt, isUnread, expirationDurationMs, expirationTimestamp } = + selected; // NOTE we want messages on the left in the message detail view regardless of direction const isIncoming = props.isDetailView ? true : direction === 'incoming'; diff --git a/ts/components/conversation/message/message-item/InteractionNotification.tsx b/ts/components/conversation/message/message-item/InteractionNotification.tsx index be06bee1d..b4d30c635 100644 --- a/ts/components/conversation/message/message-item/InteractionNotification.tsx +++ b/ts/components/conversation/message/message-item/InteractionNotification.tsx @@ -44,8 +44,8 @@ export const InteractionNotification = (props: PropsForInteractionNotification) text = isCommunity ? window.i18n('leaveCommunityFailedPleaseTryAgain') : isGroup - ? window.i18n('leaveGroupFailedPleaseTryAgain') - : window.i18n('deleteConversationFailedPleaseTryAgain'); + ? window.i18n('leaveGroupFailedPleaseTryAgain') + : window.i18n('deleteConversationFailedPleaseTryAgain'); break; default: assertUnreachable( diff --git a/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx b/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx index d68f7d544..088bae640 100644 --- a/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx +++ b/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx @@ -172,8 +172,8 @@ export const OverlayDisappearingMessages = () => { {singleMode === 'deleteAfterRead' ? window.i18n('disappearingMessagesModeAfterReadSubtitle') : singleMode === 'deleteAfterSend' - ? window.i18n('disappearingMessagesModeAfterSendSubtitle') - : window.i18n('settingAppliesToYourMessages')} + ? window.i18n('disappearingMessagesModeAfterSendSubtitle') + : window.i18n('settingAppliesToYourMessages')} { singleMode ? disappearingModeOptions[singleMode] : modeSelected - ? disappearingModeOptions[modeSelected] - : undefined + ? disappearingModeOptions[modeSelected] + : undefined } /> @@ -217,8 +217,8 @@ export const OverlayDisappearingMessages = () => { singleMode ? disappearingModeOptions[singleMode] : modeSelected - ? disappearingModeOptions[modeSelected] - : undefined + ? disappearingModeOptions[modeSelected] + : undefined } dataTestId={'disappear-set-button'} > diff --git a/ts/components/dialog/InviteContactsDialog.tsx b/ts/components/dialog/InviteContactsDialog.tsx index a3215881c..63a07ca65 100644 --- a/ts/components/dialog/InviteContactsDialog.tsx +++ b/ts/components/dialog/InviteContactsDialog.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import useKey from 'react-use/lib/useKey'; import { PubkeyType } from 'libsession_util_nodejs'; @@ -25,10 +25,12 @@ import { SessionUtilUserGroups } from '../../session/utils/libsession/libsession import { groupInfoActions } from '../../state/ducks/metaGroups'; import { useContactsToInviteToGroup } from '../../state/selectors/conversations'; import { useMemberGroupChangePending } from '../../state/selectors/groups'; +import { useSelectedIsGroupV2 } from '../../state/selectors/selectedConversation'; import { MemberListItem } from '../MemberListItem'; import { SessionWrapperModal } from '../SessionWrapperModal'; import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton'; import { SessionSpinner } from '../basic/SessionSpinner'; +import { SessionToggle } from '../basic/SessionToggle'; type Props = { conversationId: string; @@ -122,6 +124,8 @@ const InviteContactsDialogInner = (props: Props) => { const membersFromRedux = useSortedGroupMembers(conversationId); const zombiesFromRedux = useZombies(conversationId); const displayName = useConversationUsername(conversationId); + const isGroupV2 = useSelectedIsGroupV2(); + const [shareHistory, setShareHistory] = useState(false); const { uniqueValues: selectedContacts, addTo, removeFrom } = useSet(); @@ -149,9 +153,10 @@ const InviteContactsDialogInner = (props: Props) => { void submitForOpenGroup(conversationId, selectedContacts); } else { if (PubKey.is03Pubkey(conversationId)) { + const forcedAsPubkeys = selectedContacts as Array; const action = groupInfoActions.currentDeviceGroupMembersChange({ - addMembersWithoutHistory: selectedContacts as Array, - addMembersWithHistory: [], + addMembersWithoutHistory: shareHistory ? [] : forcedAsPubkeys, + addMembersWithHistory: shareHistory ? forcedAsPubkeys : [], removeMembers: [], groupPk: conversationId, }); @@ -184,7 +189,12 @@ const InviteContactsDialogInner = (props: Props) => { return ( - + {isGroupV2 && ( + + Share History?{' '} + setShareHistory(!shareHistory)} /> + + )}
{hasContacts ? ( validContactsForInvite.map((member: string) => ( @@ -208,7 +218,6 @@ const InviteContactsDialogInner = (props: Props) => { -
= { addUser: { - path: - 'M8.85,2.17c-1.73,0-3.12,1.4-3.12,3.12s1.4,3.12,3.12,3.12c1.73,0,3.13-1.4,3.13-3.12S10.58,2.17,8.85,2.17z M8.85,0.08c2.88,0,5.21,2.33,5.21,5.21s-2.33,5.21-5.21,5.21s-5.2-2.33-5.2-5.21C3.65,2.42,5.98,0.08,8.85,0.08z M20.83,5.29 c0.54,0,0.98,0.41,1.04,0.93l0.01,0.11v2.08h2.08c0.54,0,0.98,0.41,1.04,0.93v0.12c0,0.54-0.41,0.98-0.93,1.04l-0.11,0.01h-2.08 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08h-2.08c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11 c0-0.54,0.41-0.98,0.93-1.04l0.11-0.01h2.08V6.34C19.79,5.76,20.26,5.29,20.83,5.29z M12.5,12.58c2.8,0,5.09,2.21,5.2,4.99v0.22 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08c0-1.67-1.3-3.03-2.95-3.12h-0.18H5.21 c-1.67,0-3.03,1.3-3.12,2.95v0.18v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93L0,19.88V17.8 c0-2.8,2.21-5.09,4.99-5.2h0.22h7.29V12.58z', + path: 'M8.85,2.17c-1.73,0-3.12,1.4-3.12,3.12s1.4,3.12,3.12,3.12c1.73,0,3.13-1.4,3.13-3.12S10.58,2.17,8.85,2.17z M8.85,0.08c2.88,0,5.21,2.33,5.21,5.21s-2.33,5.21-5.21,5.21s-5.2-2.33-5.2-5.21C3.65,2.42,5.98,0.08,8.85,0.08z M20.83,5.29 c0.54,0,0.98,0.41,1.04,0.93l0.01,0.11v2.08h2.08c0.54,0,0.98,0.41,1.04,0.93v0.12c0,0.54-0.41,0.98-0.93,1.04l-0.11,0.01h-2.08 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08h-2.08c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11 c0-0.54,0.41-0.98,0.93-1.04l0.11-0.01h2.08V6.34C19.79,5.76,20.26,5.29,20.83,5.29z M12.5,12.58c2.8,0,5.09,2.21,5.2,4.99v0.22 v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93l-0.01-0.11v-2.08c0-1.67-1.3-3.03-2.95-3.12h-0.18H5.21 c-1.67,0-3.03,1.3-3.12,2.95v0.18v2.08c0,0.58-0.47,1.04-1.04,1.04c-0.54,0-0.98-0.41-1.04-0.93L0,19.88V17.8 c0-2.8,2.21-5.09,4.99-5.2h0.22h7.29V12.58z', viewBox: '0 0 25 21', ratio: 1, }, addModerator: { - path: - 'M21.7.7H5.1c-1.2 0-2.2.5-3 1.3C1.3 2.8.9 3.8.9 5v10.5c0 1.1.4 2.2 1.2 3 .8.8 1.8 1.2 2.9 1.2h16.7c1.1 0 2.2-.5 2.9-1.2.8-.8 1.2-1.9 1.2-3V5c0-.6-.1-1.1-.3-1.6-.2-.5-.5-1-.9-1.4-.4-.4-.8-.7-1.4-.9-.4-.3-.9-.4-1.5-.4zm2.1 14.8c0 .6-.2 1.1-.6 1.5-.4.4-.9.6-1.5.6H5.1c-.6 0-1.1-.2-1.5-.6-.4-.4-.6-1-.6-1.5V5c0-.6.2-1.1.6-1.5.4-.4.9-.6 1.5-.6h16.7c.6 0 1.1.2 1.5.6.4.4.6.9.6 1.5-.1 0-.1 10.5-.1 10.5zM17.1 9.2h-2.7V6.5c0-.3-.1-.6-.3-.8-.4-.4-1.1-.4-1.5 0-.2.2-.3.5-.3.8v2.7H9.7c-.3 0-.5.1-.7.3-.4.4-.4 1.1 0 1.5.2.2.5.3.7.3h2.6V14c0 .3.1.6.3.8.2.2.5.3.7.3.3 0 .5-.1.7-.3.2-.2.3-.5.3-.8v-2.7H17c.3 0 .5-.1.7-.3.4-.4.4-1.1 0-1.5-.1-.2-.4-.3-.6-.3z', + path: 'M21.7.7H5.1c-1.2 0-2.2.5-3 1.3C1.3 2.8.9 3.8.9 5v10.5c0 1.1.4 2.2 1.2 3 .8.8 1.8 1.2 2.9 1.2h16.7c1.1 0 2.2-.5 2.9-1.2.8-.8 1.2-1.9 1.2-3V5c0-.6-.1-1.1-.3-1.6-.2-.5-.5-1-.9-1.4-.4-.4-.8-.7-1.4-.9-.4-.3-.9-.4-1.5-.4zm2.1 14.8c0 .6-.2 1.1-.6 1.5-.4.4-.9.6-1.5.6H5.1c-.6 0-1.1-.2-1.5-.6-.4-.4-.6-1-.6-1.5V5c0-.6.2-1.1.6-1.5.4-.4.9-.6 1.5-.6h16.7c.6 0 1.1.2 1.5.6.4.4.6.9.6 1.5-.1 0-.1 10.5-.1 10.5zM17.1 9.2h-2.7V6.5c0-.3-.1-.6-.3-.8-.4-.4-1.1-.4-1.5 0-.2.2-.3.5-.3.8v2.7H9.7c-.3 0-.5.1-.7.3-.4.4-.4 1.1 0 1.5.2.2.5.3.7.3h2.6V14c0 .3.1.6.3.8.2.2.5.3.7.3.3 0 .5-.1.7-.3.2-.2.3-.5.3-.8v-2.7H17c.3 0 .5-.1.7-.3.4-.4.4-1.1 0-1.5-.1-.2-.4-.3-.6-.3z', viewBox: '0 0 26 20', ratio: 1.18, }, arrow: { - path: - 'M33.187,12.438 L6.097,12.438 L16.113,2.608 C16.704,2.027 16.713,1.078 16.133,0.486 C15.551,-0.105 14.602,-0.113 14.011,0.466 L1.407,12.836 C1.121,13.117 0.959,13.5 0.957981241,13.9 C0.956,14.3 1.114,14.685 1.397,14.968 L14.022,27.593 C14.315,27.886 14.699,28.032 15.083,28.032 C15.466,28.032 15.85,27.886 16.143,27.593 C16.729,27.007 16.729,26.057 16.143,25.472 L6.109,15.438 L33.187,15.438 C34.015,15.438 34.687,14.766 34.687,13.938 C34.687,13.109 34.015,12.438 33.187,12.438', + path: 'M33.187,12.438 L6.097,12.438 L16.113,2.608 C16.704,2.027 16.713,1.078 16.133,0.486 C15.551,-0.105 14.602,-0.113 14.011,0.466 L1.407,12.836 C1.121,13.117 0.959,13.5 0.957981241,13.9 C0.956,14.3 1.114,14.685 1.397,14.968 L14.022,27.593 C14.315,27.886 14.699,28.032 15.083,28.032 C15.466,28.032 15.85,27.886 16.143,27.593 C16.729,27.007 16.729,26.057 16.143,25.472 L6.109,15.438 L33.187,15.438 C34.015,15.438 34.687,14.766 34.687,13.938 C34.687,13.109 34.015,12.438 33.187,12.438', viewBox: '0 -4 37 37', ratio: 1, }, bell: { - path: - 'M2.117 0a.396.396 0 00-.397.397v.18C.963.757.53 1.434.53 2.25v1.323l-.53.53v.264h4.233V4.1l-.529-.53v-.223h-.29c-.066 0-.132-.006-.197-.015v.546l-2.159-.042V2.249c0-.656.4-1.19 1.059-1.19l.064.003c.119-.181.278-.334.463-.448a1.608 1.608 0 00-.13-.036v-.18A.396.396 0 002.117 0zm-.53 4.63a.53.53 0 001.058 0z M3.355.578a1.267 1.267 0 000 2.534h.634v-.254h-.634c-.55 0-1.013-.464-1.013-1.013 0-.55.463-1.014 1.013-1.014.55 0 1.014.464 1.014 1.014v.18c0 .1-.09.2-.19.2s-.19-.1-.19-.2v-.18a.634.634 0 10-.185.447.47.47 0 00.375.186c.25 0 .443-.203.443-.452v-.181c0-.7-.567-1.267-1.267-1.267zm0 1.647a.38.38 0 110-.76.38.38 0 010 .76z', + path: 'M2.117 0a.396.396 0 00-.397.397v.18C.963.757.53 1.434.53 2.25v1.323l-.53.53v.264h4.233V4.1l-.529-.53v-.223h-.29c-.066 0-.132-.006-.197-.015v.546l-2.159-.042V2.249c0-.656.4-1.19 1.059-1.19l.064.003c.119-.181.278-.334.463-.448a1.608 1.608 0 00-.13-.036v-.18A.396.396 0 002.117 0zm-.53 4.63a.53.53 0 001.058 0z M3.355.578a1.267 1.267 0 000 2.534h.634v-.254h-.634c-.55 0-1.013-.464-1.013-1.013 0-.55.463-1.014 1.013-1.014.55 0 1.014.464 1.014 1.014v.18c0 .1-.09.2-.19.2s-.19-.1-.19-.2v-.18a.634.634 0 10-.185.447.47.47 0 00.375.186c.25 0 .443-.203.443-.452v-.181c0-.7-.567-1.267-1.267-1.267zm0 1.647a.38.38 0 110-.76.38.38 0 010 .76z', viewBox: '0 0 4.622 5.159', ratio: 1, }, brand: { - path: - 'm 216.456,315.282 c 36.104,0 66.415,-29.551 65.565,-65.646 -0.59,-25.135 -14.478,-48.161 -36.54,-60.386 l -83.435,-46.234 v 69.229 c 0,5.18855 -4.20645,9.39455 -9.395,9.394 H 67.847 c -26.603,0 -48.093,22.297 -46.765,49.183 1.242,25.15 22.941,44.46 48.123,44.46 h 147.251 m -75.437,-121.993 0.016,-69.217 c 0.002,-5.186 4.19,-9.391 9.376,-9.392 l 84.808,-0.014 c 26.602,0 48.092,-22.297 46.764,-49.181 C 280.74,40.334 259.041,21.023 233.858,21.023 H 86.608 c -36.103,0 -66.415,29.551 -65.565,65.646 0.591,25.136 14.479,48.161 36.541,60.386 z m 114.65,-22.427 c 29.233,16.2 47.395,47.023 47.395,80.448 0,46.865 -38.129,84.995 -84.995,84.995 H 67.847 C 30.437,336.305 0,305.867 0,268.459 0,231.051 30.437,200.616 67.847,200.616 h 43.026 L 47.396,165.445 C 18.162,149.243 0,118.42 0,84.995 0,38.131 38.13,0 84.995,0 h 150.224 c 37.408,0 67.845,30.438 67.845,67.846 0,37.409 -30.437,67.843 -67.845,67.843 h -43.028 l 63.478,35.173', + path: 'm 216.456,315.282 c 36.104,0 66.415,-29.551 65.565,-65.646 -0.59,-25.135 -14.478,-48.161 -36.54,-60.386 l -83.435,-46.234 v 69.229 c 0,5.18855 -4.20645,9.39455 -9.395,9.394 H 67.847 c -26.603,0 -48.093,22.297 -46.765,49.183 1.242,25.15 22.941,44.46 48.123,44.46 h 147.251 m -75.437,-121.993 0.016,-69.217 c 0.002,-5.186 4.19,-9.391 9.376,-9.392 l 84.808,-0.014 c 26.602,0 48.092,-22.297 46.764,-49.181 C 280.74,40.334 259.041,21.023 233.858,21.023 H 86.608 c -36.103,0 -66.415,29.551 -65.565,65.646 0.591,25.136 14.479,48.161 36.541,60.386 z m 114.65,-22.427 c 29.233,16.2 47.395,47.023 47.395,80.448 0,46.865 -38.129,84.995 -84.995,84.995 H 67.847 C 30.437,336.305 0,305.867 0,268.459 0,231.051 30.437,200.616 67.847,200.616 h 43.026 L 47.396,165.445 C 18.162,149.243 0,118.42 0,84.995 0,38.131 38.13,0 84.995,0 h 150.224 c 37.408,0 67.845,30.438 67.845,67.846 0,37.409 -30.437,67.843 -67.845,67.843 h -43.028 l 63.478,35.173', viewBox: '0 0 404.085 448.407', ratio: 1, }, callIncoming: { - path: - 'M14.414 7l3.293-3.293a1 1 0 00-1.414-1.414L13 5.586V4a1 1 0 10-2 0v4.003a.996.996 0 00.617.921A.997.997 0 0012 9h4a1 1 0 100-2h-1.586zM2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.037 11.037 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C7.82 18 2 12.18 2 5V3z', + path: 'M14.414 7l3.293-3.293a1 1 0 00-1.414-1.414L13 5.586V4a1 1 0 10-2 0v4.003a.996.996 0 00.617.921A.997.997 0 0012 9h4a1 1 0 100-2h-1.586zM2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.037 11.037 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C7.82 18 2 12.18 2 5V3z', viewBox: '0 0 20 20', ratio: 1, }, callOutgoing: { - path: - 'M17.924 2.617a.997.997 0 00-.215-.322l-.004-.004A.997.997 0 0017 2h-4a1 1 0 100 2h1.586l-3.293 3.293a1 1 0 001.414 1.414L16 5.414V7a1 1 0 102 0V3a.997.997 0 00-.076-.383zM2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.037 11.037 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C7.82 18 2 12.18 2 5V3z', + path: 'M17.924 2.617a.997.997 0 00-.215-.322l-.004-.004A.997.997 0 0017 2h-4a1 1 0 100 2h1.586l-3.293 3.293a1 1 0 001.414 1.414L16 5.414V7a1 1 0 102 0V3a.997.997 0 00-.076-.383zM2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.037 11.037 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C7.82 18 2 12.18 2 5V3z', viewBox: '0 0 20 20', ratio: 1, }, callMissed: { - path: - 'M2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.037 11.037 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C7.82 18 2 12.18 2 5V3zM16.707 3.293a1 1 0 010 1.414L15.414 6l1.293 1.293a1 1 0 01-1.414 1.414L14 7.414l-1.293 1.293a1 1 0 11-1.414-1.414L12.586 6l-1.293-1.293a1 1 0 011.414-1.414L14 4.586l1.293-1.293a1 1 0 011.414 0z', + path: 'M2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.037 11.037 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C7.82 18 2 12.18 2 5V3zM16.707 3.293a1 1 0 010 1.414L15.414 6l1.293 1.293a1 1 0 01-1.414 1.414L14 7.414l-1.293 1.293a1 1 0 11-1.414-1.414L12.586 6l-1.293-1.293a1 1 0 011.414-1.414L14 4.586l1.293-1.293a1 1 0 011.414 0z', viewBox: '0 0 20 20', ratio: 1, }, @@ -143,20 +135,17 @@ export const icons: Record { // Do this only if we created a new Session ID, or if we already received the initial configuration message const triggerSyncIfNeeded = async () => { const us = UserUtils.getOurPubKeyStrFromCache(); - await ConvoHub.use() - .get(us) - .setDidApproveMe(true, true); - await ConvoHub.use() - .get(us) - .setIsApproved(true, true); + await ConvoHub.use().get(us).setDidApproveMe(true, true); + await ConvoHub.use().get(us).setIsApproved(true, true); const didWeHandleAConfigurationMessageAlready = (await Data.getItemById(SettingsKey.hasSyncedInitialConfigurationItem))?.value || false; if (didWeHandleAConfigurationMessageAlready) { diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index b353634e1..48b23cfbe 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -352,28 +352,29 @@ export function useIsTyping(conversationId?: string): boolean { return useConversationPropsById(conversationId)?.isTyping || false; } -const getMessageExpirationProps = createSelector(getMessagePropsByMessageId, (props): - | PropsForExpiringMessage - | undefined => { - if (!props || isEmpty(props)) { - return undefined; - } +const getMessageExpirationProps = createSelector( + getMessagePropsByMessageId, + (props): PropsForExpiringMessage | undefined => { + if (!props || isEmpty(props)) { + return undefined; + } - const msgProps: PropsForExpiringMessage = { - ...pick(props.propsForMessage, [ - 'convoId', - 'direction', - 'receivedAt', - 'isUnread', - 'expirationTimestamp', - 'expirationDurationMs', - 'isExpired', - ]), - messageId: props.propsForMessage.id, - }; - - return msgProps; -}); + const msgProps: PropsForExpiringMessage = { + ...pick(props.propsForMessage, [ + 'convoId', + 'direction', + 'receivedAt', + 'isUnread', + 'expirationTimestamp', + 'expirationDurationMs', + 'isExpired', + ]), + messageId: props.propsForMessage.id, + }; + + return msgProps; + } +); export function useMessageExpirationPropsById(messageId?: string) { return useSelector((state: StateType) => { @@ -430,9 +431,7 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string, hasOnlyO }, [disappearingMessageMode, hasOnlyOneMode]); } -export function useQuoteAuthorName( - authorId?: string -): { +export function useQuoteAuthorName(authorId?: string): { authorName: string | undefined; isMe: boolean; } { @@ -442,8 +441,8 @@ export function useQuoteAuthorName( const authorName = isMe ? window.i18n('you') : convoProps?.nickname || convoProps?.isPrivate - ? convoProps?.displayNameInProfile - : undefined; + ? convoProps?.displayNameInProfile + : undefined; return { authorName, isMe }; } @@ -495,12 +494,12 @@ export function useDisappearingMessageSettingText({ expirationMode === 'deleteAfterRead' ? window.i18n('disappearingMessagesModeAfterRead') : expirationMode === 'deleteAfterSend' - ? window.i18n('disappearingMessagesModeAfterSend') - : expirationMode === 'legacy' - ? isMe || (isGroup && !isPublic) ? window.i18n('disappearingMessagesModeAfterSend') - : window.i18n('disappearingMessagesModeAfterRead') - : null; + : expirationMode === 'legacy' + ? isMe || (isGroup && !isPublic) + ? window.i18n('disappearingMessagesModeAfterSend') + : window.i18n('disappearingMessagesModeAfterRead') + : null; const expireTimerText = isNumber(expireTimer) ? abbreviate diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index e4440c32d..02c7fd687 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -206,9 +206,7 @@ export const declineConversationWithConfirm = ({ const okKey: LocalizerKeys = alsoBlock ? 'block' : 'delete'; const nameToBlock = alsoBlock && !!conversationIdOrigin - ? ConvoHub.use() - .get(conversationIdOrigin) - ?.getContactProfileNameOrShortenedPubKey() + ? ConvoHub.use().get(conversationIdOrigin)?.getContactProfileNameOrShortenedPubKey() : null; const messageKey: LocalizerKeys = isGroupV2 ? alsoBlock && nameToBlock @@ -621,9 +619,7 @@ export async function uploadOurAvatar(newAvatarDecrypted?: ArrayBuffer) { } else { // this is a reupload. no need to generate a new profileKey const ourConvoProfileKey = - ConvoHub.use() - .get(UserUtils.getOurPubKeyStrFromCache()) - ?.getProfileKey() || null; + ConvoHub.use().get(UserUtils.getOurPubKeyStrFromCache())?.getProfileKey() || null; profileKey = ourConvoProfileKey ? fromHexToArray(ourConvoProfileKey) : null; if (!profileKey) { diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index d134a0b9e..4c112e2b1 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -2243,8 +2243,8 @@ export class ConversationModel extends Backbone.Model { const interactionNotification = lastMessageModel.getInteractionNotification(); const lastMessageInteractionType = interactionNotification?.interactionType; - const lastMessageInteractionStatus = lastMessageModel.getInteractionNotification() - ?.interactionStatus; + const lastMessageInteractionStatus = + lastMessageModel.getInteractionNotification()?.interactionStatus; const lastMessageStatus = lastMessageModel.getMessagePropStatus() || undefined; const lastMessageNotificationText = lastMessageModel.getNotificationText() || undefined; // we just want to set the `status` to `undefined` if there are no `lastMessageNotificationText` diff --git a/ts/models/message.ts b/ts/models/message.ts index 0887bd64e..a0d72d543 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -487,7 +487,7 @@ export class MessageModel extends Backbone.Model { if (groupUpdate.joinedWithHistory?.length) { const change: PropsForGroupUpdateAdd = { type: 'add', - added: groupUpdate.joined as Array, + added: groupUpdate.joinedWithHistory as Array, withHistory: true, }; return { change, ...sharedProps }; @@ -763,9 +763,8 @@ export class MessageModel extends Backbone.Model { const quoteWithData = await loadQuoteData(this.get('quote')); const previewWithData = await loadPreviewData(this.get('preview')); - const { hasAttachments, hasVisualMediaAttachments, hasFileAttachments } = getAttachmentMetadata( - this - ); + const { hasAttachments, hasVisualMediaAttachments, hasFileAttachments } = + getAttachmentMetadata(this); this.set({ hasAttachments, hasVisualMediaAttachments, hasFileAttachments }); await this.commit(); @@ -816,8 +815,9 @@ export class MessageModel extends Backbone.Model { } window.log.info( - `Upload of message data for message ${this.idForLogging()} is finished in ${Date.now() - - start}ms.` + `Upload of message data for message ${this.idForLogging()} is finished in ${ + Date.now() - start + }ms.` ); return { body, @@ -1266,24 +1266,34 @@ export class MessageModel extends Backbone.Model { const left: Array | undefined = Array.isArray(groupUpdate.left) ? groupUpdate.left : groupUpdate.left - ? [groupUpdate.left] - : undefined; + ? [groupUpdate.left] + : undefined; const kicked: Array | undefined = Array.isArray(groupUpdate.kicked) ? groupUpdate.kicked : groupUpdate.kicked - ? [groupUpdate.kicked] - : undefined; + ? [groupUpdate.kicked] + : undefined; const joined: Array | undefined = Array.isArray(groupUpdate.joined) ? groupUpdate.joined : groupUpdate.joined - ? [groupUpdate.joined] - : undefined; + ? [groupUpdate.joined] + : undefined; + const joinedWithHistory: Array | undefined = Array.isArray( + groupUpdate.joinedWithHistory + ) + ? groupUpdate.joinedWithHistory + : groupUpdate.joinedWithHistory + ? [groupUpdate.joinedWithHistory] + : undefined; const forcedArrayUpdate: MessageGroupUpdate = {}; if (left) { forcedArrayUpdate.left = left; } + if (joinedWithHistory) { + forcedArrayUpdate.joinedWithHistory = joinedWithHistory; + } if (joined) { forcedArrayUpdate.joined = joined; } @@ -1404,8 +1414,8 @@ export class MessageModel extends Backbone.Model { return isCommunity ? window.i18n('leaveCommunityFailed') : isGroup - ? window.i18n('leaveGroupFailed') - : window.i18n('deleteConversationFailed'); + ? window.i18n('leaveGroupFailed') + : window.i18n('deleteConversationFailed'); default: assertUnreachable( interactionType, diff --git a/ts/session/apis/snode_api/batchRequest.ts b/ts/session/apis/snode_api/batchRequest.ts index 9c714d74e..106512674 100644 --- a/ts/session/apis/snode_api/batchRequest.ts +++ b/ts/session/apis/snode_api/batchRequest.ts @@ -94,7 +94,6 @@ function decodeBatchRequest(snodeResponse: SnodeResponse): NotEmptyArrayOfBatchR try { // console.error('decodeBatch: ', snodeResponse); if (snodeResponse.status !== 200) { - debugger; throw new Error(`decodeBatchRequest invalid status code: ${snodeResponse.status}`); } const parsed = JSON.parse(snodeResponse.body); diff --git a/ts/session/apis/snode_api/namespaces.ts b/ts/session/apis/snode_api/namespaces.ts index 12466290a..377b706c5 100644 --- a/ts/session/apis/snode_api/namespaces.ts +++ b/ts/session/apis/snode_api/namespaces.ts @@ -257,6 +257,8 @@ function toRole(namespace: number) { return 'groupInfo'; case SnodeNamespaces.ClosedGroupMembers: return 'groupMembers'; + case SnodeNamespaces.ClosedGroupRevokedRetrievableMessages: + return 'groupRevoked'; default: return `${namespace}`; } diff --git a/ts/session/apis/snode_api/onions.ts b/ts/session/apis/snode_api/onions.ts index 6f5cbdd7b..15289d338 100644 --- a/ts/session/apis/snode_api/onions.ts +++ b/ts/session/apis/snode_api/onions.ts @@ -87,9 +87,11 @@ async function encryptOnionV4RequestForPubkey( ) { const plaintext = encodeV4Request(requestInfo); - return callUtilsWorker('encryptForPubkey', pubKeyX25519hex, plaintext) as Promise< - DestinationContext - >; + return callUtilsWorker( + 'encryptForPubkey', + pubKeyX25519hex, + plaintext + ) as Promise; } // Returns the actual ciphertext, symmetric key that will be used // for decryption, and an ephemeral_key to send to the next hop @@ -99,9 +101,11 @@ async function encryptForPubKey( ): Promise { const plaintext = new TextEncoder().encode(JSON.stringify(requestInfo)); - return callUtilsWorker('encryptForPubkey', pubKeyX25519hex, plaintext) as Promise< - DestinationContext - >; + return callUtilsWorker( + 'encryptForPubkey', + pubKeyX25519hex, + plaintext + ) as Promise; } export type DestinationRelayV2 = { diff --git a/ts/session/apis/snode_api/swarmPolling.ts b/ts/session/apis/snode_api/swarmPolling.ts index 9c6394710..f191314f6 100644 --- a/ts/session/apis/snode_api/swarmPolling.ts +++ b/ts/session/apis/snode_api/swarmPolling.ts @@ -728,17 +728,16 @@ function retrieveItemWithNamespace( ): Array { return flatten( compact( - results.map( - result => - result.messages.messages?.map(r => { - // throws if the result is not expected - const parsedItem = retrieveItemSchema.parse(r); - return { - ...omit(parsedItem, 'timestamp'), - namespace: result.namespace, - storedAt: parsedItem.timestamp, - }; - }) + results.map(result => + result.messages.messages?.map(r => { + // throws if the result is not expected + const parsedItem = retrieveItemSchema.parse(r); + return { + ...omit(parsedItem, 'timestamp'), + namespace: result.namespace, + storedAt: parsedItem.timestamp, + }; + }) ) ) ); diff --git a/ts/session/disappearing_messages/index.ts b/ts/session/disappearing_messages/index.ts index a31547367..931eb85f9 100644 --- a/ts/session/disappearing_messages/index.ts +++ b/ts/session/disappearing_messages/index.ts @@ -59,9 +59,7 @@ export async function destroyMessagesAndUpdateRedux( // trigger a refresh the last message for all those uniq conversation conversationWithChanges.forEach(convoIdToUpdate => { - ConvoHub.use() - .get(convoIdToUpdate) - ?.updateLastMessage(); + ConvoHub.use().get(convoIdToUpdate)?.updateLastMessage(); }); } @@ -91,12 +89,8 @@ async function destroyExpiredMessages() { window.log.info('destroyExpiredMessages: convosToRefresh:', convosToRefresh); await Promise.all( convosToRefresh.map(async c => { - ConvoHub.use() - .get(c) - ?.updateLastMessage(); - return ConvoHub.use() - .get(c) - ?.refreshInMemoryDetails(); + ConvoHub.use().get(c)?.updateLastMessage(); + return ConvoHub.use().get(c)?.refreshInMemoryDetails(); }) ); } catch (error) { @@ -278,9 +272,7 @@ function changeToDisappearingMessageType( * This should only be used for DataExtractionNotification and CallMessages (the ones saved to the DB) currently. * Note: this can only be called for private conversations, excluding ourselves as it throws otherwise (this wouldn't be right) * */ -function forcedDeleteAfterReadMsgSetting( - convo: ConversationModel -): { +function forcedDeleteAfterReadMsgSetting(convo: ConversationModel): { expirationType: Exclude; expireTimer: number; } { @@ -307,9 +299,7 @@ function forcedDeleteAfterReadMsgSetting( * This should only be used for the outgoing CallMessages that we keep locally only (not synced, just the "you started a call" notification) * Note: this can only be called for private conversations, excluding ourselves as it throws otherwise (this wouldn't be right) * */ -function forcedDeleteAfterSendMsgSetting( - convo: ConversationModel -): { +function forcedDeleteAfterSendMsgSetting(convo: ConversationModel): { expirationType: Exclude; expireTimer: number; } { @@ -365,7 +355,8 @@ async function checkForExpireUpdateInContentMessage( ): Promise { const dataMessage = content.dataMessage as SignalService.DataMessage | undefined; // We will only support legacy disappearing messages for a short period before disappearing messages v2 is unlocked - const isDisappearingMessagesV2Released = await ReleasedFeatures.checkIsDisappearMessageV2FeatureReleased(); + const isDisappearingMessagesV2Released = + await ReleasedFeatures.checkIsDisappearMessageV2FeatureReleased(); const couldBeLegacyContentMessage = couldBeLegacyDisappearingMessageContent(content); const isLegacyDataMessage = @@ -565,9 +556,9 @@ function getMessageReadyToDisappear( if (msgExpirationWasAlreadyUpdated) { const expirationStartTimestamp = messageExpirationFromRetrieve - expireTimer * 1000; window.log.debug( - `incoming DaR message already read by another device, forcing readAt ${(Date.now() - - expirationStartTimestamp) / - 1000}s ago, so with ${(messageExpirationFromRetrieve - Date.now()) / 1000}s left` + `incoming DaR message already read by another device, forcing readAt ${ + (Date.now() - expirationStartTimestamp) / 1000 + }s ago, so with ${(messageExpirationFromRetrieve - Date.now()) / 1000}s left` ); messageModel.set({ expirationStartTimestamp, diff --git a/ts/session/group/closed-group.ts b/ts/session/group/closed-group.ts index 0f72a232f..f92ae9209 100644 --- a/ts/session/group/closed-group.ts +++ b/ts/session/group/closed-group.ts @@ -166,7 +166,11 @@ export async function addUpdateMessage({ if (diff.type === 'name' && diff.newName) { groupUpdate.name = diff.newName; } else if (diff.type === 'add' && diff.added) { - groupUpdate.joined = diff.added; + if (diff.withHistory) { + groupUpdate.joinedWithHistory = diff.added; + } else { + groupUpdate.joined = diff.added; + } } else if (diff.type === 'left' && diff.left) { groupUpdate.left = diff.left; } else if (diff.type === 'kicked' && diff.kicked) { diff --git a/ts/state/ducks/metaGroups.ts b/ts/state/ducks/metaGroups.ts index 984eeeddf..2bf0776d2 100644 --- a/ts/state/ducks/metaGroups.ts +++ b/ts/state/ducks/metaGroups.ts @@ -784,7 +784,7 @@ async function handleMemberAddedFromUI({ const updateMessagesToPush: Array = []; if (withHistory.length) { const msgModel = await ClosedGroup.addUpdateMessage({ - diff: { type: 'add', added: withHistory, withHistory: false }, + diff: { type: 'add', added: withHistory, withHistory: true }, ...shared, }); const groupChange = await getWithHistoryControlMessage({ @@ -801,7 +801,7 @@ async function handleMemberAddedFromUI({ } if (withoutHistory.length) { const msgModel = await ClosedGroup.addUpdateMessage({ - diff: { type: 'add', added: withoutHistory, withHistory: true }, + diff: { type: 'add', added: withoutHistory, withHistory: false }, ...shared, }); const groupChange = await getWithoutHistoryControlMessage({