diff --git a/.eslintrc.js b/.eslintrc.js index 671387e71..f109f1170 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,5 @@ +var path = require('path'); + module.exports = { root: true, settings: { @@ -10,6 +12,11 @@ module.exports = { react: { version: 'detect', }, + 'import/resolver': { + node: { + paths: [path.resolve(__dirname)], + }, + }, }, extends: [ diff --git a/.gitignore b/.gitignore index a57cb1a51..27cf464db 100644 --- a/.gitignore +++ b/.gitignore @@ -50,5 +50,6 @@ test-results/ coverage/ stylesheets/dist/ -*.worker.js.LICENSE.txt +*.LICENSE.txt ts/webworker/workers/node/**/*.node + diff --git a/build/afterPackHook.js b/build/afterPackHook.js index 49dfae909..7cc030cb2 100644 --- a/build/afterPackHook.js +++ b/build/afterPackHook.js @@ -5,7 +5,7 @@ const util = require('util'); const renameAsync = util.promisify(fs.rename); const unlinkAsync = util.promisify(fs.unlink); -module.exports = async function(context) { +module.exports = async function (context) { // Replace the app launcher on linux only. if (process.platform !== 'linux') { return; diff --git a/libsession.worker.config.js b/libsession.worker.config.js index fe1741bea..bb8a9df2a 100644 --- a/libsession.worker.config.js +++ b/libsession.worker.config.js @@ -1,6 +1,8 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path'); +const isProd = process.env.NODE_ENV === 'production'; + module.exports = { entry: './ts/webworker/workers/node/libsession/libsession.worker.ts', node: { @@ -29,11 +31,11 @@ module.exports = { }, }, output: { - filename: 'libsession.worker.js', + filename: 'libsession.worker.compiled.js', path: path.resolve(__dirname, 'ts', 'webworker', 'workers', 'node', 'libsession'), }, target: 'node', optimization: { - minimize: true, + minimize: isProd, }, }; diff --git a/ts/components/avatar/Avatar.tsx b/ts/components/avatar/Avatar.tsx index 43134b21c..5bc51d6c7 100644 --- a/ts/components/avatar/Avatar.tsx +++ b/ts/components/avatar/Avatar.tsx @@ -110,15 +110,8 @@ const AvatarImage = ( }; const AvatarInner = (props: Props) => { - const { - base64Data, - size, - pubkey, - forcedAvatarPath, - forcedName, - dataTestId, - onAvatarClick, - } = props; + const { base64Data, size, pubkey, forcedAvatarPath, forcedName, dataTestId, onAvatarClick } = + props; const [imageBroken, setImageBroken] = useState(false); const isSelectingMessages = useSelector(isMessageSelectionMode); diff --git a/ts/components/basic/SessionButton.tsx b/ts/components/basic/SessionButton.tsx index 84e96136d..10a1d33e8 100644 --- a/ts/components/basic/SessionButton.tsx +++ b/ts/components/basic/SessionButton.tsx @@ -82,8 +82,8 @@ const StyledButton = styled.div<{ props.buttonType === SessionButtonType.Solid ? 'background-color: var(--button-solid-disabled-color)' : props.buttonType === SessionButtonType.Outline - ? 'border: 1px solid var(--button-outline-disabled-color)' - : ''}; + ? 'border: 1px solid var(--button-outline-disabled-color)' + : ''}; color: ${props => props.buttonType === SessionButtonType.Solid ? 'var(--button-solid-text-color)' @@ -116,16 +116,8 @@ type Props = { }; export const SessionButton = (props: Props) => { - const { - buttonType, - buttonShape, - dataTestId, - buttonColor, - text, - disabled, - onClick, - margin, - } = props; + const { buttonType, buttonShape, dataTestId, buttonColor, text, disabled, onClick, margin } = + props; const clickHandler = (e: any) => { if (onClick) { diff --git a/ts/components/basic/SessionRadio.tsx b/ts/components/basic/SessionRadio.tsx index 600743fb5..56a5b41b2 100644 --- a/ts/components/basic/SessionRadio.tsx +++ b/ts/components/basic/SessionRadio.tsx @@ -18,8 +18,8 @@ const StyledInput = styled.input<{ props.disabled ? 'var(--disabled-color)' : props.selectedColor - ? props.selectedColor - : 'var(--primary-color)'}; + ? props.selectedColor + : 'var(--primary-color)'}; } `; @@ -133,8 +133,8 @@ const StyledLabelOutlineSelected = styled(StyledLabel)<{ selectedColor: string } props.disabled ? 'var(--disabled-color)' : props.selectedColor - ? props.selectedColor - : 'var(--primary-color)'}; + ? props.selectedColor + : 'var(--primary-color)'}; outline: 1px solid transparent; /* CSS variables don't work here */ } `; diff --git a/ts/components/basic/SessionToggle.tsx b/ts/components/basic/SessionToggle.tsx index bdbb9e857..3f9ec0cb4 100644 --- a/ts/components/basic/SessionToggle.tsx +++ b/ts/components/basic/SessionToggle.tsx @@ -16,7 +16,9 @@ const StyledKnob = styled.div<{ active: boolean }>` ? '-2px 1px 3px var(--toggle-switch-ball-shadow-color);' : '2px 1px 3px var(--toggle-switch-ball-shadow-color);'}; - transition: transform var(--default-duration) ease, background-color var(--default-duration) ease; + transition: + transform var(--default-duration) ease, + background-color var(--default-duration) ease; transform: ${props => (props.active ? 'translateX(25px)' : '')}; `; diff --git a/ts/components/basic/Text.tsx b/ts/components/basic/Text.tsx index fd6e7a879..a99acf97a 100644 --- a/ts/components/basic/Text.tsx +++ b/ts/components/basic/Text.tsx @@ -42,23 +42,23 @@ const SpacerStyled = styled.div` props.size === 'xl' ? 'var(--margins-xl)' : props.size === 'lg' - ? 'var(--margins-lg)' - : props.size === 'md' - ? 'var(--margins-md)' - : props.size === 'sm' - ? 'var(--margins-sm)' - : 'var(--margins-xs)'}; + ? 'var(--margins-lg)' + : props.size === 'md' + ? 'var(--margins-md)' + : props.size === 'sm' + ? 'var(--margins-sm)' + : 'var(--margins-xs)'}; width: ${props => props.size === 'xl' ? 'var(--margins-xl)' : props.size === 'lg' - ? 'var(--margins-lg)' - : props.size === 'md' - ? 'var(--margins-md)' - : props.size === 'sm' - ? 'var(--margins-sm)' - : 'var(--margins-xs)'}; + ? 'var(--margins-lg)' + : props.size === 'md' + ? 'var(--margins-md)' + : props.size === 'sm' + ? 'var(--margins-sm)' + : 'var(--margins-xs)'}; `; const Spacer = (props: SpacerProps) => { diff --git a/ts/components/conversation/ContactName.tsx b/ts/components/conversation/ContactName.tsx index ed01e7a78..718467b78 100644 --- a/ts/components/conversation/ContactName.tsx +++ b/ts/components/conversation/ContactName.tsx @@ -25,11 +25,13 @@ export const ContactName = (props: Props) => { const convoName = useNicknameOrProfileNameOrShortenedPubkey(pubkey); const isPrivate = useIsPrivate(pubkey); const shouldShowProfile = Boolean(convoName || profileName || name); - const styles = (boldProfileName - ? { - fontWeight: 'bold', - } - : {}) as React.CSSProperties; + const styles = ( + boldProfileName + ? { + fontWeight: 'bold', + } + : {} + ) as React.CSSProperties; const textProfile = profileName || name || convoName || window.i18n('anonymous'); return ( diff --git a/ts/components/conversation/SessionConversation.tsx b/ts/components/conversation/SessionConversation.tsx index 708e5e481..25cd9ce57 100644 --- a/ts/components/conversation/SessionConversation.tsx +++ b/ts/components/conversation/SessionConversation.tsx @@ -127,10 +127,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/SessionQuotedMessageComposition.tsx b/ts/components/conversation/SessionQuotedMessageComposition.tsx index 6c54f5f78..fc5371209 100644 --- a/ts/components/conversation/SessionQuotedMessageComposition.tsx +++ b/ts/components/conversation/SessionQuotedMessageComposition.tsx @@ -70,14 +70,14 @@ function renderSubtitleText( return quoteText && quoteText !== '' ? quoteText : hasAudioAttachment - ? window.i18n('audio') - : isGenericFile - ? window.i18n('document') - : isVideo - ? window.i18n('video') - : isImage - ? window.i18n('image') - : null; + ? window.i18n('audio') + : isGenericFile + ? window.i18n('document') + : isVideo + ? window.i18n('video') + : isImage + ? window.i18n('image') + : null; } export const SessionQuotedMessageComposition = () => { diff --git a/ts/components/conversation/TimerNotification.tsx b/ts/components/conversation/TimerNotification.tsx index 2dd26fc7d..6c3791eac 100644 --- a/ts/components/conversation/TimerNotification.tsx +++ b/ts/components/conversation/TimerNotification.tsx @@ -147,8 +147,8 @@ function useTextToRender(props: PropsForExpirationTimer) { const mode = isLegacyDisappearingModeEnabled(expirationMode) ? null : expirationMode === 'deleteAfterRead' - ? window.i18n('timerModeRead') - : window.i18n('timerModeSent'); + ? window.i18n('timerModeRead') + : window.i18n('timerModeSent'); switch (type) { case 'fromOther': return disabled @@ -157,12 +157,12 @@ function useTextToRender(props: PropsForExpirationTimer) { [contact, timespanText] ) : mode - ? window.i18n(ownSideOnly ? 'theySetTheirDisappearingMessages' : 'theyChangedTheTimer', [ - contact, - timespanText, - mode, - ]) - : window.i18n('theyChangedTheTimerLegacy', [contact, timespanText]); + ? window.i18n(ownSideOnly ? 'theySetTheirDisappearingMessages' : 'theyChangedTheTimer', [ + contact, + timespanText, + mode, + ]) + : window.i18n('theyChangedTheTimerLegacy', [contact, timespanText]); case 'fromMe': case 'fromSync': return disabled @@ -170,11 +170,11 @@ function useTextToRender(props: PropsForExpirationTimer) { ownSideOnly ? 'youDisabledYourDisappearingMessages' : 'youDisabledDisappearingMessages' ) : mode - ? window.i18n(ownSideOnly ? 'youSetYourDisappearingMessages' : 'youChangedTheTimer', [ - timespanText, - mode, - ]) - : window.i18n('youChangedTheTimerLegacy', [timespanText]); + ? window.i18n(ownSideOnly ? 'youSetYourDisappearingMessages' : 'youChangedTheTimer', [ + timespanText, + mode, + ]) + : window.i18n('youChangedTheTimerLegacy', [timespanText]); default: assertUnreachable(type, `TimerNotification: Missing case error "${type}"`); } diff --git a/ts/components/conversation/Timestamp.tsx b/ts/components/conversation/Timestamp.tsx index 92c88f606..de2ee1139 100644 --- a/ts/components/conversation/Timestamp.tsx +++ b/ts/components/conversation/Timestamp.tsx @@ -44,10 +44,7 @@ export const Timestamp = (props: Props) => { // this is a hack to make the date string shorter, looks like moment does not have a localized way of doing this for now. const dateString = momentFromNow - ? momentValue - .fromNow() - .replace('minutes', 'mins') - .replace('minute', 'min') + ? momentValue.fromNow().replace('minutes', 'mins').replace('minute', 'min') : momentValue.format('lll'); const title = moment(timestamp).format('llll'); diff --git a/ts/components/conversation/TypingAnimation.tsx b/ts/components/conversation/TypingAnimation.tsx index 61af18a01..7ec13f7f5 100644 --- a/ts/components/conversation/TypingAnimation.tsx +++ b/ts/components/conversation/TypingAnimation.tsx @@ -63,8 +63,8 @@ const StyledTypingDot = styled.div<{ index: number }>` props.index === 0 ? 'typing-animation-first' : props.index === 1 - ? 'typing-animation-second' - : 'typing-animation-third'} + ? 'typing-animation-second' + : 'typing-animation-third'} 1600ms ease infinite; `; diff --git a/ts/components/conversation/header/ConversationHeaderTitle.tsx b/ts/components/conversation/header/ConversationHeaderTitle.tsx index 43830a101..7aeb0207a 100644 --- a/ts/components/conversation/header/ConversationHeaderTitle.tsx +++ b/ts/components/conversation/header/ConversationHeaderTitle.tsx @@ -51,9 +51,8 @@ export const ConversationHeaderTitle = () => { abbreviate: true, }); - const [visibleSubtitle, setVisibleSubtitle] = useState( - 'disappearingMessages' - ); + const [visibleSubtitle, setVisibleSubtitle] = + useState('disappearingMessages'); const [subtitleStrings, setSubtitleStrings] = useState({}); const [subtitleArray, setSubtitleArray] = useState>([]); diff --git a/ts/components/conversation/media-gallery/groupMediaItemsByDate.ts b/ts/components/conversation/media-gallery/groupMediaItemsByDate.ts index b01ed751d..5e82e9be2 100644 --- a/ts/components/conversation/media-gallery/groupMediaItemsByDate.ts +++ b/ts/components/conversation/media-gallery/groupMediaItemsByDate.ts @@ -87,55 +87,53 @@ type MediaItemWithYearMonthSection = GenericMediaItemWithSection ( - mediaItem: MediaItemType -): MediaItemWithSection => { - const today = moment(referenceDateTime).startOf('day'); - const yesterday = moment(referenceDateTime) - .subtract(1, 'day') - .startOf('day'); - const thisWeek = moment(referenceDateTime).startOf('isoWeek'); - const thisMonth = moment(referenceDateTime).startOf('month'); +const withSection = + (referenceDateTime: moment.Moment) => + (mediaItem: MediaItemType): MediaItemWithSection => { + const today = moment(referenceDateTime).startOf('day'); + const yesterday = moment(referenceDateTime).subtract(1, 'day').startOf('day'); + const thisWeek = moment(referenceDateTime).startOf('isoWeek'); + const thisMonth = moment(referenceDateTime).startOf('month'); + + const { messageTimestamp } = mediaItem; + const mediaItemReceivedDate = moment.utc(messageTimestamp); + if (mediaItemReceivedDate.isAfter(today)) { + return { + order: 0, + type: 'today', + mediaItem, + }; + } + if (mediaItemReceivedDate.isAfter(yesterday)) { + return { + order: 1, + type: 'yesterday', + mediaItem, + }; + } + if (mediaItemReceivedDate.isAfter(thisWeek)) { + return { + order: 2, + type: 'thisWeek', + mediaItem, + }; + } + if (mediaItemReceivedDate.isAfter(thisMonth)) { + return { + order: 3, + type: 'thisMonth', + mediaItem, + }; + } + + const month: number = mediaItemReceivedDate.month(); + const year: number = mediaItemReceivedDate.year(); - const { messageTimestamp } = mediaItem; - const mediaItemReceivedDate = moment.utc(messageTimestamp); - if (mediaItemReceivedDate.isAfter(today)) { - return { - order: 0, - type: 'today', - mediaItem, - }; - } - if (mediaItemReceivedDate.isAfter(yesterday)) { - return { - order: 1, - type: 'yesterday', - mediaItem, - }; - } - if (mediaItemReceivedDate.isAfter(thisWeek)) { - return { - order: 2, - type: 'thisWeek', - mediaItem, - }; - } - if (mediaItemReceivedDate.isAfter(thisMonth)) { return { - order: 3, - type: 'thisMonth', + order: year * 100 + month, + type: 'yearMonth', + month, + year, mediaItem, }; - } - - const month: number = mediaItemReceivedDate.month(); - const year: number = mediaItemReceivedDate.year(); - - return { - order: year * 100 + month, - type: 'yearMonth', - month, - year, - mediaItem, }; -}; diff --git a/ts/components/conversation/message/message-content/MessageContent.tsx b/ts/components/conversation/message/message-content/MessageContent.tsx index 9b85263f6..24a0619b2 100644 --- a/ts/components/conversation/message/message-content/MessageContent.tsx +++ b/ts/components/conversation/message/message-content/MessageContent.tsx @@ -146,15 +146,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 1be31cc7a..3d9a6fec6 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-content/MessageText.tsx b/ts/components/conversation/message/message-content/MessageText.tsx index 15ef56bd1..18a0f39b6 100644 --- a/ts/components/conversation/message/message-content/MessageText.tsx +++ b/ts/components/conversation/message/message-content/MessageText.tsx @@ -32,8 +32,8 @@ export const MessageText = (props: Props) => { const contents = isDeleted ? window.i18n('messageDeletedPlaceholder') : direction === 'incoming' && status === 'error' - ? window.i18n('incomingError') - : text?.trim(); + ? window.i18n('incomingError') + : text?.trim(); if (!contents) { return null; 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/message/reactions/ReactionPopup.tsx b/ts/components/conversation/message/reactions/ReactionPopup.tsx index cefd352cf..903e1d267 100644 --- a/ts/components/conversation/message/reactions/ReactionPopup.tsx +++ b/ts/components/conversation/message/reactions/ReactionPopup.tsx @@ -111,8 +111,8 @@ const Contacts = (contacts: Array, count: number) => { reactors === 1 ? 'reactionPopupOne' : reactors === 2 - ? 'reactionPopupTwo' - : 'reactionPopupThree', + ? 'reactionPopupTwo' + : 'reactionPopupThree', contacts )}{' '} {window.i18n('reactionPopup')} diff --git a/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx b/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx index 29c72d811..d3db66a94 100644 --- a/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx +++ b/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx @@ -48,9 +48,7 @@ import { MediaItemType } from '../../../lightbox/LightboxGallery'; import { MediaGallery } from '../../media-gallery/MediaGallery'; import { Header, StyledScrollContainer } from './components'; -async function getMediaGalleryProps( - conversationId: string -): Promise<{ +async function getMediaGalleryProps(conversationId: string): Promise<{ documents: Array; media: Array; }> { @@ -261,13 +259,13 @@ export const OverlayRightPanelSettings = () => { const leaveGroupString = isPublic ? window.i18n('leaveCommunity') : lastMessage?.interactionType === ConversationInteractionType.Leave && - lastMessage?.interactionStatus === ConversationInteractionStatus.Error - ? window.i18n('deleteConversation') - : isKickedFromGroup - ? window.i18n('youGotKickedFromGroup') - : left - ? window.i18n('youLeftTheGroup') - : window.i18n('leaveGroup'); + lastMessage?.interactionStatus === ConversationInteractionStatus.Error + ? window.i18n('deleteConversation') + : isKickedFromGroup + ? window.i18n('youGotKickedFromGroup') + : left + ? window.i18n('youLeftTheGroup') + : window.i18n('leaveGroup'); const showUpdateGroupNameButton = isGroup && weAreAdmin && !commonNoShow; // legacy groups non-admin cannot change groupname anymore const showAddRemoveModeratorsButton = weAreAdmin && !commonNoShow && isPublic; diff --git a/ts/components/conversation/right-panel/overlay/disappearing-messages/DisappearingModes.tsx b/ts/components/conversation/right-panel/overlay/disappearing-messages/DisappearingModes.tsx index 083a8733a..3683119cc 100644 --- a/ts/components/conversation/right-panel/overlay/disappearing-messages/DisappearingModes.tsx +++ b/ts/components/conversation/right-panel/overlay/disappearing-messages/DisappearingModes.tsx @@ -42,19 +42,19 @@ export const DisappearingModes = (props: DisappearingModesProps) => { mode === 'legacy' ? window.i18n('disappearingMessagesModeLegacy') : mode === 'deleteAfterRead' - ? window.i18n('disappearingMessagesModeAfterRead') - : mode === 'deleteAfterSend' - ? window.i18n('disappearingMessagesModeAfterSend') - : window.i18n('disappearingMessagesModeOff'); + ? window.i18n('disappearingMessagesModeAfterRead') + : mode === 'deleteAfterSend' + ? window.i18n('disappearingMessagesModeAfterSend') + : window.i18n('disappearingMessagesModeOff'); const subtitleI18n = mode === 'legacy' ? window.i18n('disappearingMessagesModeLegacySubtitle') : mode === 'deleteAfterRead' - ? window.i18n('disappearingMessagesModeAfterReadSubtitle') - : mode === 'deleteAfterSend' - ? window.i18n('disappearingMessagesModeAfterSendSubtitle') - : undefined; + ? window.i18n('disappearingMessagesModeAfterReadSubtitle') + : mode === 'deleteAfterSend' + ? window.i18n('disappearingMessagesModeAfterSendSubtitle') + : undefined; return ( { {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 } /> @@ -223,8 +223,8 @@ export const OverlayDisappearingMessages = () => { singleMode ? disappearingModeOptions[singleMode] : modeSelected - ? disappearingModeOptions[modeSelected] - : undefined + ? disappearingModeOptions[modeSelected] + : undefined } dataTestId={'disappear-set-button'} > diff --git a/ts/components/dialog/ReactClearAllModal.tsx b/ts/components/dialog/ReactClearAllModal.tsx index fa3a07b6e..7d7347bf4 100644 --- a/ts/components/dialog/ReactClearAllModal.tsx +++ b/ts/components/dialog/ReactClearAllModal.tsx @@ -59,9 +59,7 @@ export const ReactClearAllModal = (props: Props): ReactElement => { } const { convoId, serverId } = msgProps; - const roomInfos = getConversationController() - .get(convoId) - .toOpenGroupV2(); + const roomInfos = getConversationController().get(convoId).toOpenGroupV2(); const handleClose = () => { dispatch(updateReactClearAllModal(null)); diff --git a/ts/components/dialog/SessionPasswordDialog.tsx b/ts/components/dialog/SessionPasswordDialog.tsx index 1eafcf538..98d736902 100644 --- a/ts/components/dialog/SessionPasswordDialog.tsx +++ b/ts/components/dialog/SessionPasswordDialog.tsx @@ -82,10 +82,10 @@ export class SessionPasswordDialog extends React.Component { passwordAction === 'change' ? 'changePassword' : passwordAction === 'remove' - ? 'removePassword' - : passwordAction === 'enter' - ? 'passwordViewTitle' - : 'setPassword'; + ? 'removePassword' + : passwordAction === 'enter' + ? 'passwordViewTitle' + : 'setPassword'; return ( @@ -295,11 +295,8 @@ export class SessionPasswordDialog extends React.Component { private async setPassword() { const { passwordAction } = this.props; - const { - currentPasswordEntered, - currentPasswordConfirmEntered, - currentPasswordRetypeEntered, - } = this.state; + const { currentPasswordEntered, currentPasswordConfirmEntered, currentPasswordRetypeEntered } = + this.state; // Trim leading / trailing whitespace for UX const firstPasswordEntered = (currentPasswordEntered || '').trim(); diff --git a/ts/components/dialog/UpdateGroupMembersDialog.tsx b/ts/components/dialog/UpdateGroupMembersDialog.tsx index 070a1c2b0..e00132e86 100644 --- a/ts/components/dialog/UpdateGroupMembersDialog.tsx +++ b/ts/components/dialog/UpdateGroupMembersDialog.tsx @@ -171,9 +171,11 @@ export const UpdateGroupMembersDialog = (props: Props) => { const convoProps = useConversationPropsById(conversationId); const existingMembers = convoProps?.members || []; - const { addTo, removeFrom, uniqueValues: membersToKeepWithUpdate } = useSet( - existingMembers - ); + const { + addTo, + removeFrom, + uniqueValues: membersToKeepWithUpdate, + } = useSet(existingMembers); const dispatch = useDispatch(); diff --git a/ts/components/icon/DropDownAndToggleButton.tsx b/ts/components/icon/DropDownAndToggleButton.tsx index fccb8a3db..98db7b081 100644 --- a/ts/components/icon/DropDownAndToggleButton.tsx +++ b/ts/components/icon/DropDownAndToggleButton.tsx @@ -18,14 +18,14 @@ const StyledRoundedButton = styled.div<{ isFullScreen: boolean; isMuted: boolean props.isMuted ? 'var(--call-buttons-background-disabled-color)' : props.isFullScreen - ? 'var(--call-buttons-action-background-color)' - : 'var(--call-buttons-background-color)'}; + ? 'var(--call-buttons-action-background-color)' + : 'var(--call-buttons-background-color)'}; color: ${props => props.isMuted ? 'var(--call-buttons-icon-disabled-color)' : props.isFullScreen - ? 'var(--call-buttons-action-icon-color)' - : 'var(--call-buttons-icon-color)'}; + ? 'var(--call-buttons-action-icon-color)' + : 'var(--call-buttons-icon-color)'}; ${props => props.isFullScreen && 'opacity: 0.4;'} &:hover { diff --git a/ts/components/icon/Icons.tsx b/ts/components/icon/Icons.tsx index 36a9c7ebb..27f336055 100644 --- a/ts/components/icon/Icons.tsx +++ b/ts/components/icon/Icons.tsx @@ -90,50 +90,42 @@ export type SessionIconSize = 'tiny' | 'small' | 'medium' | 'large' | 'huge' | ' export const icons: Record = { 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 getConversationController() - .get(us) - .setDidApproveMe(true, true); - await getConversationController() - .get(us) - .setIsApproved(true, true); + await getConversationController().get(us).setDidApproveMe(true, true); + await getConversationController().get(us).setIsApproved(true, true); const didWeHandleAConfigurationMessageAlready = (await Data.getItemById(SettingsKey.hasSyncedInitialConfigurationItem))?.value || false; if (didWeHandleAConfigurationMessageAlready) { diff --git a/ts/components/leftpane/conversation-list-item/InteractionItem.tsx b/ts/components/leftpane/conversation-list-item/InteractionItem.tsx index 0e7b0031f..29b836bce 100644 --- a/ts/components/leftpane/conversation-list-item/InteractionItem.tsx +++ b/ts/components/leftpane/conversation-list-item/InteractionItem.tsx @@ -64,15 +64,15 @@ export const InteractionItem = (props: InteractionItemProps) => { errorText = isCommunity ? window.i18n('leaveCommunityFailed') : isGroup - ? window.i18n('leaveGroupFailed') - : window.i18n('deleteConversationFailed'); + ? window.i18n('leaveGroupFailed') + : window.i18n('deleteConversationFailed'); text = interactionStatus === ConversationInteractionStatus.Error ? errorText : interactionStatus === ConversationInteractionStatus.Start || - interactionStatus === ConversationInteractionStatus.Loading - ? window.i18n('leaving') - : text; + interactionStatus === ConversationInteractionStatus.Loading + ? window.i18n('leaving') + : text; break; default: assertUnreachable( diff --git a/ts/components/leftpane/conversation-list-item/UserItem.tsx b/ts/components/leftpane/conversation-list-item/UserItem.tsx index 0526bcb2f..ec293ae3c 100644 --- a/ts/components/leftpane/conversation-list-item/UserItem.tsx +++ b/ts/components/leftpane/conversation-list-item/UserItem.tsx @@ -27,8 +27,8 @@ export const UserItem = () => { const displayName = isMe ? window.i18n('noteToSelf') : isSearchResultsMode && hasNickname && realName - ? `${realName} (${username})` - : username; + ? `${realName} (${username})` + : username; let shouldShowPubkey = false; if ((!username || username.length === 0) && (!displayName || displayName.length === 0)) { diff --git a/ts/components/menu/Menu.tsx b/ts/components/menu/Menu.tsx index 465012594..69cb07118 100644 --- a/ts/components/menu/Menu.tsx +++ b/ts/components/menu/Menu.tsx @@ -155,9 +155,9 @@ export const LeaveGroupOrCommunityMenuItem = () => { {isPublic ? window.i18n('leaveCommunity') : lastMessage?.interactionType === ConversationInteractionType.Leave && - lastMessage?.interactionStatus === ConversationInteractionStatus.Error - ? window.i18n('deleteConversation') - : window.i18n('leaveGroup')} + lastMessage?.interactionStatus === ConversationInteractionStatus.Error + ? window.i18n('deleteConversation') + : window.i18n('leaveGroup')} ); } @@ -546,8 +546,8 @@ export const NotificationForConvoMenuItem = (): JSX.Element | null => { n === 'all' || !n ? 'notificationForConvo_all' : n === 'disabled' - ? 'notificationForConvo_disabled' - : 'notificationForConvo_mentions_only'; + ? 'notificationForConvo_disabled' + : 'notificationForConvo_mentions_only'; return { value: n, name: window.i18n(keyToUse) }; }); diff --git a/ts/data/data.ts b/ts/data/data.ts index 64cce1e68..e5190e997 100644 --- a/ts/data/data.ts +++ b/ts/data/data.ts @@ -176,9 +176,8 @@ async function removeConversation(id: string): Promise { } async function getAllConversations(): Promise> { - const conversationsAttrs = (await channels.getAllConversations()) as Array< - ConversationAttributes - >; + const conversationsAttrs = + (await channels.getAllConversations()) as Array; return conversationsAttrs.map(attr => new ConversationModel(attr)); } @@ -547,23 +546,26 @@ async function removeAllMessagesInConversation(conversationId: string): Promise< await message.cleanup(); } window.log.info( - `removeAllMessagesInConversation messages.cleanup() ${conversationId} took ${Date.now() - - start}ms` + `removeAllMessagesInConversation messages.cleanup() ${conversationId} took ${ + Date.now() - start + }ms` ); start = Date.now(); // eslint-disable-next-line no-await-in-loop await channels.removeMessagesByIds(ids); window.log.info( - `removeAllMessagesInConversation: removeMessagesByIds ${conversationId} took ${Date.now() - - start}ms` + `removeAllMessagesInConversation: removeMessagesByIds ${conversationId} took ${ + Date.now() - start + }ms` ); } while (messages.length); await channels.removeAllMessagesInConversation(conversationId); window.log.info( - `removeAllMessagesInConversation: complete time ${conversationId} took ${Date.now() - - startFunction}ms` + `removeAllMessagesInConversation: complete time ${conversationId} took ${ + Date.now() - startFunction + }ms` ); } diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index 662f1199e..71744f8ee 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -274,28 +274,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) => { @@ -352,17 +353,18 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string, hasOnlyO }, [disappearingMessageMode, hasOnlyOneMode]); } -export function useQuoteAuthorName( - authorId?: string -): { authorName: string | undefined; isMe: boolean } { +export function useQuoteAuthorName(authorId?: string): { + authorName: string | undefined; + isMe: boolean; +} { const convoProps = useConversationPropsById(authorId); const isMe = Boolean(authorId && isUsAnySogsFromCache(authorId)); const authorName = isMe ? window.i18n('you') : convoProps?.nickname || convoProps?.isPrivate - ? convoProps?.displayNameInProfile - : undefined; + ? convoProps?.displayNameInProfile + : undefined; return { authorName, isMe }; } @@ -403,12 +405,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/hooks/useVideoEventListener.ts b/ts/hooks/useVideoEventListener.ts index 06c984aa3..1fe3880cb 100644 --- a/ts/hooks/useVideoEventListener.ts +++ b/ts/hooks/useVideoEventListener.ts @@ -21,9 +21,8 @@ export function useVideoCallEventsListener(uniqueId: string, onSame: boolean) { const [remoteStream, setRemoteStream] = useState(null); const [localStreamVideoIsMuted, setLocalStreamVideoIsMuted] = useState(true); const [ourAudioIsMuted, setOurAudioIsMuted] = useState(false); - const [currentSelectedAudioOutput, setCurrentSelectedAudioOutput] = useState( - DEVICE_DISABLED_DEVICE_ID - ); + const [currentSelectedAudioOutput, setCurrentSelectedAudioOutput] = + useState(DEVICE_DISABLED_DEVICE_ID); const [remoteStreamVideoIsMuted, setRemoteStreamVideoIsMuted] = useState(true); const mountedStateFunc = useMountedState(); const mountedState = mountedStateFunc(); diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index 98d18929d..8954d36fb 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -556,9 +556,8 @@ export async function uploadOurAvatar(newAvatarDecrypted?: ArrayBuffer) { } else { // this is a reupload. no need to generate a new profileKey const ourConvoProfileKey = - getConversationController() - .get(UserUtils.getOurPubKeyStrFromCache()) - ?.get('profileKey') || null; + getConversationController().get(UserUtils.getOurPubKeyStrFromCache())?.get('profileKey') || + null; profileKey = ourConvoProfileKey ? fromHexToArray(ourConvoProfileKey) : null; if (!profileKey) { diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index 807046738..8d37b28e5 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -862,10 +862,13 @@ async function requestShutdown() { // exits the app before we've set everything up in preload() (so the browser isn't // yet listening for these events), or if there are a whole lot of stacked-up tasks. // Note: two minutes is also our timeout for SQL tasks in data.ts in the browser. - setTimeout(() => { - console.log('requestShutdown: Response never received; forcing shutdown.'); - resolve(undefined); - }, 2 * 60 * 1000); + setTimeout( + () => { + console.log('requestShutdown: Response never received; forcing shutdown.'); + resolve(undefined); + }, + 2 * 60 * 1000 + ); }); try { diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 4423c0ca6..d4d5450b6 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -2104,8 +2104,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` @@ -2473,10 +2473,10 @@ export class ConversationModel extends Backbone.Model { mode === 'deleteAfterRead' ? ours === 'deleteAfterRead' : mode === 'deleteAfterSend' - ? ours === 'deleteAfterSend' - : mode === 'off' - ? ours === 'off' - : false; + ? ours === 'deleteAfterSend' + : mode === 'off' + ? ours === 'off' + : false; return success; } diff --git a/ts/models/conversationAttributes.ts b/ts/models/conversationAttributes.ts index 03d6e7d8b..0fa1dc183 100644 --- a/ts/models/conversationAttributes.ts +++ b/ts/models/conversationAttributes.ts @@ -39,7 +39,7 @@ export function isDirectConversation(conversationType: ConversationTypeEnum) { * mentions_only: trigger a notification only on mentions of ourself */ export const ConversationNotificationSetting = ['all', 'disabled', 'mentions_only'] as const; -export type ConversationNotificationSettingType = typeof ConversationNotificationSetting[number]; +export type ConversationNotificationSettingType = (typeof ConversationNotificationSetting)[number]; /** * Some fields are retrieved from the database as a select, but should not be saved in a commit() diff --git a/ts/models/message.ts b/ts/models/message.ts index fbf0c35ad..92f497702 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -273,9 +273,8 @@ export class MessageModel extends Backbone.Model { (pubkeysInDesc || []).forEach((pubkeyWithAt: string) => { const pubkey = pubkeyWithAt.slice(1); const isUS = isUsAnySogsFromCache(pubkey); - const displayName = getConversationController().getContactProfileNameOrShortenedPubKey( - pubkey - ); + const displayName = + getConversationController().getContactProfileNameOrShortenedPubKey(pubkey); if (isUS) { description = description?.replace(pubkeyWithAt, `@${window.i18n('you')}`); } else if (displayName && displayName.length) { @@ -742,9 +741,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(); @@ -795,8 +793,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, @@ -1238,18 +1237,18 @@ 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 forcedArrayUpdate: MessageGroupUpdate = {}; @@ -1381,8 +1380,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/node/menu.ts b/ts/node/menu.ts index fb2862e1b..fb4541850 100644 --- a/ts/node/menu.ts +++ b/ts/node/menu.ts @@ -17,14 +17,8 @@ export const createTemplate = ( throw new TypeError('`options.platform` must be a string'); } - const { - openReleaseNotes, - openSupportPage, - platform, - showAbout, - showDebugLog, - showWindow, - } = options; + const { openReleaseNotes, openSupportPage, platform, showAbout, showDebugLog, showWindow } = + options; const template = [ { diff --git a/ts/node/migration/helpers/v31.ts b/ts/node/migration/helpers/v31.ts index d1314b3cb..b8bef0bad 100644 --- a/ts/node/migration/helpers/v31.ts +++ b/ts/node/migration/helpers/v31.ts @@ -309,14 +309,8 @@ function insertLegacyGroupIntoWrapper( ) { checkTargetMigration(version, targetVersion); - const { - priority, - id, - groupAdmins, - members, - displayNameInProfile, - lastJoinedTimestamp, - } = legacyGroup; + const { priority, id, groupAdmins, members, displayNameInProfile, lastJoinedTimestamp } = + legacyGroup; const latestEncryptionKeyPairHex = sqlNode.getLatestClosedGroupEncryptionKeyPair( legacyGroup.id, diff --git a/ts/node/sql.ts b/ts/node/sql.ts index 52a12d6e0..52323b03a 100644 --- a/ts/node/sql.ts +++ b/ts/node/sql.ts @@ -351,9 +351,7 @@ function getById(table: string, id: string, instance?: BetterSqlite3.Database) { function removeById(table: string, id: string) { if (!Array.isArray(id)) { - assertGlobalInstance() - .prepare(`DELETE FROM ${table} WHERE id = $id;`) - .run({ id }); + assertGlobalInstance().prepare(`DELETE FROM ${table} WHERE id = $id;`).run({ id }); return; } @@ -401,9 +399,7 @@ function updateSwarmNodesForPubkey(pubkey: string, snodeEdKeys: Array) { } function getConversationCount() { - const row = assertGlobalInstance() - .prepare(`SELECT count(*) from ${CONVERSATIONS_TABLE};`) - .get(); + const row = assertGlobalInstance().prepare(`SELECT count(*) from ${CONVERSATIONS_TABLE};`).get(); if (!row) { throw new Error(`getConversationCount: Unable to get count of ${CONVERSATIONS_TABLE}`); } @@ -530,11 +526,9 @@ function fetchConvoMemoryDetails(convoId: string): SaveConversationReturn { function removeConversation(id: string | Array) { if (!Array.isArray(id)) { - assertGlobalInstance() - .prepare(`DELETE FROM ${CONVERSATIONS_TABLE} WHERE id = $id;`) - .run({ - id, - }); + assertGlobalInstance().prepare(`DELETE FROM ${CONVERSATIONS_TABLE} WHERE id = $id;`).run({ + id, + }); return; } @@ -778,9 +772,7 @@ function searchMessagesInConversation(query: string, conversationId: string, lim } function getMessageCount() { - const row = assertGlobalInstance() - .prepare(`SELECT count(*) from ${MESSAGES_TABLE};`) - .get(); + const row = assertGlobalInstance().prepare(`SELECT count(*) from ${MESSAGES_TABLE};`).get(); if (!row) { throw new Error(`getMessageCount: Unable to get count of ${MESSAGES_TABLE}`); @@ -953,19 +945,15 @@ function saveSeenMessageHash(data: any) { } function cleanLastHashes() { - assertGlobalInstance() - .prepare(`DELETE FROM ${LAST_HASHES_TABLE} WHERE expiresAt <= $now;`) - .run({ - now: Date.now(), - }); + assertGlobalInstance().prepare(`DELETE FROM ${LAST_HASHES_TABLE} WHERE expiresAt <= $now;`).run({ + now: Date.now(), + }); } function cleanSeenMessages() { - assertGlobalInstance() - .prepare('DELETE FROM seenMessages WHERE expiresAt <= $now;') - .run({ - now: Date.now(), - }); + assertGlobalInstance().prepare('DELETE FROM seenMessages WHERE expiresAt <= $now;').run({ + now: Date.now(), + }); } function saveMessages(arrayOfMessages: Array) { @@ -1738,19 +1726,15 @@ const unprocessed: UnprocessedDataNode = { }, getUnprocessedById: (id: string) => { - const row = assertGlobalInstance() - .prepare('SELECT * FROM unprocessed WHERE id = $id;') - .get({ - id, - }); + const row = assertGlobalInstance().prepare('SELECT * FROM unprocessed WHERE id = $id;').get({ + id, + }); return row; }, getUnprocessedCount: () => { - const row = assertGlobalInstance() - .prepare('SELECT count(*) from unprocessed;') - .get(); + const row = assertGlobalInstance().prepare('SELECT count(*) from unprocessed;').get(); if (!row) { throw new Error('getMessageCount: Unable to get count of unprocessed'); @@ -1772,15 +1756,11 @@ const unprocessed: UnprocessedDataNode = { console.error('removeUnprocessed only supports single ids at a time'); throw new Error('removeUnprocessed only supports single ids at a time'); } - assertGlobalInstance() - .prepare('DELETE FROM unprocessed WHERE id = $id;') - .run({ id }); + assertGlobalInstance().prepare('DELETE FROM unprocessed WHERE id = $id;').run({ id }); }, removeAllUnprocessed: () => { - assertGlobalInstance() - .prepare('DELETE FROM unprocessed;') - .run(); + assertGlobalInstance().prepare('DELETE FROM unprocessed;').run(); }, }; @@ -1870,9 +1850,7 @@ function removeAll() { } function removeAllConversations() { - assertGlobalInstance() - .prepare(`DELETE FROM ${CONVERSATIONS_TABLE};`) - .run(); + assertGlobalInstance().prepare(`DELETE FROM ${CONVERSATIONS_TABLE};`).run(); } function getMessagesWithVisualMediaAttachments(conversationId: string, limit?: number) { @@ -2220,9 +2198,7 @@ function removeV2OpenGroupRoom(conversationId: string) { function getEntriesCountInTable(tbl: string) { try { - const row = assertGlobalInstance() - .prepare(`SELECT count(*) from ${tbl};`) - .get(); + const row = assertGlobalInstance().prepare(`SELECT count(*) from ${tbl};`).get(); return row['count(*)']; } catch (e) { console.error(e); @@ -2387,8 +2363,9 @@ function cleanUpOldOpengroupsOnStart() { const messagesInConvoAfter = getMessagesCountByConversation(convoId); console.info( - `Cleaning ${countToRemove} messages older than 6 months in public convo: ${convoId} took ${Date.now() - - start}ms. Old message count: ${messagesInConvoBefore}, new message count: ${messagesInConvoAfter}` + `Cleaning ${countToRemove} messages older than 6 months in public convo: ${convoId} took ${ + Date.now() - start + }ms. Old message count: ${messagesInConvoBefore}, new message count: ${messagesInConvoAfter}` ); // no need to update the `unreadCount` during the migration anymore. diff --git a/ts/receiver/closedGroups.ts b/ts/receiver/closedGroups.ts index 4398eeb0d..ca27e7360 100644 --- a/ts/receiver/closedGroups.ts +++ b/ts/receiver/closedGroups.ts @@ -318,8 +318,8 @@ export async function handleNewClosedGroup( expireTimer === 0 ? 'off' : ReleasedFeatures.isDisappearMessageV2FeatureReleasedCached() - ? 'deleteAfterSend' - : 'legacy', + ? 'deleteAfterSend' + : 'legacy', providedExpireTimer: expireTimer, providedSource: sender, receivedAt: GetNetworkTime.getNowWithNetworkOffset(), diff --git a/ts/receiver/contentMessage.ts b/ts/receiver/contentMessage.ts index 4477b3c1f..5fe90263a 100644 --- a/ts/receiver/contentMessage.ts +++ b/ts/receiver/contentMessage.ts @@ -549,7 +549,8 @@ export async function innerHandleSwarmContentMessage({ await handleDataExtractionNotification({ envelope, - dataExtractionNotification: content.dataExtractionNotification as SignalService.DataExtractionNotification, + dataExtractionNotification: + content.dataExtractionNotification as SignalService.DataExtractionNotification, expireUpdate, messageHash, }); diff --git a/ts/receiver/opengroup.ts b/ts/receiver/opengroup.ts index fe412d2b7..790fa4916 100644 --- a/ts/receiver/opengroup.ts +++ b/ts/receiver/opengroup.ts @@ -68,11 +68,7 @@ const handleOpenGroupMessage = async ( return; } - if ( - !getConversationController() - .get(conversationId) - ?.isOpenGroupV2() - ) { + if (!getConversationController().get(conversationId)?.isOpenGroupV2()) { window?.log?.error('Received a message for an unknown convo or not an v2. Skipping'); return; } diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index f92b0ec74..22f2f1fee 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -153,8 +153,9 @@ function handleLinkPreviews(messageBody: string, messagePreview: any, message: M ); if (preview.length < incomingPreview.length) { window?.log?.info( - `${message.idForLogging()}: Eliminated ${preview.length - - incomingPreview.length} previews with invalid urls'` + `${message.idForLogging()}: Eliminated ${ + preview.length - incomingPreview.length + } previews with invalid urls'` ); } @@ -361,12 +362,9 @@ export async function handleMessageJob( messageHash: string ) { window?.log?.info( - `Starting handleMessageJob for message ${messageModel.idForLogging()}, ${messageModel.get( - 'serverTimestamp' - ) || - messageModel.get( - 'timestamp' - )} in conversation ${conversation.idForLogging()}, messageHash:${messageHash}` + `Starting handleMessageJob for message ${messageModel.idForLogging()}, ${ + messageModel.get('serverTimestamp') || messageModel.get('timestamp') + } in conversation ${conversation.idForLogging()}, messageHash:${messageHash}` ); const sendingDeviceConversation = await getConversationController().getOrCreateAndWait( diff --git a/ts/session/apis/open_group_api/sogsv3/knownBlindedkeys.ts b/ts/session/apis/open_group_api/sogsv3/knownBlindedkeys.ts index fd4e76043..e569eb40b 100644 --- a/ts/session/apis/open_group_api/sogsv3/knownBlindedkeys.ts +++ b/ts/session/apis/open_group_api/sogsv3/knownBlindedkeys.ts @@ -238,11 +238,7 @@ export function getUsBlindedInThatServer(convo: ConversationModel | string): str } const convoId = isString(convo) ? convo : convo.id; - if ( - !getConversationController() - .get(convoId) - ?.isOpenGroupV2() - ) { + if (!getConversationController().get(convoId)?.isOpenGroupV2()) { return undefined; } const room = OpenGroupData.getV2OpenGroupRoom(isString(convo) ? convo : convo.id); diff --git a/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts b/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts index d62a6558d..9a2edf381 100644 --- a/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts +++ b/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts @@ -259,9 +259,8 @@ const handleMessagesResponseV4 = async ( subrequestOption.messages.roomId ); - const messagesWithValidSignature = await filterOutMessagesInvalidSignature( - messagesWithoutDeleted - ); + const messagesWithValidSignature = + await filterOutMessagesInvalidSignature(messagesWithoutDeleted); // we do a first check with blinded ids. Looking to filter out messages we already received from that blinded id. const messagesFilteredBlindedIds = await filterDuplicatesFromDbAndIncomingV4( messagesWithValidSignature @@ -427,8 +426,8 @@ async function handleInboxOutboxMessages( unblindedIDOrBlinded, ConversationTypeEnum.PRIVATE ); - const serverConversationId = OpenGroupData.getV2OpenGroupRoomsByServerUrl(serverUrl)?.[0] - .conversationId; + const serverConversationId = + OpenGroupData.getV2OpenGroupRoomsByServerUrl(serverUrl)?.[0].conversationId; if (!serverConversationId) { throw new Error('serverConversationId needs to exist'); } diff --git a/ts/session/apis/snode_api/expireRequest.ts b/ts/session/apis/snode_api/expireRequest.ts index 6ad81d9a9..67418073d 100644 --- a/ts/session/apis/snode_api/expireRequest.ts +++ b/ts/session/apis/snode_api/expireRequest.ts @@ -457,8 +457,9 @@ export async function expireMessagesOnSnode( } catch (e) { const snodeStr = snode ? `${snode.ip}:${snode.port}` : 'null'; window?.log?.warn( - `[expireMessageOnSnode] ${e.code || ''}${e.message || - e} by ${ourPubKey} via snode:${snodeStr}` + `[expireMessageOnSnode] ${e.code || ''}${ + e.message || e + } by ${ourPubKey} via snode:${snodeStr}` ); throw e; } diff --git a/ts/session/apis/snode_api/getExpiriesRequest.ts b/ts/session/apis/snode_api/getExpiriesRequest.ts index 0b6b2f117..1b6cee6c8 100644 --- a/ts/session/apis/snode_api/getExpiriesRequest.ts +++ b/ts/session/apis/snode_api/getExpiriesRequest.ts @@ -191,8 +191,9 @@ export async function getExpiriesFromSnode({ messageHashes }: GetExpiriesFromSno } catch (e) { const snodeStr = snode ? `${snode.ip}:${snode.port}` : 'null'; window?.log?.warn( - `[getExpiriesFromSnode] ${e.code ? `${e.code} ` : ''}${e.message || - e} by ${ourPubKey} for ${messageHashes} via snode:${snodeStr}` + `[getExpiriesFromSnode] ${e.code ? `${e.code} ` : ''}${ + e.message || e + } by ${ourPubKey} for ${messageHashes} via snode:${snodeStr}` ); throw e; } diff --git a/ts/session/apis/snode_api/onions.ts b/ts/session/apis/snode_api/onions.ts index 8b8c61bf5..1478bce85 100644 --- a/ts/session/apis/snode_api/onions.ts +++ b/ts/session/apis/snode_api/onions.ts @@ -86,9 +86,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 @@ -98,9 +100,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 49b7a700a..4a335dfc6 100644 --- a/ts/session/apis/snode_api/swarmPolling.ts +++ b/ts/session/apis/snode_api/swarmPolling.ts @@ -180,9 +180,7 @@ export class SwarmPolling { const diff = now - group.lastPolledTimestamp; const loggingId = - getConversationController() - .get(group.pubkey.key) - ?.idForLogging() || group.pubkey.key; + getConversationController().get(group.pubkey.key)?.idForLogging() || group.pubkey.key; if (diff >= convoPollingTimeout) { window?.log?.debug( `Polling for ${loggingId}; timeout: ${convoPollingTimeout}; diff: ${diff} ` @@ -355,9 +353,8 @@ export class SwarmPolling { }) ); - const allDecryptedConfigMessages: Array> = []; + const allDecryptedConfigMessages: Array> = + []; for (let index = 0; index < extractedUserConfigMessage.length; index++) { const userConfigMessage = extractedUserConfigMessage[index]; diff --git a/ts/session/crypto/index.ts b/ts/session/crypto/index.ts index 3343b53e0..6581fe544 100644 --- a/ts/session/crypto/index.ts +++ b/ts/session/crypto/index.ts @@ -17,10 +17,7 @@ export async function getSodiumRenderer(): Promise { } export const sha256 = (s: string) => { - return crypto - .createHash('sha256') - .update(s) - .digest('base64'); + return crypto.createHash('sha256').update(s).digest('base64'); }; export const concatUInt8Array = (...args: Array): Uint8Array => { diff --git a/ts/session/disappearing_messages/index.ts b/ts/session/disappearing_messages/index.ts index ad6454a02..54ecf5101 100644 --- a/ts/session/disappearing_messages/index.ts +++ b/ts/session/disappearing_messages/index.ts @@ -59,9 +59,7 @@ async function destroyMessagesAndUpdateRedux( // trigger a refresh the last message for all those uniq conversation conversationWithChanges.forEach(convoIdToUpdate => { - getConversationController() - .get(convoIdToUpdate) - ?.updateLastMessage(); + getConversationController().get(convoIdToUpdate)?.updateLastMessage(); }); } @@ -91,12 +89,8 @@ async function destroyExpiredMessages() { window.log.info('destroyExpiredMessages: convosToRefresh:', convosToRefresh); await Promise.all( convosToRefresh.map(async c => { - getConversationController() - .get(c) - ?.updateLastMessage(); - return getConversationController() - .get(c) - ?.refreshInMemoryDetails(); + getConversationController().get(c)?.updateLastMessage(); + return getConversationController().get(c)?.refreshInMemoryDetails(); }) ); } catch (error) { @@ -278,9 +272,10 @@ 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 -): { expirationType: Exclude; expireTimer: number } { +function forcedDeleteAfterReadMsgSetting(convo: ConversationModel): { + expirationType: Exclude; + expireTimer: number; +} { if (convo.isMe() || !convo.isPrivate()) { throw new Error( 'forcedDeleteAfterReadMsgSetting can only be called with a private chat (excluding ourselves)' @@ -304,9 +299,10 @@ 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 -): { expirationType: Exclude; expireTimer: number } { +function forcedDeleteAfterSendMsgSetting(convo: ConversationModel): { + expirationType: Exclude; + expireTimer: number; +} { if (convo.isMe() || !convo.isPrivate()) { throw new Error( 'forcedDeleteAfterSendMsgSetting can only be called with a private chat (excluding ourselves)' @@ -359,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 = @@ -559,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/disappearing_messages/types.ts b/ts/session/disappearing_messages/types.ts index 550df0663..39c5574cd 100644 --- a/ts/session/disappearing_messages/types.ts +++ b/ts/session/disappearing_messages/types.ts @@ -1,5 +1,5 @@ // NOTE this must match Content.ExpirationType in the protobuf -export type DisappearingMessageType = typeof DisappearingMessageMode[number]; +export type DisappearingMessageType = (typeof DisappearingMessageMode)[number]; export const DisappearingMessageMode = ['unknown', 'deleteAfterRead', 'deleteAfterSend'] as const; export type DisappearAfterSendOnly = Exclude; @@ -11,7 +11,8 @@ export const DisappearingMessageConversationModes = [ // TODO legacy messages support will be removed in a future release 'legacy', ] as const; -export type DisappearingMessageConversationModeType = typeof DisappearingMessageConversationModes[number]; +export type DisappearingMessageConversationModeType = + (typeof DisappearingMessageConversationModes)[number]; // TODO legacy messages support will be removed in a future release // expirationType will no longer have an undefined option diff --git a/ts/session/messages/outgoing/ExpirableMessage.ts b/ts/session/messages/outgoing/ExpirableMessage.ts index 962acb379..dd9538e2c 100644 --- a/ts/session/messages/outgoing/ExpirableMessage.ts +++ b/ts/session/messages/outgoing/ExpirableMessage.ts @@ -30,10 +30,10 @@ export class ExpirableMessage extends ContentMessage { this.expirationType === 'deleteAfterSend' ? SignalService.Content.ExpirationType.DELETE_AFTER_SEND : this.expirationType === 'deleteAfterRead' - ? SignalService.Content.ExpirationType.DELETE_AFTER_READ - : this.expirationType === 'unknown' - ? SignalService.Content.ExpirationType.UNKNOWN - : undefined, + ? SignalService.Content.ExpirationType.DELETE_AFTER_READ + : this.expirationType === 'unknown' + ? SignalService.Content.ExpirationType.UNKNOWN + : undefined, expirationTimer: this.expireTimer && this.expireTimer > -1 ? this.expireTimer : undefined, }); } diff --git a/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts b/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts index 9f984c42e..e569d813b 100644 --- a/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts @@ -54,9 +54,8 @@ export const sendDataExtractionNotification = async ( window.log.warn('Not sending saving attachment notification for', attachmentSender); return; } - const { expirationType, expireTimer } = DisappearingMessages.forcedDeleteAfterReadMsgSetting( - convo - ); + const { expirationType, expireTimer } = + DisappearingMessages.forcedDeleteAfterReadMsgSetting(convo); // DataExtractionNotification are expiring with a forced DaR timer if a DaS is set. // It's because we want the DataExtractionNotification to stay in the swarm as much as possible, // but also expire on the recipient's side (and synced) once read. diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts index 326a66718..e28ff1dfb 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts @@ -6,9 +6,7 @@ export interface ClosedGroupEncryptionPairMessageParams extends ClosedGroupMessa } export class ClosedGroupEncryptionPairMessage extends ClosedGroupMessage { - private readonly encryptedKeyPairs: Array< - SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper - >; + private readonly encryptedKeyPairs: Array; constructor(params: ClosedGroupEncryptionPairMessageParams) { super(params); diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMessage.ts index fb53e2daa..60699cf5e 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMessage.ts @@ -43,7 +43,8 @@ export abstract class ClosedGroupMessage extends ExpirableMessage { public dataProto(): SignalService.DataMessage { const dataMessage = super.dataProto(); - dataMessage.closedGroupControlMessage = new SignalService.DataMessage.ClosedGroupControlMessage(); + dataMessage.closedGroupControlMessage = + new SignalService.DataMessage.ClosedGroupControlMessage(); return dataMessage; } diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNewMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNewMessage.ts index b2ff16102..53b0a76c4 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNewMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNewMessage.ts @@ -54,7 +54,8 @@ export class ClosedGroupNewMessage extends ClosedGroupMessage { public dataProto(): SignalService.DataMessage { const dataMessage = new SignalService.DataMessage(); - dataMessage.closedGroupControlMessage = new SignalService.DataMessage.ClosedGroupControlMessage(); + dataMessage.closedGroupControlMessage = + new SignalService.DataMessage.ClosedGroupControlMessage(); dataMessage.closedGroupControlMessage.type = SignalService.DataMessage.ClosedGroupControlMessage.Type.NEW; diff --git a/ts/session/onions/onionPath.ts b/ts/session/onions/onionPath.ts index d6df1e60b..d05229976 100644 --- a/ts/session/onions/onionPath.ts +++ b/ts/session/onions/onionPath.ts @@ -375,9 +375,9 @@ export async function selectGuardNodes(): Promise> { // Test all three nodes at once, wait for all to resolve or reject // eslint-disable-next-line no-await-in-loop - const idxOk = ( - await Promise.allSettled(candidateNodes.map(OnionPaths.testGuardNode)) - ).flatMap(p => (p.status === 'fulfilled' ? p.value : null)); + const idxOk = (await Promise.allSettled(candidateNodes.map(OnionPaths.testGuardNode))).flatMap( + p => (p.status === 'fulfilled' ? p.value : null) + ); const goodNodes = _.zip(idxOk, candidateNodes) .filter(x => x[0]) diff --git a/ts/session/sending/MessageSender.ts b/ts/session/sending/MessageSender.ts index a19fa7948..e2dcdf4ab 100644 --- a/ts/session/sending/MessageSender.ts +++ b/ts/session/sending/MessageSender.ts @@ -285,11 +285,7 @@ async function sendMessagesDataToSnode( } function encryptionBasedOnConversation(destination: PubKey) { - if ( - getConversationController() - .get(destination.key) - ?.isClosedGroup() - ) { + if (getConversationController().get(destination.key)?.isClosedGroup()) { return SignalService.Envelope.Type.CLOSED_GROUP_MESSAGE; } return SignalService.Envelope.Type.SESSION_MESSAGE; @@ -326,10 +322,8 @@ async function encryptMessageAndWrap( ttl, } = params; - const { - overRiddenTimestampBuffer, - networkTimestamp, - } = overwriteOutgoingTimestampWithNetworkTimestamp({ plainTextBuffer }); + const { overRiddenTimestampBuffer, networkTimestamp } = + overwriteOutgoingTimestampWithNetworkTimestamp({ plainTextBuffer }); const recipient = PubKey.cast(destination); const { envelopeType, cipherText } = await MessageEncrypter.encrypt( @@ -349,11 +343,9 @@ async function encryptMessageAndWrap( const overridenNamespace = !isNil(namespace) ? namespace - : getConversationController() - .get(recipient.key) - ?.isClosedGroup() - ? SnodeNamespaces.ClosedGroupMessage - : SnodeNamespaces.UserMessages; + : getConversationController().get(recipient.key)?.isClosedGroup() + ? SnodeNamespaces.ClosedGroupMessage + : SnodeNamespaces.UserMessages; return { data64, diff --git a/ts/session/utils/AttachmentsDownload.ts b/ts/session/utils/AttachmentsDownload.ts index 8bc14d72d..d9d54a2ac 100644 --- a/ts/session/utils/AttachmentsDownload.ts +++ b/ts/session/utils/AttachmentsDownload.ts @@ -216,11 +216,8 @@ async function _runJob(job: any) { // and tries to update the same message. found = await Data.getMessageById(messageId); if (found) { - const { - hasAttachments, - hasVisualMediaAttachments, - hasFileAttachments, - } = getAttachmentMetadata(found); + const { hasAttachments, hasVisualMediaAttachments, hasFileAttachments } = + getAttachmentMetadata(found); found.set({ hasAttachments, hasVisualMediaAttachments, hasFileAttachments }); } diff --git a/ts/session/utils/calling/CallManager.ts b/ts/session/utils/calling/CallManager.ts index 3b0bb2c95..cc411f0aa 100644 --- a/ts/session/utils/calling/CallManager.ts +++ b/ts/session/utils/calling/CallManager.ts @@ -425,9 +425,8 @@ async function createOfferAndSendIt(recipient: string, msgIdentifier: string | n ); // Note: we are forcing callMessages to be DaR if DaS, using the same timer - const { expirationType, expireTimer } = DisappearingMessages.forcedDeleteAfterReadMsgSetting( - convo - ); + const { expirationType, expireTimer } = + DisappearingMessages.forcedDeleteAfterReadMsgSetting(convo); const offerMessage = new CallMessage({ identifier: msgIdentifier || undefined, @@ -946,9 +945,8 @@ export async function rejectCallAlreadyAnotherCall(fromSender: string, forcedUUI rejectedCallUUIDS.add(forcedUUID); // Note: we are forcing callMessages to be DaR if DaS, using the same timer - const { expirationType, expireTimer } = DisappearingMessages.forcedDeleteAfterReadMsgSetting( - convo - ); + const { expirationType, expireTimer } = + DisappearingMessages.forcedDeleteAfterReadMsgSetting(convo); const rejectCallMessage = new CallMessage({ type: SignalService.CallMessage.Type.END_CALL, @@ -980,9 +978,8 @@ export async function USER_rejectIncomingCallRequest(fromSender: string) { throw new Error('USER_rejectIncomingCallRequest not existing convo'); } // Note: we are forcing callMessages to be DaR if DaS, using the same timer - const { expirationType, expireTimer } = DisappearingMessages.forcedDeleteAfterReadMsgSetting( - convo - ); + const { expirationType, expireTimer } = + DisappearingMessages.forcedDeleteAfterReadMsgSetting(convo); const endCallMessage = new CallMessage({ type: SignalService.CallMessage.Type.END_CALL, @@ -1032,9 +1029,8 @@ export async function USER_hangup(fromSender: string) { throw new Error('USER_hangup not existing convo'); } // Note: we are forcing callMessages to be DaR if DaS, using the same timer - const { expirationType, expireTimer } = DisappearingMessages.forcedDeleteAfterReadMsgSetting( - convo - ); + const { expirationType, expireTimer } = + DisappearingMessages.forcedDeleteAfterReadMsgSetting(convo); rejectedCallUUIDS.add(currentCallUUID); const endCallMessage = new CallMessage({ type: SignalService.CallMessage.Type.END_CALL, @@ -1117,9 +1113,8 @@ async function buildAnswerAndSendIt(sender: string, msgIdentifier: string | null throw new Error('buildAnswerAndSendIt not existing convo'); } // Note: we are forcing callMessages to be DaR if DaS, using the same timer - const { expirationType, expireTimer } = DisappearingMessages.forcedDeleteAfterReadMsgSetting( - convo - ); + const { expirationType, expireTimer } = + DisappearingMessages.forcedDeleteAfterReadMsgSetting(convo); const answerSdp = answer.sdp; const callAnswerMessage = new CallMessage({ identifier: msgIdentifier || undefined, @@ -1157,9 +1152,7 @@ function getCachedMessageFromCallMessage( } async function isUserApprovedOrWeSentAMessage(user: string) { - const isApproved = getConversationController() - .get(user) - ?.isApproved(); + const isApproved = getConversationController().get(user)?.isApproved(); if (isApproved) { return true; @@ -1524,10 +1517,7 @@ function pushCallMessageToCallCache( callMessage: CachedCallMessageType ) { createCallCacheForPubkeyAndUUID(sender, uuid); - callCache - .get(sender) - ?.get(uuid) - ?.push(callMessage); + callCache.get(sender)?.get(uuid)?.push(callMessage); } /** diff --git a/ts/session/utils/job_runners/JobDeserialization.ts b/ts/session/utils/job_runners/JobDeserialization.ts index 363761da0..0957a6aa4 100644 --- a/ts/session/utils/job_runners/JobDeserialization.ts +++ b/ts/session/utils/job_runners/JobDeserialization.ts @@ -16,13 +16,13 @@ export function persistedJobFromData( switch (data.jobType) { case 'ConfigurationSyncJobType': - return (new ConfigurationSync.ConfigurationSyncJob(data) as unknown) as PersistedJob; + return new ConfigurationSync.ConfigurationSyncJob(data) as unknown as PersistedJob; case 'AvatarDownloadJobType': - return (new AvatarDownload.AvatarDownloadJob(data) as unknown) as PersistedJob; + return new AvatarDownload.AvatarDownloadJob(data) as unknown as PersistedJob; case 'FakeSleepForJobType': - return (new FakeSleepForJob(data) as unknown) as PersistedJob; + return new FakeSleepForJob(data) as unknown as PersistedJob; case 'FakeSleepForJobMultiType': - return (new FakeSleepForMultiJob(data) as unknown) as PersistedJob; + return new FakeSleepForMultiJob(data) as unknown as PersistedJob; default: window?.log?.error('unknown persisted job type:', (data as any).jobType); return null; diff --git a/ts/session/utils/job_runners/JobRunner.ts b/ts/session/utils/job_runners/JobRunner.ts index fc6f1566f..f3ed3d886 100644 --- a/ts/session/utils/job_runners/JobRunner.ts +++ b/ts/session/utils/job_runners/JobRunner.ts @@ -235,13 +235,16 @@ export class PersistedJobRunner { global.clearTimeout(this.nextJobStartTimer); } // plan a timer to wakeup when that timer is reached. - this.nextJobStartTimer = global.setTimeout(() => { - if (this.nextJobStartTimer) { - global.clearTimeout(this.nextJobStartTimer); - this.nextJobStartTimer = null; - } - void this.runNextJob(); - }, Math.max(nextJob.persistedData.nextAttemptTimestamp - Date.now(), 1)); + this.nextJobStartTimer = global.setTimeout( + () => { + if (this.nextJobStartTimer) { + global.clearTimeout(this.nextJobStartTimer); + this.nextJobStartTimer = null; + } + void this.runNextJob(); + }, + Math.max(nextJob.persistedData.nextAttemptTimestamp - Date.now(), 1) + ); return 'job_deferred'; } diff --git a/ts/session/utils/libsession/libsession_utils_contacts.ts b/ts/session/utils/libsession/libsession_utils_contacts.ts index ec3fdb6f0..a704da1a5 100644 --- a/ts/session/utils/libsession/libsession_utils_contacts.ts +++ b/ts/session/utils/libsession/libsession_utils_contacts.ts @@ -101,15 +101,11 @@ async function refreshMappedValue(id: string, duringAppStart = false) { if (fromWrapper) { setMappedValue(fromWrapper); if (!duringAppStart) { - getConversationController() - .get(id) - ?.triggerUIRefresh(); + getConversationController().get(id)?.triggerUIRefresh(); } } else if (mappedContactWrapperValues.delete(id)) { if (!duringAppStart) { - getConversationController() - .get(id) - ?.triggerUIRefresh(); + getConversationController().get(id)?.triggerUIRefresh(); } } } diff --git a/ts/session/utils/libsession/libsession_utils_convo_info_volatile.ts b/ts/session/utils/libsession/libsession_utils_convo_info_volatile.ts index dbde50150..a426ce1e6 100644 --- a/ts/session/utils/libsession/libsession_utils_convo_info_volatile.ts +++ b/ts/session/utils/libsession/libsession_utils_convo_info_volatile.ts @@ -51,8 +51,8 @@ function getConvoType(convo: ConversationModel): ConvoVolatileType { SessionUtilUserProfile.isUserProfileToStoreInWrapper(convo.id) ? '1o1' : SessionUtilUserGroups.isCommunityToStoreInWrapper(convo) - ? 'Community' - : 'LegacyGroup'; + ? 'Community' + : 'LegacyGroup'; return convoType; } @@ -180,9 +180,8 @@ async function refreshConvoVolatileCached( refreshed = true; break; case 'LegacyGroup': - const fromWrapperLegacyGroup = await ConvoInfoVolatileWrapperActions.getLegacyGroup( - convoId - ); + const fromWrapperLegacyGroup = + await ConvoInfoVolatileWrapperActions.getLegacyGroup(convoId); if (fromWrapperLegacyGroup) { mappedLegacyGroupWrapperValues.set(convoId, fromWrapperLegacyGroup); } @@ -201,9 +200,7 @@ async function refreshConvoVolatileCached( } if (refreshed && !duringAppStart) { - getConversationController() - .get(convoId) - ?.triggerUIRefresh(); + getConversationController().get(convoId)?.triggerUIRefresh(); } } catch (e) { window.log.info(`refreshMappedValue for volatile convoID: ${convoId}`, e.message); diff --git a/ts/session/utils/sync/syncUtils.ts b/ts/session/utils/sync/syncUtils.ts index 2504ea72b..7363fac74 100644 --- a/ts/session/utils/sync/syncUtils.ts +++ b/ts/session/utils/sync/syncUtils.ts @@ -190,9 +190,9 @@ const getValidClosedGroups = async (convos: Array) => { }) ); - const onlyValidClosedGroup = closedGroups.filter(m => m !== null) as Array< - ConfigurationMessageClosedGroup - >; + const onlyValidClosedGroup = closedGroups.filter( + m => m !== null + ) as Array; return onlyValidClosedGroup; }; @@ -268,9 +268,8 @@ export const getCurrentConfigurationMessage = async ( } const ourProfileKeyHex = - getConversationController() - .get(UserUtils.getOurPubKeyStrFromCache()) - ?.get('profileKey') || null; + getConversationController().get(UserUtils.getOurPubKeyStrFromCache())?.get('profileKey') || + null; const profileKey = ourProfileKeyHex ? fromHexToArray(ourProfileKeyHex) : undefined; const profilePicture = ourConvo?.get('avatarPointer') || undefined; diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 35040ccde..75ec88a08 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -378,13 +378,11 @@ async function getMessages({ return { messagesProps: [], quotesProps: {} }; } - const { - messages: messagesCollection, - quotes: quotesCollection, - } = await Data.getMessagesByConversation(conversationKey, { - messageId, - returnQuotes: true, - }); + const { messages: messagesCollection, quotes: quotesCollection } = + await Data.getMessagesByConversation(conversationKey, { + messageId, + returnQuotes: true, + }); const messagesProps: Array = messagesCollection.models.map( m => m.getMessageModelProps() @@ -1174,13 +1172,11 @@ export async function openConversationToSpecificMessage(args: { const { conversationKey, messageIdToNavigateTo, shouldHighlightMessage } = args; await unmarkAsForcedUnread(conversationKey); - const { - messagesProps: messagesAroundThisMessage, - quotesProps: quotesAroundThisMessage, - } = await getMessages({ - conversationKey, - messageId: messageIdToNavigateTo, - }); + const { messagesProps: messagesAroundThisMessage, quotesProps: quotesAroundThisMessage } = + await getMessages({ + conversationKey, + messageId: messageIdToNavigateTo, + }); const mostRecentMessageIdOnOpen = await Data.getLastMessageIdInConversation(conversationKey); diff --git a/ts/state/ducks/defaultRooms.tsx b/ts/state/ducks/defaultRooms.tsx index ffca2b1d9..59ebaec72 100644 --- a/ts/state/ducks/defaultRooms.tsx +++ b/ts/state/ducks/defaultRooms.tsx @@ -52,9 +52,6 @@ const defaultRoomsSlice = createSlice({ }); const { actions, reducer } = defaultRoomsSlice; -export const { - updateDefaultRooms, - updateDefaultBase64RoomData, - updateDefaultRoomsInProgress, -} = actions; +export const { updateDefaultRooms, updateDefaultBase64RoomData, updateDefaultRoomsInProgress } = + actions; export const defaultRoomReducer = reducer; diff --git a/ts/state/ducks/section.tsx b/ts/state/ducks/section.tsx index 3c67f25ee..5060af4cc 100644 --- a/ts/state/ducks/section.tsx +++ b/ts/state/ducks/section.tsx @@ -159,7 +159,7 @@ export const reducer = ( case FOCUS_SECTION: // if we change to something else than settings, reset the focused settings section // eslint-disable-next-line no-case-declarations - const castedPayload = (payload as unknown) as SectionType; + const castedPayload = payload as unknown as SectionType; if (castedPayload !== SectionType.Settings) { return { diff --git a/ts/state/ducks/settings.tsx b/ts/state/ducks/settings.tsx index 74b7c86c2..318e7fc23 100644 --- a/ts/state/ducks/settings.tsx +++ b/ts/state/ducks/settings.tsx @@ -13,7 +13,7 @@ const SettingsBoolsKeyTrackedInRedux = [ ] as const; export type SettingsState = { - settingsBools: Record; + settingsBools: Record<(typeof SettingsBoolsKeyTrackedInRedux)[number], boolean>; }; export function getSettingsInitialState() { @@ -28,7 +28,7 @@ export function getSettingsInitialState() { }; } -function isTrackedBoolean(key: string): key is typeof SettingsBoolsKeyTrackedInRedux[number] { +function isTrackedBoolean(key: string): key is (typeof SettingsBoolsKeyTrackedInRedux)[number] { return SettingsBoolsKeyTrackedInRedux.indexOf(key as any) !== -1; } @@ -97,9 +97,6 @@ const settingsSlice = createSlice({ }); const { actions, reducer } = settingsSlice; -export const { - updateSettingsBoolValue, - deleteSettingsBoolValue, - updateAllOnStorageReady, -} = actions; +export const { updateSettingsBoolValue, deleteSettingsBoolValue, updateAllOnStorageReady } = + actions; export const settingsReducer = reducer; diff --git a/ts/state/ducks/userConfig.tsx b/ts/state/ducks/userConfig.tsx index 502367b87..e18171747 100644 --- a/ts/state/ducks/userConfig.tsx +++ b/ts/state/ducks/userConfig.tsx @@ -36,11 +36,8 @@ const userConfigSlice = createSlice({ }); const { actions, reducer } = userConfigSlice; -export const { - toggleAudioAutoplay, - disableRecoveryPhrasePrompt, - hideMessageRequestBanner, -} = actions; +export const { toggleAudioAutoplay, disableRecoveryPhrasePrompt, hideMessageRequestBanner } = + actions; export const userConfigReducer = reducer; export function showMessageRequestBannerOutsideRedux() { diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 981e426e3..16a46412b 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -724,39 +724,40 @@ export const getMessagePropsByMessageId = createSelector( } ); -export const getMessageReactsProps = createSelector(getMessagePropsByMessageId, (props): - | MessageReactsSelectorProps - | undefined => { - if (!props || isEmpty(props)) { - return undefined; - } +export const getMessageReactsProps = createSelector( + getMessagePropsByMessageId, + (props): MessageReactsSelectorProps | undefined => { + if (!props || isEmpty(props)) { + return undefined; + } - const msgProps: MessageReactsSelectorProps = pick(props.propsForMessage, [ - 'convoId', - 'conversationType', - 'reacts', - 'serverId', - ]); - - if (msgProps.reacts) { - // NOTE we don't want to render reactions that have 'senders' as an object this is a deprecated type used during development 25/08/2022 - const oldReactions = Object.values(msgProps.reacts).filter( - reaction => !Array.isArray(reaction.senders) - ); + const msgProps: MessageReactsSelectorProps = pick(props.propsForMessage, [ + 'convoId', + 'conversationType', + 'reacts', + 'serverId', + ]); + + if (msgProps.reacts) { + // NOTE we don't want to render reactions that have 'senders' as an object this is a deprecated type used during development 25/08/2022 + const oldReactions = Object.values(msgProps.reacts).filter( + reaction => !Array.isArray(reaction.senders) + ); + + if (oldReactions.length > 0) { + msgProps.reacts = undefined; + return msgProps; + } - if (oldReactions.length > 0) { - msgProps.reacts = undefined; - return msgProps; + const sortedReacts = Object.entries(msgProps.reacts).sort((a, b) => { + return a[1].index < b[1].index ? -1 : a[1].index > b[1].index ? 1 : 0; + }); + msgProps.sortedReacts = sortedReacts; } - const sortedReacts = Object.entries(msgProps.reacts).sort((a, b) => { - return a[1].index < b[1].index ? -1 : a[1].index > b[1].index ? 1 : 0; - }); - msgProps.sortedReacts = sortedReacts; + return msgProps; } - - return msgProps; -}); +); export const getMessageQuoteProps = createSelector( getConversationLookup, @@ -840,45 +841,47 @@ export const getMessageQuoteProps = createSelector( } ); -export const getMessageTextProps = createSelector(getMessagePropsByMessageId, (props): - | MessageTextSelectorProps - | undefined => { - if (!props || isEmpty(props)) { - return undefined; - } - - const msgProps: MessageTextSelectorProps = pick(props.propsForMessage, [ - 'direction', - 'status', - 'text', - 'isDeleted', - 'conversationType', - ]); +export const getMessageTextProps = createSelector( + getMessagePropsByMessageId, + (props): MessageTextSelectorProps | undefined => { + if (!props || isEmpty(props)) { + return undefined; + } - return msgProps; -}); + const msgProps: MessageTextSelectorProps = pick(props.propsForMessage, [ + 'direction', + 'status', + 'text', + 'isDeleted', + 'conversationType', + ]); -export const getMessageAttachmentProps = createSelector(getMessagePropsByMessageId, (props): - | MessageAttachmentSelectorProps - | undefined => { - if (!props || isEmpty(props)) { - return undefined; + return msgProps; } +); - const msgProps: MessageAttachmentSelectorProps = { - attachments: props.propsForMessage.attachments || [], - ...pick(props.propsForMessage, [ - 'direction', - 'isTrustedForAttachmentDownload', - 'timestamp', - 'serverTimestamp', - 'sender', - 'convoId', - ]), - }; +export const getMessageAttachmentProps = createSelector( + getMessagePropsByMessageId, + (props): MessageAttachmentSelectorProps | undefined => { + if (!props || isEmpty(props)) { + return undefined; + } - return msgProps; -}); + const msgProps: MessageAttachmentSelectorProps = { + attachments: props.propsForMessage.attachments || [], + ...pick(props.propsForMessage, [ + 'direction', + 'isTrustedForAttachmentDownload', + 'timestamp', + 'serverTimestamp', + 'sender', + 'convoId', + ]), + }; + + return msgProps; + } +); export const getIsMessageSelected = createSelector( getMessagePropsByMessageId, @@ -894,27 +897,28 @@ export const getIsMessageSelected = createSelector( } ); -export const getMessageContentSelectorProps = createSelector(getMessagePropsByMessageId, (props): - | MessageContentSelectorProps - | undefined => { - if (!props || isEmpty(props)) { - return undefined; - } +export const getMessageContentSelectorProps = createSelector( + getMessagePropsByMessageId, + (props): MessageContentSelectorProps | undefined => { + if (!props || isEmpty(props)) { + return undefined; + } - const msgProps: MessageContentSelectorProps = { - ...pick(props.propsForMessage, [ - 'direction', - 'serverTimestamp', - 'text', - 'timestamp', - 'previews', - 'quote', - 'attachments', - ]), - }; + const msgProps: MessageContentSelectorProps = { + ...pick(props.propsForMessage, [ + 'direction', + 'serverTimestamp', + 'text', + 'timestamp', + 'previews', + 'quote', + 'attachments', + ]), + }; - return msgProps; -}); + return msgProps; + } +); export const getMessageContentWithStatusesSelectorProps = createSelector( getMessagePropsByMessageId, diff --git a/ts/test/session/unit/crypto/MessageEncrypter_test.ts b/ts/test/session/unit/crypto/MessageEncrypter_test.ts index 27bc167c6..d7658024d 100644 --- a/ts/test/session/unit/crypto/MessageEncrypter_test.ts +++ b/ts/test/session/unit/crypto/MessageEncrypter_test.ts @@ -16,73 +16,12 @@ import { SessionKeyPair } from '../../../../receiver/keypairs'; export const TEST_identityKeyPair: SessionKeyPair = { pubKey: new Uint8Array([ - 5, - 44, - 2, - 168, - 162, - 203, - 50, - 66, - 136, - 81, - 30, - 221, - 57, - 245, - 1, - 148, - 162, - 194, - 255, - 47, - 134, - 104, - 180, - 207, - 188, - 18, - 71, - 62, - 58, - 107, - 23, - 92, - 97, + 5, 44, 2, 168, 162, 203, 50, 66, 136, 81, 30, 221, 57, 245, 1, 148, 162, 194, 255, 47, 134, 104, + 180, 207, 188, 18, 71, 62, 58, 107, 23, 92, 97, ]), privKey: new Uint8Array([ - 200, - 45, - 226, - 75, - 253, - 235, - 213, - 108, - 187, - 188, - 217, - 9, - 51, - 105, - 65, - 15, - 97, - 36, - 233, - 33, - 21, - 31, - 7, - 90, - 145, - 30, - 52, - 254, - 47, - 162, - 192, - 105, + 200, 45, 226, 75, 253, 235, 213, 108, 187, 188, 217, 9, 51, 105, 65, 15, 97, 36, 233, 33, 21, + 31, 7, 90, 145, 30, 52, 254, 47, 162, 192, 105, ]), ed25519KeyPair: { privateKey: new Uint8Array(), diff --git a/ts/test/session/unit/crypto/OpenGroupAuthentication_test.ts b/ts/test/session/unit/crypto/OpenGroupAuthentication_test.ts index f925d4c45..c5af953d9 100644 --- a/ts/test/session/unit/crypto/OpenGroupAuthentication_test.ts +++ b/ts/test/session/unit/crypto/OpenGroupAuthentication_test.ts @@ -13,38 +13,8 @@ chai.use(chaiBytes); describe('OpenGroupAuthentication', () => { const secondPartPrivKey = new Uint8Array([ - 186, - 198, - 231, - 30, - 253, - 125, - 250, - 74, - 131, - 201, - 142, - 210, - 79, - 37, - 74, - 178, - 194, - 103, - 249, - 204, - 219, - 23, - 42, - 82, - 128, - 160, - 68, - 74, - 210, - 78, - 137, - 204, + 186, 198, 231, 30, 253, 125, 250, 74, 131, 201, 142, 210, 79, 37, 74, 178, 194, 103, 249, 204, + 219, 23, 42, 82, 128, 160, 68, 74, 210, 78, 137, 204, ]); const signingKeysA: ByteKeyPair = { // 881132ee03dbd2da065aa4c94f96081f62142dc8011d1b7a00de83e4aab38ce4 @@ -89,104 +59,14 @@ describe('OpenGroupAuthentication', () => { const signingKeysB: ByteKeyPair = { privKeyBytes: new Uint8Array([ - 130, - 56, - 83, - 227, - 58, - 149, - 251, - 148, - 119, - 85, - 180, - 81, - 17, - 190, - 245, - 33, - 219, - 6, - 246, - 238, - 110, - 61, - 191, - 133, - 244, - 223, - 32, - 32, - 121, - 172, - 138, - 198, - 215, - 25, - 249, - 139, - 235, - 31, - 251, - 12, - 100, - 87, - 84, - 131, - 231, - 45, - 87, - 251, - 204, - 133, - 20, - 3, - 118, - 71, - 29, - 47, - 245, - 62, - 216, - 163, - 254, - 248, - 195, - 109, + 130, 56, 83, 227, 58, 149, 251, 148, 119, 85, 180, 81, 17, 190, 245, 33, 219, 6, 246, 238, + 110, 61, 191, 133, 244, 223, 32, 32, 121, 172, 138, 198, 215, 25, 249, 139, 235, 31, 251, 12, + 100, 87, 84, 131, 231, 45, 87, 251, 204, 133, 20, 3, 118, 71, 29, 47, 245, 62, 216, 163, 254, + 248, 195, 109, ]), pubKeyBytes: new Uint8Array([ - 215, - 25, - 249, - 139, - 235, - 31, - 251, - 12, - 100, - 87, - 84, - 131, - 231, - 45, - 87, - 251, - 204, - 133, - 20, - 3, - 118, - 71, - 29, - 47, - 245, - 62, - 216, - 163, - 254, - 248, - 195, - 109, + 215, 25, 249, 139, 235, 31, 251, 12, 100, 87, 84, 131, 231, 45, 87, 251, 204, 133, 20, 3, 118, + 71, 29, 47, 245, 62, 216, 163, 254, 248, 195, 109, ]), }; const serverPubKey = new Uint8Array( @@ -395,12 +275,14 @@ const decryptBlindedMessage = async ( aSignKeyBytes: ByteKeyPair, bSignKeyBytes: ByteKeyPair, serverPubKey: Uint8Array -): Promise<| { - messageText: string; - senderED25519PubKey: string; - senderSessionId: string; - } -| undefined> => { +): Promise< + | { + messageText: string; + senderED25519PubKey: string; + senderSessionId: string; + } + | undefined +> => { const sodium = await getSodiumRenderer(); const aBlindingValues = SogsBlinding.getBlindingValues(serverPubKey, aSignKeyBytes, sodium); diff --git a/ts/test/session/unit/disappearing_messages/DisappearingMessage_test.ts b/ts/test/session/unit/disappearing_messages/DisappearingMessage_test.ts index 8101c87dc..519ac15eb 100644 --- a/ts/test/session/unit/disappearing_messages/DisappearingMessage_test.ts +++ b/ts/test/session/unit/disappearing_messages/DisappearingMessage_test.ts @@ -305,9 +305,8 @@ describe('DisappearingMessage', () => { }); it('if the type and expireTimer are undefined then the conversation mode is off', async () => { const conversation = new ConversationModel({ ...conversationArgs }); - const conversationMode = DisappearingMessages.changeToDisappearingConversationMode( - conversation - ); + const conversationMode = + DisappearingMessages.changeToDisappearingConversationMode(conversation); expect(conversationMode, 'returns off').to.be.eq('off'); }); diff --git a/ts/test/session/unit/disappearing_messages/ExpireRequest_test.ts b/ts/test/session/unit/disappearing_messages/ExpireRequest_test.ts index d749c7633..1ed906c37 100644 --- a/ts/test/session/unit/disappearing_messages/ExpireRequest_test.ts +++ b/ts/test/session/unit/disappearing_messages/ExpireRequest_test.ts @@ -44,9 +44,8 @@ describe('ExpireRequest', () => { }; it('builds a request with just the messageHash and expireTimer of 1 minute', async () => { - const request: UpdateExpiryOnNodeSubRequest | null = await buildExpireRequestSingleExpiry( - props - ); + const request: UpdateExpiryOnNodeSubRequest | null = + await buildExpireRequestSingleExpiry(props); expect(request, 'should not return null').to.not.be.null; expect(request, 'should not return undefined').to.not.be.undefined; diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts index ae05f62fe..6a08da0f8 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts @@ -67,9 +67,8 @@ describe('libsession_user_profile', () => { Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(SessionUtilUserProfile, 'isUserProfileToStoreInWrapper').returns(true); - const wrapperUserProfile = await SessionUtilUserProfile.insertUserProfileIntoWrapper( - ourNumber - ); + const wrapperUserProfile = + await SessionUtilUserProfile.insertUserProfileIntoWrapper(ourNumber); expect(wrapperUserProfile, 'something should be returned from the wrapper').to.not.be.null; if (!wrapperUserProfile) { @@ -123,9 +122,8 @@ describe('libsession_user_profile', () => { Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(SessionUtilUserProfile, 'isUserProfileToStoreInWrapper').returns(true); - const wrapperUserProfile = await SessionUtilUserProfile.insertUserProfileIntoWrapper( - ourNumber - ); + const wrapperUserProfile = + await SessionUtilUserProfile.insertUserProfileIntoWrapper(ourNumber); expect(wrapperUserProfile, 'something should be returned from the wrapper').to.not.be.null; if (!wrapperUserProfile) { diff --git a/ts/test/session/unit/messages/ChatMessage_test.ts b/ts/test/session/unit/messages/ChatMessage_test.ts index f297e45f0..d2f525b1a 100644 --- a/ts/test/session/unit/messages/ChatMessage_test.ts +++ b/ts/test/session/unit/messages/ChatMessage_test.ts @@ -131,9 +131,7 @@ describe('VisibleMessage', () => { const plainText = message.plainTextBuffer(); const decoded = SignalService.Content.decode(plainText); expect(decoded.dataMessage?.preview).to.have.lengthOf(1); - expect(decoded.dataMessage) - .to.have.nested.property('preview[0].url') - .to.be.deep.equal('url'); + expect(decoded.dataMessage).to.have.nested.property('preview[0].url').to.be.deep.equal('url'); expect(decoded.dataMessage) .to.have.nested.property('preview[0].title') .to.be.deep.equal('title'); diff --git a/ts/test/session/unit/messages/closed_groups/ClosedGroupChatMessage_test.ts b/ts/test/session/unit/messages/closed_groups/ClosedGroupChatMessage_test.ts index c9d279932..3cd04aae2 100644 --- a/ts/test/session/unit/messages/closed_groups/ClosedGroupChatMessage_test.ts +++ b/ts/test/session/unit/messages/closed_groups/ClosedGroupChatMessage_test.ts @@ -41,9 +41,7 @@ describe('ClosedGroupVisibleMessage', () => { expect(decoded.dataMessage).to.have.deep.property('body', 'body'); // we use the timestamp of the chatMessage as parent timestamp - expect(message) - .to.have.property('timestamp') - .to.be.equal(chatMessage.timestamp); + expect(message).to.have.property('timestamp').to.be.equal(chatMessage.timestamp); }); it('correct ttl', () => { diff --git a/ts/test/session/unit/padding/Padding_test.ts b/ts/test/session/unit/padding/Padding_test.ts index 1577c364d..376bf5b65 100644 --- a/ts/test/session/unit/padding/Padding_test.ts +++ b/ts/test/session/unit/padding/Padding_test.ts @@ -94,25 +94,7 @@ describe('Padding', () => { it('remove padding', () => { const expectedSize = 10; const paddedBuffer = new Uint8Array([ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 128, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 0, 0, 0, 0, 0, 0, 0, 0, ]); const unpaddedMessage = removeMessagePadding(paddedBuffer); diff --git a/ts/test/session/unit/utils/Messages_test.ts b/ts/test/session/unit/utils/Messages_test.ts index f839e02ca..696aebbab 100644 --- a/ts/test/session/unit/utils/Messages_test.ts +++ b/ts/test/session/unit/utils/Messages_test.ts @@ -199,9 +199,8 @@ describe('Message Utils', () => { it('passing ClosedGroupEncryptionPairMessage returns ClosedGroup', async () => { const device = TestUtils.generateFakePubKey(); - const fakeWrappers = new Array< - SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper - >(); + const fakeWrappers = + new Array(); fakeWrappers.push( new SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper({ publicKey: new Uint8Array(8), @@ -221,9 +220,8 @@ describe('Message Utils', () => { it('passing ClosedGroupEncryptionKeyPairReply returns Fallback', async () => { const device = TestUtils.generateFakePubKey(); - const fakeWrappers = new Array< - SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper - >(); + const fakeWrappers = + new Array(); fakeWrappers.push( new SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper({ publicKey: new Uint8Array(8), diff --git a/ts/test/session/unit/utils/Promise_test.ts b/ts/test/session/unit/utils/Promise_test.ts index 075ebc260..80f0c5ae0 100644 --- a/ts/test/session/unit/utils/Promise_test.ts +++ b/ts/test/session/unit/utils/Promise_test.ts @@ -21,7 +21,7 @@ describe('Promise Utils', () => { let pollSpy: sinon.SinonSpy< [ (done: (arg: any) => void) => Promise | void, - (Partial | undefined)? + (Partial | undefined)?, ], Promise >; diff --git a/ts/test/session/unit/utils/String_test.ts b/ts/test/session/unit/utils/String_test.ts index 4813618fb..3f8bcf9c9 100644 --- a/ts/test/session/unit/utils/String_test.ts +++ b/ts/test/session/unit/utils/String_test.ts @@ -83,9 +83,7 @@ describe('String Utils', () => { it('can encode huge string', () => { const stringSize = 2 ** 16; - const testString = Array(stringSize) - .fill('0') - .join(''); + const testString = Array(stringSize).fill('0').join(''); const allEncodedings = (['base64', 'hex', 'binary', 'utf8'] as Array).map(e => StringUtils.encode(testString, e) @@ -145,9 +143,7 @@ describe('String Utils', () => { it('can decode huge buffer', () => { const bytes = 2 ** 16; - const bufferString = Array(bytes) - .fill('A') - .join(''); + const bufferString = Array(bytes).fill('A').join(''); const buffer = ByteBuffer.fromUTF8(bufferString); const encodings = ['base64', 'hex', 'binary', 'utf8'] as Array; diff --git a/ts/test/test-utils/utils/stubbing.ts b/ts/test/test-utils/utils/stubbing.ts index 867e60e3e..bbfe547e6 100644 --- a/ts/test/test-utils/utils/stubbing.ts +++ b/ts/test/test-utils/utils/stubbing.ts @@ -52,7 +52,7 @@ export function stubLibSessionWorker(value: any) { } export function stubCreateObjectUrl() { - (global as any).URL = function() {}; + (global as any).URL = function () {}; (global as any).URL.createObjectURL = () => { return `${Date.now()}:${Math.floor(Math.random() * 1000)}`; }; diff --git a/ts/types/attachments/migrations.ts b/ts/types/attachments/migrations.ts index d2bae6eb2..c42ec185d 100644 --- a/ts/types/attachments/migrations.ts +++ b/ts/types/attachments/migrations.ts @@ -201,23 +201,25 @@ type CaptureDimensionType = { contentType: string; path: string }; export const captureDimensionsAndScreenshot = async ( attachment: CaptureDimensionType -): Promise => { +): Promise< + CaptureDimensionType & { + width?: number; + height?: number; + + thumbnail: { + path: string; + contentType: string; + width: number; + height: number; + } | null; + screenshot: { + path: string; + contentType: string; + width: number; + height: number; + } | null; + } +> => { const { contentType } = attachment; if ( diff --git a/ts/types/message/initializeAttachmentMetadata.ts b/ts/types/message/initializeAttachmentMetadata.ts index 7f41c7003..6e06045b3 100644 --- a/ts/types/message/initializeAttachmentMetadata.ts +++ b/ts/types/message/initializeAttachmentMetadata.ts @@ -1,9 +1,10 @@ import { MessageModel } from '../../models/message'; import * as Attachment from '../Attachment'; -const hasAttachmentInMessage = (predicate: (value: Attachment.Attachment) => boolean) => ( - message: MessageModel -): boolean => Boolean((message.get('attachments') || []).some(predicate)); +const hasAttachmentInMessage = + (predicate: (value: Attachment.Attachment) => boolean) => + (message: MessageModel): boolean => + Boolean((message.get('attachments') || []).some(predicate)); export const hasFileAttachmentInMessage = hasAttachmentInMessage(Attachment.isFile); export const hasVisualMediaAttachmentInMessage = hasAttachmentInMessage(Attachment.isVisualMedia); diff --git a/ts/updater/updater.ts b/ts/updater/updater.ts index 84f2c8cdf..4abe99287 100644 --- a/ts/updater/updater.ts +++ b/ts/updater/updater.ts @@ -40,22 +40,28 @@ export async function start( autoUpdater.logger = logger; autoUpdater.autoDownload = false; - interval = global.setInterval(async () => { - try { - await checkForUpdates(getMainWindow, messages, logger); - } catch (error) { - logger.error('auto-update: error:', getPrintableError(error)); - } - }, 1000 * 60 * 10); // trigger and try to update every 10 minutes to let the file gets downloaded if we are updating + interval = global.setInterval( + async () => { + try { + await checkForUpdates(getMainWindow, messages, logger); + } catch (error) { + logger.error('auto-update: error:', getPrintableError(error)); + } + }, + 1000 * 60 * 10 + ); // trigger and try to update every 10 minutes to let the file gets downloaded if we are updating stopped = false; - global.setTimeout(async () => { - try { - await checkForUpdates(getMainWindow, messages, logger); - } catch (error) { - logger.error('auto-update: error:', getPrintableError(error)); - } - }, 2 * 60 * 1000); // we do checks from the fileserver every 1 minute. + global.setTimeout( + async () => { + try { + await checkForUpdates(getMainWindow, messages, logger); + } catch (error) { + logger.error('auto-update: error:', getPrintableError(error)); + } + }, + 2 * 60 * 1000 + ); // we do checks from the fileserver every 1 minute. } export function stop() { diff --git a/ts/util/linkPreviewFetch.ts b/ts/util/linkPreviewFetch.ts index 4c02b7241..73729e606 100644 --- a/ts/util/linkPreviewFetch.ts +++ b/ts/util/linkPreviewFetch.ts @@ -299,10 +299,7 @@ const getLinkHrefAttribute = ( ): string | null => { for (let i = 0; i < rels.length; i += 1) { const rel = rels[i]; - const href = document - .querySelector(`link[rel="${rel}"]`) - ?.getAttribute('href') - ?.trim(); + const href = document.querySelector(`link[rel="${rel}"]`)?.getAttribute('href')?.trim(); if (href) { return href; } diff --git a/ts/util/privacy.ts b/ts/util/privacy.ts index 148aef54b..c67ce0ad7 100644 --- a/ts/util/privacy.ts +++ b/ts/util/privacy.ts @@ -7,9 +7,11 @@ import { isDevProd } from '../shared/env_vars'; const APP_ROOT_PATH = getAppRootPath(); const SESSION_ID_PATTERN = /\b((05)?[0-9a-f]{64})\b/gi; -const SNODE_PATTERN = /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/g; +const SNODE_PATTERN = + /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/g; const GROUP_ID_PATTERN = /(group\()([^)]+)(\))/g; -const SERVER_URL_PATTERN = /https?:\/\/[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g; +const SERVER_URL_PATTERN = + /https?:\/\/[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g; const REDACTION_PLACEHOLDER = '[REDACTED]'; // redactPath :: Path -> String -> String diff --git a/ts/util/readReceipts.ts b/ts/util/readReceipts.ts index 474153288..5adb3c951 100644 --- a/ts/util/readReceipts.ts +++ b/ts/util/readReceipts.ts @@ -30,9 +30,7 @@ async function onReadReceipt(receipt: { source: string; timestamp: number; readA if ( !convoId || !getConversationController().get(convoId) || - !getConversationController() - .get(convoId) - .isPrivate() + !getConversationController().get(convoId).isPrivate() ) { window.log.info( 'Convo is undefined or not a private chat for read receipt in convo', diff --git a/ts/webworker/workers/browser/libsession_worker_interface.ts b/ts/webworker/workers/browser/libsession_worker_interface.ts index 35b76fdad..4c463578c 100644 --- a/ts/webworker/workers/browser/libsession_worker_interface.ts +++ b/ts/webworker/workers/browser/libsession_worker_interface.ts @@ -1,6 +1,5 @@ /* eslint-disable import/extensions */ /* eslint-disable import/no-unresolved */ -import { join } from 'path'; import { BaseWrapperActionsCalls, ContactInfoSet, @@ -10,6 +9,7 @@ import { UserConfigWrapperActionsCalls, UserGroupsWrapperActionsCalls, } from 'libsession_util_nodejs'; +import { join } from 'path'; import { getAppRootPath } from '../../../node/getRootPath'; import { WorkerInterface } from '../../worker_interface'; @@ -30,7 +30,7 @@ const internalCallLibSessionWorker = async ([ 'workers', 'node', 'libsession', - 'libsession.worker.js' + 'libsession.worker.compiled.js' ); libsessionWorkerInterface = new WorkerInterface(libsessionWorkerPath, 1 * 60 * 1000); diff --git a/ts/webworker/workers/browser/util_worker_interface.ts b/ts/webworker/workers/browser/util_worker_interface.ts index cafef5cd9..f2fb842a3 100644 --- a/ts/webworker/workers/browser/util_worker_interface.ts +++ b/ts/webworker/workers/browser/util_worker_interface.ts @@ -25,7 +25,7 @@ const internalCallUtilsWorker = async ( 'workers', 'node', 'util', - 'util.worker.js' + 'util.worker.compiled.js' ); utilWorkerInterface = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000); } diff --git a/utils.worker.config.js b/utils.worker.config.js index 001dddb40..284dca0f5 100644 --- a/utils.worker.config.js +++ b/utils.worker.config.js @@ -22,7 +22,7 @@ module.exports = { }, }, output: { - filename: 'util.worker.js', + filename: 'util.worker.compiled.js', path: path.resolve(__dirname, 'ts', 'webworker', 'workers', 'node', 'util'), }, target: 'node',