diff --git a/app/main.ts b/app/main.ts index fd4900353..1c0abc9c6 100644 --- a/app/main.ts +++ b/app/main.ts @@ -1436,9 +1436,8 @@ app.on('ready', async () => { let getMediaAccessStatus; // This function is not supported on Linux, so we have a fallback. if (systemPreferences.getMediaAccessStatus) { - getMediaAccessStatus = systemPreferences.getMediaAccessStatus.bind( - systemPreferences - ); + getMediaAccessStatus = + systemPreferences.getMediaAccessStatus.bind(systemPreferences); } else { getMediaAccessStatus = noop; } @@ -1814,18 +1813,18 @@ ipc.on( } ); -ipc.on('update-system-tray-setting', ( - _event, - rawSystemTraySetting /* : Readonly */ -) => { - const systemTraySetting = parseSystemTraySetting(rawSystemTraySetting); - systemTraySettingCache.set(systemTraySetting); +ipc.on( + 'update-system-tray-setting', + (_event, rawSystemTraySetting /* : Readonly */) => { + const systemTraySetting = parseSystemTraySetting(rawSystemTraySetting); + systemTraySettingCache.set(systemTraySetting); - if (systemTrayService) { - const isEnabled = shouldMinimizeToSystemTray(systemTraySetting); - systemTrayService.setEnabled(isEnabled); + if (systemTrayService) { + const isEnabled = shouldMinimizeToSystemTray(systemTraySetting); + systemTrayService.setEnabled(isEnabled); + } } -}); +); ipc.on('close-about', () => { if (aboutWindow) { diff --git a/js/expiring_tap_to_view_messages.js b/js/expiring_tap_to_view_messages.js index ad4fe7e9d..28a3f9d69 100644 --- a/js/expiring_tap_to_view_messages.js +++ b/js/expiring_tap_to_view_messages.js @@ -16,11 +16,10 @@ window.SignalContext.log.info( 'eraseTapToViewMessages: Loading messages...' ); - const messages = await window.Signal.Data.getTapToViewMessagesNeedingErase( - { + const messages = + await window.Signal.Data.getTapToViewMessagesNeedingErase({ MessageCollection: Whisper.MessageCollection, - } - ); + }); await Promise.all( messages.map(async fromDB => { @@ -51,7 +50,8 @@ const HOUR = 60 * MINUTE; const THIRTY_DAYS = 30 * 24 * HOUR; - const receivedAt = await window.Signal.Data.getNextTapToViewMessageTimestampToAgeOut(); + const receivedAt = + await window.Signal.Data.getNextTapToViewMessageTimestampToAgeOut(); if (!receivedAt) { return; } diff --git a/js/modules/signal.js b/js/modules/signal.js index 936a7e4ec..45a78f0f1 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -196,9 +196,8 @@ function initializeMigrations({ const getAbsoluteAttachmentPath = createAbsolutePathGetter(attachmentsPath); const deleteOnDisk = Attachments.createDeleter(attachmentsPath); const writeNewAttachmentData = createWriterForNew(attachmentsPath); - const copyIntoAttachmentsDirectory = Attachments.copyIntoAttachmentsDirectory( - attachmentsPath - ); + const copyIntoAttachmentsDirectory = + Attachments.copyIntoAttachmentsDirectory(attachmentsPath); const doesAttachmentExist = createDoesExist(attachmentsPath); const stickersPath = getStickersPath(userDataPath); @@ -216,9 +215,8 @@ function initializeMigrations({ const writeNewTempData = createWriterForNew(tempPath); const deleteTempFile = Attachments.createDeleter(tempPath); const readTempData = createReader(tempPath); - const copyIntoTempDirectory = Attachments.copyIntoAttachmentsDirectory( - tempPath - ); + const copyIntoTempDirectory = + Attachments.copyIntoAttachmentsDirectory(tempPath); const draftPath = getDraftPath(userDataPath); const getAbsoluteDraftPath = createAbsolutePathGetter(draftPath); diff --git a/js/modules/types/message.js b/js/modules/types/message.js index cfeece093..7247129b3 100644 --- a/js/modules/types/message.js +++ b/js/modules/types/message.js @@ -194,64 +194,63 @@ exports._mapContact = upgradeContact => async (message, context) => { // _mapQuotedAttachments :: (QuotedAttachment -> Promise QuotedAttachment) -> // (Message, Context) -> // Promise Message -exports._mapQuotedAttachments = upgradeAttachment => async ( - message, - context -) => { - if (!message.quote) { - return message; - } - if (!context || !isObject(context.logger)) { - throw new Error('_mapQuotedAttachments: context must have logger object'); - } - - const upgradeWithContext = async attachment => { - const { thumbnail } = attachment; - if (!thumbnail) { - return attachment; +exports._mapQuotedAttachments = + upgradeAttachment => async (message, context) => { + if (!message.quote) { + return message; + } + if (!context || !isObject(context.logger)) { + throw new Error('_mapQuotedAttachments: context must have logger object'); } - const upgradedThumbnail = await upgradeAttachment(thumbnail, context); - return { ...attachment, thumbnail: upgradedThumbnail }; + const upgradeWithContext = async attachment => { + const { thumbnail } = attachment; + if (!thumbnail) { + return attachment; + } + + const upgradedThumbnail = await upgradeAttachment(thumbnail, context); + return { ...attachment, thumbnail: upgradedThumbnail }; + }; + + const quotedAttachments = + (message.quote && message.quote.attachments) || []; + + const attachments = await Promise.all( + quotedAttachments.map(upgradeWithContext) + ); + return { ...message, quote: { ...message.quote, attachments } }; }; - const quotedAttachments = (message.quote && message.quote.attachments) || []; - - const attachments = await Promise.all( - quotedAttachments.map(upgradeWithContext) - ); - return { ...message, quote: { ...message.quote, attachments } }; -}; - // _mapPreviewAttachments :: (PreviewAttachment -> Promise PreviewAttachment) -> // (Message, Context) -> // Promise Message -exports._mapPreviewAttachments = upgradeAttachment => async ( - message, - context -) => { - if (!message.preview) { - return message; - } - if (!context || !isObject(context.logger)) { - throw new Error('_mapPreviewAttachments: context must have logger object'); - } - - const upgradeWithContext = async preview => { - const { image } = preview; - if (!image) { - return preview; +exports._mapPreviewAttachments = + upgradeAttachment => async (message, context) => { + if (!message.preview) { + return message; + } + if (!context || !isObject(context.logger)) { + throw new Error( + '_mapPreviewAttachments: context must have logger object' + ); } - const upgradedImage = await upgradeAttachment(image, context); - return { ...preview, image: upgradedImage }; - }; + const upgradeWithContext = async preview => { + const { image } = preview; + if (!image) { + return preview; + } - const preview = await Promise.all( - (message.preview || []).map(upgradeWithContext) - ); - return { ...message, preview }; -}; + const upgradedImage = await upgradeAttachment(image, context); + return { ...preview, image: upgradedImage }; + }; + + const preview = await Promise.all( + (message.preview || []).map(upgradeWithContext) + ); + return { ...message, preview }; + }; const toVersion0 = async (message, context) => exports.initializeSchemaVersion({ message, logger: context.logger }); diff --git a/js/reliable_trigger.js b/js/reliable_trigger.js index c71e131ac..76f897709 100644 --- a/js/reliable_trigger.js +++ b/js/reliable_trigger.js @@ -136,5 +136,9 @@ return this; } - Backbone.Model.prototype.trigger = Backbone.View.prototype.trigger = Backbone.Collection.prototype.trigger = Backbone.Events.trigger = trigger; + Backbone.Model.prototype.trigger = + Backbone.View.prototype.trigger = + Backbone.Collection.prototype.trigger = + Backbone.Events.trigger = + trigger; })(); diff --git a/libtextsecure/test/fake_web_api.js b/libtextsecure/test/fake_web_api.js index 001fae403..5bb4da454 100644 --- a/libtextsecure/test/fake_web_api.js +++ b/libtextsecure/test/fake_web_api.js @@ -48,9 +48,8 @@ const fakeAPI = { throw new Error('Invalid message'); } - messagesSentMap[ - `${destination}.${messageArray[i].destinationDeviceId}` - ] = msg; + messagesSentMap[`${destination}.${messageArray[i].destinationDeviceId}`] = + msg; } }, }; diff --git a/libtextsecure/test/sendmessage_test.js b/libtextsecure/test/sendmessage_test.js index 66a2dfb18..e856310c4 100644 --- a/libtextsecure/test/sendmessage_test.js +++ b/libtextsecure/test/sendmessage_test.js @@ -5,257 +5,33 @@ /* eslint-disable no-console */ const BUCKET_SIZES = [ - 541, - 568, - 596, - 626, - 657, - 690, - 725, - 761, - 799, - 839, - 881, - 925, - 972, - 1020, - 1071, - 1125, - 1181, - 1240, - 1302, - 1367, - 1436, - 1507, - 1583, - 1662, - 1745, - 1832, - 1924, - 2020, - 2121, - 2227, - 2339, - 2456, - 2579, - 2708, - 2843, - 2985, - 3134, - 3291, - 3456, - 3629, - 3810, - 4001, - 4201, - 4411, - 4631, - 4863, - 5106, - 5361, - 5629, - 5911, - 6207, - 6517, - 6843, - 7185, - 7544, - 7921, - 8318, - 8733, - 9170, - 9629, - 10110, - 10616, - 11146, - 11704, - 12289, - 12903, - 13549, - 14226, - 14937, - 15684, - 16469, - 17292, - 18157, - 19065, - 20018, - 21019, - 22070, - 23173, - 24332, - 25549, - 26826, - 28167, - 29576, - 31054, - 32607, - 34238, - 35950, - 37747, - 39634, - 41616, - 43697, - 45882, - 48176, - 50585, - 53114, - 55770, - 58558, - 61486, - 64561, - 67789, - 71178, - 74737, - 78474, - 82398, - 86518, - 90843, - 95386, - 100155, - 105163, - 110421, - 115942, - 121739, - 127826, - 134217, - 140928, - 147975, - 155373, - 163142, - 171299, - 179864, - 188858, - 198300, - 208215, - 218626, - 229558, - 241036, - 253087, - 265742, - 279029, - 292980, - 307629, - 323011, - 339161, - 356119, - 373925, - 392622, - 412253, - 432866, - 454509, - 477234, - 501096, - 526151, - 552458, - 580081, - 609086, - 639540, - 671517, - 705093, - 740347, - 777365, - 816233, - 857045, - 899897, - 944892, - 992136, - 1041743, - 1093831, - 1148522, - 1205948, - 1266246, - 1329558, - 1396036, - 1465838, - 1539130, - 1616086, - 1696890, - 1781735, - 1870822, - 1964363, - 2062581, - 2165710, - 2273996, - 2387695, - 2507080, - 2632434, - 2764056, - 2902259, - 3047372, - 3199740, - 3359727, - 3527714, - 3704100, - 3889305, - 4083770, - 4287958, - 4502356, - 4727474, - 4963848, - 5212040, - 5472642, - 5746274, - 6033588, - 6335268, - 6652031, - 6984633, - 7333864, - 7700558, - 8085585, - 8489865, - 8914358, - 9360076, - 9828080, - 10319484, - 10835458, - 11377231, - 11946092, - 12543397, - 13170567, - 13829095, - 14520550, - 15246578, - 16008907, - 16809352, - 17649820, - 18532311, - 19458926, - 20431872, - 21453466, - 22526139, - 23652446, - 24835069, - 26076822, - 27380663, - 28749697, - 30187181, - 31696540, - 33281368, - 34945436, - 36692708, - 38527343, - 40453710, - 42476396, - 44600216, - 46830227, - 49171738, - 51630325, - 54211841, - 56922433, - 59768555, - 62756983, - 65894832, - 69189573, - 72649052, - 76281505, - 80095580, - 84100359, - 88305377, - 92720646, - 97356678, - 102224512, - 107335738, + 541, 568, 596, 626, 657, 690, 725, 761, 799, 839, 881, 925, 972, 1020, 1071, + 1125, 1181, 1240, 1302, 1367, 1436, 1507, 1583, 1662, 1745, 1832, 1924, 2020, + 2121, 2227, 2339, 2456, 2579, 2708, 2843, 2985, 3134, 3291, 3456, 3629, 3810, + 4001, 4201, 4411, 4631, 4863, 5106, 5361, 5629, 5911, 6207, 6517, 6843, 7185, + 7544, 7921, 8318, 8733, 9170, 9629, 10110, 10616, 11146, 11704, 12289, 12903, + 13549, 14226, 14937, 15684, 16469, 17292, 18157, 19065, 20018, 21019, 22070, + 23173, 24332, 25549, 26826, 28167, 29576, 31054, 32607, 34238, 35950, 37747, + 39634, 41616, 43697, 45882, 48176, 50585, 53114, 55770, 58558, 61486, 64561, + 67789, 71178, 74737, 78474, 82398, 86518, 90843, 95386, 100155, 105163, + 110421, 115942, 121739, 127826, 134217, 140928, 147975, 155373, 163142, + 171299, 179864, 188858, 198300, 208215, 218626, 229558, 241036, 253087, + 265742, 279029, 292980, 307629, 323011, 339161, 356119, 373925, 392622, + 412253, 432866, 454509, 477234, 501096, 526151, 552458, 580081, 609086, + 639540, 671517, 705093, 740347, 777365, 816233, 857045, 899897, 944892, + 992136, 1041743, 1093831, 1148522, 1205948, 1266246, 1329558, 1396036, + 1465838, 1539130, 1616086, 1696890, 1781735, 1870822, 1964363, 2062581, + 2165710, 2273996, 2387695, 2507080, 2632434, 2764056, 2902259, 3047372, + 3199740, 3359727, 3527714, 3704100, 3889305, 4083770, 4287958, 4502356, + 4727474, 4963848, 5212040, 5472642, 5746274, 6033588, 6335268, 6652031, + 6984633, 7333864, 7700558, 8085585, 8489865, 8914358, 9360076, 9828080, + 10319484, 10835458, 11377231, 11946092, 12543397, 13170567, 13829095, + 14520550, 15246578, 16008907, 16809352, 17649820, 18532311, 19458926, + 20431872, 21453466, 22526139, 23652446, 24835069, 26076822, 27380663, + 28749697, 30187181, 31696540, 33281368, 34945436, 36692708, 38527343, + 40453710, 42476396, 44600216, 46830227, 49171738, 51630325, 54211841, + 56922433, 59768555, 62756983, 65894832, 69189573, 72649052, 76281505, + 80095580, 84100359, 88305377, 92720646, 97356678, 102224512, 107335738, ]; describe('sendmessage', () => { diff --git a/package.json b/package.json index fba3b68be..19b0860eb 100644 --- a/package.json +++ b/package.json @@ -275,7 +275,7 @@ "npm-run-all": "4.1.5", "nyc": "11.4.1", "patch-package": "6.4.7", - "prettier": "^2.2.1", + "prettier": "2.4.1", "react-docgen-typescript": "1.2.6", "sass-loader": "10.2.0", "sinon": "11.1.1", diff --git a/preload.js b/preload.js index 2b8036afe..fbe55fb10 100644 --- a/preload.js +++ b/preload.js @@ -389,18 +389,18 @@ try { window.imageToBlurHash = imageToBlurHash; window.emojiData = require('emoji-datasource'); - window.libphonenumber = require('google-libphonenumber').PhoneNumberUtil.getInstance(); - window.libphonenumber.PhoneNumberFormat = require('google-libphonenumber').PhoneNumberFormat; + window.libphonenumber = + require('google-libphonenumber').PhoneNumberUtil.getInstance(); + window.libphonenumber.PhoneNumberFormat = + require('google-libphonenumber').PhoneNumberFormat; const activeWindowService = new ActiveWindowService(); activeWindowService.initialize(window.document, ipc); window.isActive = activeWindowService.isActive.bind(activeWindowService); - window.registerForActive = activeWindowService.registerForActive.bind( - activeWindowService - ); - window.unregisterForActive = activeWindowService.unregisterForActive.bind( - activeWindowService - ); + window.registerForActive = + activeWindowService.registerForActive.bind(activeWindowService); + window.unregisterForActive = + activeWindowService.unregisterForActive.bind(activeWindowService); window.Accessibility = { reducedMotionSetting: Boolean(config.reducedMotionSetting), diff --git a/sticker-creator/app/stages/MetaStage.tsx b/sticker-creator/app/stages/MetaStage.tsx index b938200ad..f9112bb2c 100644 --- a/sticker-creator/app/stages/MetaStage.tsx +++ b/sticker-creator/app/stages/MetaStage.tsx @@ -35,9 +35,8 @@ export const MetaStage: React.ComponentType = () => { [actions] ); - const { getRootProps, getInputProps, isDragActive } = useStickerDropzone( - onDrop - ); + const { getRootProps, getInputProps, isDragActive } = + useStickerDropzone(onDrop); const onNext = React.useCallback(() => { setConfirming(true); diff --git a/sticker-creator/components/StickerFrame.tsx b/sticker-creator/components/StickerFrame.tsx index 9a3ea5937..5da1bb392 100644 --- a/sticker-creator/components/StickerFrame.tsx +++ b/sticker-creator/components/StickerFrame.tsx @@ -81,15 +81,11 @@ export const StickerFrame = React.memo( }: Props) => { const i18n = useI18n(); const [emojiPickerOpen, setEmojiPickerOpen] = React.useState(false); - const [ - emojiPopperRoot, - setEmojiPopperRoot, - ] = React.useState(null); + const [emojiPopperRoot, setEmojiPopperRoot] = + React.useState(null); const [previewActive, setPreviewActive] = React.useState(false); - const [ - previewPopperRoot, - setPreviewPopperRoot, - ] = React.useState(null); + const [previewPopperRoot, setPreviewPopperRoot] = + React.useState(null); const timerRef = React.useRef(); const handleToggleEmojiPicker = React.useCallback(() => { diff --git a/sticker-creator/elements/DropZone.tsx b/sticker-creator/elements/DropZone.tsx index 4fb601751..77488b733 100644 --- a/sticker-creator/elements/DropZone.tsx +++ b/sticker-creator/elements/DropZone.tsx @@ -37,9 +37,8 @@ export const DropZone: React.ComponentType = props => { [onDrop] ); - const { getRootProps, getInputProps, isDragActive } = useStickerDropzone( - handleDrop - ); + const { getRootProps, getInputProps, isDragActive } = + useStickerDropzone(handleDrop); React.useEffect(() => { if (onDragActive) { diff --git a/sticker-creator/preload.js b/sticker-creator/preload.js index d2b6caab5..cfef74c16 100644 --- a/sticker-creator/preload.js +++ b/sticker-creator/preload.js @@ -169,9 +169,8 @@ window.encryptAndUpload = async ( const passwordItem = await window.Signal.Data.getItemById('password'); if (!oldUsernameItem || !passwordItem) { - const { message } = window.localeMessages[ - 'StickerCreator--Authentication--error' - ]; + const { message } = + window.localeMessages['StickerCreator--Authentication--error']; ipc.send('show-message-box', { type: 'warning', diff --git a/sticker-creator/store/ducks/stickers.ts b/sticker-creator/store/ducks/stickers.ts index 42fdf605a..d6901bcb7 100644 --- a/sticker-creator/store/ducks/stickers.ts +++ b/sticker-creator/store/ducks/stickers.ts @@ -32,9 +32,8 @@ export const removeSticker = createAction('stickers/removeSticker'); export const moveSticker = createAction('stickers/moveSticker'); export const setCover = createAction('stickers/setCover'); export const resetCover = createAction('stickers/resetCover'); -export const setEmoji = createAction<{ id: string; emoji: EmojiPickDataType }>( - 'stickers/setEmoji' -); +export const setEmoji = + createAction<{ id: string; emoji: EmojiPickDataType }>('stickers/setEmoji'); export const setTitle = createAction('stickers/setTitle'); export const setAuthor = createAction('stickers/setAuthor'); export const setPackMeta = createAction('stickers/setPackMeta'); diff --git a/test/stickers_test.js b/test/stickers_test.js index 2df5b8430..93ca01e73 100644 --- a/test/stickers_test.js +++ b/test/stickers_test.js @@ -72,8 +72,7 @@ describe('Stickers', () => { ), { id: 'c8c83285b547872ac4c589d64a6edd6a', - key: - '59bb3a8860f0e6a5a83a5337a015c8d55ecd2193f82d77202f3b8112a845636e', + key: '59bb3a8860f0e6a5a83a5337a015c8d55ecd2193f82d77202f3b8112a845636e', } ); }); @@ -85,8 +84,7 @@ describe('Stickers', () => { ), { id: 'c8c83285b547872ac4c589d64a6edd6a', - key: - '59bb3a8860f0e6a5a83a5337a015c8d55ecd2193f82d77202f3b8112a845636e', + key: '59bb3a8860f0e6a5a83a5337a015c8d55ecd2193f82d77202f3b8112a845636e', } ); }); @@ -98,8 +96,7 @@ describe('Stickers', () => { ), { id: 'c8c83285b547872ac4c589d64a6edd6a', - key: - '59bb3a8860f0e6a5a83a5337a015c8d55ecd2193f82d77202f3b8112a845636e', + key: '59bb3a8860f0e6a5a83a5337a015c8d55ecd2193f82d77202f3b8112a845636e', } ); }); diff --git a/ts/Crypto.ts b/ts/Crypto.ts index 1fdb5185e..b1cdc6e16 100644 --- a/ts/Crypto.ts +++ b/ts/Crypto.ts @@ -409,10 +409,8 @@ export async function encryptCdsDiscoveryRequest( iv, queryDataPlaintext ); - const { - data: queryDataCiphertextData, - mac: queryDataCiphertextMac, - } = _getMacAndData(queryDataCiphertext); + const { data: queryDataCiphertextData, mac: queryDataCiphertextMac } = + _getMacAndData(queryDataCiphertext); const envelopes = await pProps( attestations, diff --git a/ts/LibSignalStores.ts b/ts/LibSignalStores.ts index 9e2491a58..89acecc03 100644 --- a/ts/LibSignalStores.ts +++ b/ts/LibSignalStores.ts @@ -279,10 +279,11 @@ export class SignedPreKeys extends SignedPreKeyStore { } async getSignedPreKey(id: number): Promise { - const signedPreKey = await window.textsecure.storage.protocol.loadSignedPreKey( - this.ourUuid, - id - ); + const signedPreKey = + await window.textsecure.storage.protocol.loadSignedPreKey( + this.ourUuid, + id + ); if (!signedPreKey) { throw new Error(`getSignedPreKey: SignedPreKey ${id} not found`); diff --git a/ts/SignalProtocolStore.ts b/ts/SignalProtocolStore.ts index f7f91493e..d63b67f82 100644 --- a/ts/SignalProtocolStore.ts +++ b/ts/SignalProtocolStore.ts @@ -185,10 +185,10 @@ export function freezeSignedPreKey( } // We add a this parameter to avoid an 'implicit any' error on the next line -const EventsMixin = (function EventsMixin(this: unknown) { +const EventsMixin = function EventsMixin(this: unknown) { window._.assign(this, window.Backbone.Events); // eslint-disable-next-line @typescript-eslint/no-explicit-any -} as any) as typeof window.Backbone.EventsMixin; +} as any as typeof window.Backbone.EventsMixin; type SessionCacheEntry = CacheEntryType; diff --git a/ts/background.ts b/ts/background.ts index ee06b503f..52064cedf 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -371,8 +371,8 @@ export async function startApp(): Promise { timeout: 1000 * 60 * 2, }); window.Whisper.deliveryReceiptQueue.pause(); - window.Whisper.deliveryReceiptBatcher = window.Signal.Util.createBatcher( - { + window.Whisper.deliveryReceiptBatcher = + window.Signal.Util.createBatcher({ name: 'Whisper.deliveryReceiptBatcher', wait: 500, maxSize: 100, @@ -426,8 +426,7 @@ export async function startApp(): Promise { }); } }, - } - ); + }); if (getTitleBarVisibility() === TitleBarVisibility.Hidden) { window.addEventListener('dblclick', (event: Event) => { @@ -476,10 +475,8 @@ export async function startApp(): Promise { window.setImmediate = window.nodeSetImmediate; const { IdleDetector, MessageDataMigrator } = window.Signal.Workflow; - const { - removeDatabase: removeIndexedDB, - doesDatabaseExist, - } = window.Signal.IndexedDB; + const { removeDatabase: removeIndexedDB, doesDatabaseExist } = + window.Signal.IndexedDB; const { Message } = window.Signal.Types; const { upgradeMessageSchema, @@ -868,12 +865,12 @@ export async function startApp(): Promise { ); expired.forEach(item => { const { conversationId, senderUuid, sentAt } = item; - const conversation = window.ConversationController.get( - conversationId - ); + const conversation = + window.ConversationController.get(conversationId); if (conversation) { const receivedAt = Date.now(); - const receivedAtCounter = window.Signal.Util.incrementMessageCounter(); + const receivedAtCounter = + window.Signal.Util.incrementMessageCounter(); conversation.queueJob('addDeliveryIssue', () => conversation.addDeliveryIssue({ receivedAt, @@ -933,7 +930,8 @@ export async function startApp(): Promise { ); const ourNumber = window.textsecure.storage.user.getNumber(); const ourUuid = window.textsecure.storage.user.getUuid()?.toString(); - const ourConversationId = window.ConversationController.getOurConversationId(); + const ourConversationId = + window.ConversationController.getOurConversationId(); const themeSetting = window.Events.getThemeSetting(); const theme = themeSetting === 'system' ? window.systemTheme : themeSetting; @@ -1094,7 +1092,8 @@ export async function startApp(): Promise { const newDeviceId = window.textsecure.storage.user.getDeviceId(); const newNumber = window.textsecure.storage.user.getNumber(); const newUuid = window.textsecure.storage.user.getUuid()?.toString(); - const ourConversation = window.ConversationController.getOurConversation(); + const ourConversation = + window.ConversationController.getOurConversation(); if (ourConversation?.get('e164') !== newNumber) { ourConversation?.set('e164', newNumber); @@ -1686,7 +1685,8 @@ export async function startApp(): Promise { window.Signal.challengeHandler = challengeHandler; if (!window.storage.user.getNumber()) { - const ourConversation = window.ConversationController.getOurConversation(); + const ourConversation = + window.ConversationController.getOurConversation(); const ourE164 = ourConversation?.get('e164'); if (ourE164) { log.warn('Restoring E164 from our conversation'); @@ -1699,13 +1699,14 @@ export async function startApp(): Promise { badgeImageFileDownloader.checkForFilesToDownload(); log.info('Expiration start timestamp cleanup: starting...'); - const messagesUnexpectedlyMissingExpirationStartTimestamp = await window.Signal.Data.getMessagesUnexpectedlyMissingExpirationStartTimestamp(); + const messagesUnexpectedlyMissingExpirationStartTimestamp = + await window.Signal.Data.getMessagesUnexpectedlyMissingExpirationStartTimestamp(); log.info( `Expiration start timestamp cleanup: Found ${messagesUnexpectedlyMissingExpirationStartTimestamp.length} messages for cleanup` ); if (messagesUnexpectedlyMissingExpirationStartTimestamp.length) { - const newMessageAttributes = messagesUnexpectedlyMissingExpirationStartTimestamp.map( - message => { + const newMessageAttributes = + messagesUnexpectedlyMissingExpirationStartTimestamp.map(message => { const expirationStartTimestamp = Math.min( ...filter( [ @@ -1727,8 +1728,7 @@ export async function startApp(): Promise { ...message, expirationStartTimestamp, }; - } - ); + }); await window.Signal.Data.saveMessages(newMessageAttributes); } @@ -1804,9 +1804,8 @@ export async function startApp(): Promise { window.Signal.RemoteConfig.onChange( 'desktop.clientExpiration', ({ value }) => { - const remoteBuildExpirationTimestamp = window.Signal.Util.parseRemoteClientExpiration( - value as string - ); + const remoteBuildExpirationTimestamp = + window.Signal.Util.parseRemoteClientExpiration(value as string); if (remoteBuildExpirationTimestamp) { window.storage.put( 'remoteBuildExpiration', @@ -2013,9 +2012,10 @@ export async function startApp(): Promise { 'desktop.clientExpiration' ); if (expiration) { - const remoteBuildExpirationTimestamp = window.Signal.Util.parseRemoteClientExpiration( - expiration as string - ); + const remoteBuildExpirationTimestamp = + window.Signal.Util.parseRemoteClientExpiration( + expiration as string + ); if (remoteBuildExpirationTimestamp) { window.storage.put( 'remoteBuildExpiration', @@ -2183,7 +2183,8 @@ export async function startApp(): Promise { runStorageService(); }); - const ourConversation = window.ConversationController.getOurConversationOrThrow(); + const ourConversation = + window.ConversationController.getOurConversationOrThrow(); const sendOptions = await getSendOptions(ourConversation.attributes, { syncMessage: true, }); @@ -2223,7 +2224,8 @@ export async function startApp(): Promise { // Kick off a profile refresh if necessary, but don't wait for it, as failure is // tolerable. - const ourConversationId = window.ConversationController.getOurConversationId(); + const ourConversationId = + window.ConversationController.getOurConversationId(); if (ourConversationId) { routineProfileRefresh({ allConversations: window.ConversationController.getAll(), @@ -2565,11 +2567,11 @@ export async function startApp(): Promise { } } - const c = new window.Whisper.Conversation(({ + const c = new window.Whisper.Conversation({ e164: details.number, uuid: details.uuid, type: 'private', - } as Partial) as WhatIsThis); + } as Partial as WhatIsThis); const validationError = c.validate(); if (validationError) { log.error( @@ -3000,32 +3002,38 @@ export async function startApp(): Promise { const { unidentifiedStatus = [] } = data; - const sendStateByConversationId: SendStateByConversationId = unidentifiedStatus.reduce( - (result: SendStateByConversationId, { destinationUuid, destination }) => { - const conversationId = window.ConversationController.ensureContactIds({ - uuid: destinationUuid, - e164: destination, - highTrust: true, - }); - if (!conversationId || conversationId === ourId) { - return result; - } + const sendStateByConversationId: SendStateByConversationId = + unidentifiedStatus.reduce( + ( + result: SendStateByConversationId, + { destinationUuid, destination } + ) => { + const conversationId = window.ConversationController.ensureContactIds( + { + uuid: destinationUuid, + e164: destination, + highTrust: true, + } + ); + if (!conversationId || conversationId === ourId) { + return result; + } - return { - ...result, - [conversationId]: { + return { + ...result, + [conversationId]: { + status: SendStatus.Sent, + updatedAt: timestamp, + }, + }; + }, + { + [ourId]: { status: SendStatus.Sent, updatedAt: timestamp, }, - }; - }, - { - [ourId]: { - status: SendStatus.Sent, - updatedAt: timestamp, - }, - } - ); + } + ); let unidentifiedDeliveries: Array = []; if (unidentifiedStatus.length) { @@ -3037,7 +3045,7 @@ export async function startApp(): Promise { .filter(isNotNil); } - return new window.Whisper.Message(({ + return new window.Whisper.Message({ source: window.textsecure.storage.user.getNumber(), sourceUuid: window.textsecure.storage.user.getUuid()?.toString(), sourceDevice: data.device, @@ -3054,7 +3062,7 @@ export async function startApp(): Promise { data.expirationStartTimestamp || timestamp, now ), - } as Partial) as WhatIsThis); + } as Partial as WhatIsThis); } // Works with 'sent' and 'message' data sent from MessageReceiver, with a little massage @@ -3122,9 +3130,8 @@ export async function startApp(): Promise { ); } else { // First we check for an already-migrated GroupV2 group - const migratedGroup = window.ConversationController.get( - derivedGroupV2Id - ); + const migratedGroup = + window.ConversationController.get(derivedGroupV2Id); if (migratedGroup) { return { type: Message.GROUP, @@ -3275,7 +3282,7 @@ export async function startApp(): Promise { Boolean(data.receivedAtCounter), `Did not receive receivedAtCounter for message: ${data.timestamp}` ); - return new window.Whisper.Message(({ + return new window.Whisper.Message({ source: data.source, sourceUuid: data.sourceUuid, sourceDevice: data.sourceDevice, @@ -3289,7 +3296,7 @@ export async function startApp(): Promise { type: 'incoming', readStatus: ReadStatus.Unread, timestamp: data.timestamp, - } as Partial) as WhatIsThis); + } as Partial as WhatIsThis); } // Returns `false` if this message isn't a group call message. @@ -3545,13 +3552,8 @@ export async function startApp(): Promise { logTitle: string; type: MessageReceiptType.Read | MessageReceiptType.View; }>): void { - const { - envelopeTimestamp, - timestamp, - source, - sourceUuid, - sourceDevice, - } = event.receipt; + const { envelopeTimestamp, timestamp, source, sourceUuid, sourceDevice } = + event.receipt; const sourceConversationId = window.ConversationController.ensureContactIds( { e164: source, @@ -3664,11 +3666,11 @@ export async function startApp(): Promise { ev.confirm(); } - const c = new window.Whisper.Conversation(({ + const c = new window.Whisper.Conversation({ e164, uuid, type: 'private', - } as Partial) as WhatIsThis); + } as Partial as WhatIsThis); const error = c.validate(); if (error) { log.error( @@ -3726,13 +3728,8 @@ export async function startApp(): Promise { function onDeliveryReceipt(ev: DeliveryEvent) { const { deliveryReceipt } = ev; - const { - envelopeTimestamp, - sourceUuid, - source, - sourceDevice, - timestamp, - } = deliveryReceipt; + const { envelopeTimestamp, sourceUuid, source, sourceDevice, timestamp } = + deliveryReceipt; ev.confirm(); diff --git a/ts/challenge.ts b/ts/challenge.ts index 58f45c1c5..e9aa0167e 100644 --- a/ts/challenge.ts +++ b/ts/challenge.ts @@ -154,13 +154,12 @@ export class ChallengeHandler { const retryIds = new Set(stored.map(({ messageId }) => messageId)); - const maybeMessages: ReadonlyArray< - MinimalMessage | undefined - > = await Promise.all( - Array.from(retryIds).map(async messageId => - this.options.getMessageById(messageId) - ) - ); + const maybeMessages: ReadonlyArray = + await Promise.all( + Array.from(retryIds).map(async messageId => + this.options.getMessageById(messageId) + ) + ); const messages: Array = maybeMessages.filter(isNotNil); diff --git a/ts/components/AddGroupMemberErrorDialog.tsx b/ts/components/AddGroupMemberErrorDialog.tsx index 75bf54610..a9c606115 100644 --- a/ts/components/AddGroupMemberErrorDialog.tsx +++ b/ts/components/AddGroupMemberErrorDialog.tsx @@ -35,43 +35,47 @@ type PropsType = { onClose: () => void; } & PropsDataType; -export const AddGroupMemberErrorDialog: FunctionComponent = props => { - const { i18n, onClose } = props; +export const AddGroupMemberErrorDialog: FunctionComponent = + props => { + const { i18n, onClose } = props; - let title: string; - let body: ReactNode; - switch (props.mode) { - case AddGroupMemberErrorDialogMode.CantAddContact: { - const { contact } = props; - title = i18n('chooseGroupMembers__cant-add-member__title'); - body = ( - ]} - /> - ); - break; + let title: string; + let body: ReactNode; + switch (props.mode) { + case AddGroupMemberErrorDialogMode.CantAddContact: { + const { contact } = props; + title = i18n('chooseGroupMembers__cant-add-member__title'); + body = ( + ]} + /> + ); + break; + } + case AddGroupMemberErrorDialogMode.MaximumGroupSize: { + const { maximumNumberOfContacts } = props; + title = i18n('chooseGroupMembers__maximum-group-size__title'); + body = i18n('chooseGroupMembers__maximum-group-size__body', [ + maximumNumberOfContacts.toString(), + ]); + break; + } + case AddGroupMemberErrorDialogMode.RecommendedMaximumGroupSize: { + const { recommendedMaximumNumberOfContacts } = props; + title = i18n( + 'chooseGroupMembers__maximum-recommended-group-size__title' + ); + body = i18n( + 'chooseGroupMembers__maximum-recommended-group-size__body', + [recommendedMaximumNumberOfContacts.toString()] + ); + break; + } + default: + throw missingCaseError(props); } - case AddGroupMemberErrorDialogMode.MaximumGroupSize: { - const { maximumNumberOfContacts } = props; - title = i18n('chooseGroupMembers__maximum-group-size__title'); - body = i18n('chooseGroupMembers__maximum-group-size__body', [ - maximumNumberOfContacts.toString(), - ]); - break; - } - case AddGroupMemberErrorDialogMode.RecommendedMaximumGroupSize: { - const { recommendedMaximumNumberOfContacts } = props; - title = i18n('chooseGroupMembers__maximum-recommended-group-size__title'); - body = i18n('chooseGroupMembers__maximum-recommended-group-size__body', [ - recommendedMaximumNumberOfContacts.toString(), - ]); - break; - } - default: - throw missingCaseError(props); - } - return ; -}; + return ; + }; diff --git a/ts/components/AvatarIconEditor.tsx b/ts/components/AvatarIconEditor.tsx index bd201b804..308460080 100644 --- a/ts/components/AvatarIconEditor.tsx +++ b/ts/components/AvatarIconEditor.tsx @@ -23,9 +23,8 @@ export const AvatarIconEditor = ({ onClose, }: PropsType): JSX.Element => { const [avatarBuffer, setAvatarBuffer] = useState(); - const [avatarData, setAvatarData] = useState( - initialAvatarData - ); + const [avatarData, setAvatarData] = + useState(initialAvatarData); const onColorSelected = useCallback( (color: AvatarColorType) => { diff --git a/ts/components/AvatarTextEditor.tsx b/ts/components/AvatarTextEditor.tsx index c42e72c1a..9c970c7de 100644 --- a/ts/components/AvatarTextEditor.tsx +++ b/ts/components/AvatarTextEditor.tsx @@ -47,9 +47,10 @@ export const AvatarTextEditor = ({ onDone, }: PropsType): JSX.Element => { const initialText = useMemo(() => avatarData?.text || '', [avatarData]); - const initialColor = useMemo(() => avatarData?.color || AvatarColors[0], [ - avatarData, - ]); + const initialColor = useMemo( + () => avatarData?.color || AvatarColors[0], + [avatarData] + ); const [inputText, setInputText] = useState(initialText); const [fontSize, setFontSize] = useState(getFontSizes(BUBBLE_SIZE).text); diff --git a/ts/components/CallScreen.tsx b/ts/components/CallScreen.tsx index e9e06b298..1092c4d58 100644 --- a/ts/components/CallScreen.tsx +++ b/ts/components/CallScreen.tsx @@ -514,7 +514,8 @@ export const CallScreen: React.FC = ({
{localPreviewNode} diff --git a/ts/components/CallingHeader.tsx b/ts/components/CallingHeader.tsx index 734660b96..0fab9d0c1 100644 --- a/ts/components/CallingHeader.tsx +++ b/ts/components/CallingHeader.tsx @@ -58,7 +58,8 @@ export const CallingHeader = ({ className={classNames( 'module-calling-button__participants--container', { - 'module-calling-button__participants--shown': showParticipantsList, + 'module-calling-button__participants--shown': + showParticipantsList, } )} onClick={toggleParticipants} diff --git a/ts/components/CallingLobbyJoinButton.tsx b/ts/components/CallingLobbyJoinButton.tsx index 3ef985ff9..574f1b529 100644 --- a/ts/components/CallingLobbyJoinButton.tsx +++ b/ts/components/CallingLobbyJoinButton.tsx @@ -77,10 +77,8 @@ export const CallingLobbyJoinButton: FunctionComponent<{ if (!button) { return; } - const { - width: variantWidth, - height: variantHeight, - } = button.getBoundingClientRect(); + const { width: variantWidth, height: variantHeight } = + button.getBoundingClientRect(); // We could set the padding in CSS, but we don't do that in case some other // styling causes a re-render of the button but not of the component. This diff --git a/ts/components/CallingPipRemoteVideo.tsx b/ts/components/CallingPipRemoteVideo.tsx index af50f3624..187215f49 100644 --- a/ts/components/CallingPipRemoteVideo.tsx +++ b/ts/components/CallingPipRemoteVideo.tsx @@ -90,17 +90,16 @@ export const CallingPipRemoteVideo = ({ const isPageVisible = usePageVisibility(); - const activeGroupCallSpeaker: - | undefined - | GroupCallRemoteParticipantType = useMemo(() => { - if (activeCall.callMode !== CallMode.Group) { - return undefined; - } + const activeGroupCallSpeaker: undefined | GroupCallRemoteParticipantType = + useMemo(() => { + if (activeCall.callMode !== CallMode.Group) { + return undefined; + } - return maxBy(activeCall.remoteParticipants, participant => - participant.presenting ? Infinity : participant.speakerTime || -Infinity - ); - }, [activeCall.callMode, activeCall.remoteParticipants]); + return maxBy(activeCall.remoteParticipants, participant => + participant.presenting ? Infinity : participant.speakerTime || -Infinity + ); + }, [activeCall.callMode, activeCall.remoteParticipants]); useEffect(() => { if (activeCall.callMode !== CallMode.Group) { diff --git a/ts/components/CompositionInput.tsx b/ts/components/CompositionInput.tsx index 4d1f5d59f..262c55f05 100644 --- a/ts/components/CompositionInput.tsx +++ b/ts/components/CompositionInput.tsx @@ -110,18 +110,12 @@ export function CompositionInput(props: Props): React.ReactElement { sortedGroupMembers, } = props; - const [ - emojiCompletionElement, - setEmojiCompletionElement, - ] = React.useState(); - const [ - lastSelectionRange, - setLastSelectionRange, - ] = React.useState(null); - const [ - mentionCompletionElement, - setMentionCompletionElement, - ] = React.useState(); + const [emojiCompletionElement, setEmojiCompletionElement] = + React.useState(); + const [lastSelectionRange, setLastSelectionRange] = + React.useState(null); + const [mentionCompletionElement, setMentionCompletionElement] = + React.useState(); const emojiCompletionRef = React.useRef(); const mentionCompletionRef = React.useRef(); @@ -607,9 +601,8 @@ export function CompositionInput(props: Props): React.ReactElement { ); quillRef.current = quill; emojiCompletionRef.current = quill.getModule('emojiCompletion'); - mentionCompletionRef.current = quill.getModule( - 'mentionCompletion' - ); + mentionCompletionRef.current = + quill.getModule('mentionCompletion'); } }} /> diff --git a/ts/components/CompositionUpload.tsx b/ts/components/CompositionUpload.tsx index 1a69d6658..718012d95 100644 --- a/ts/components/CompositionUpload.tsx +++ b/ts/components/CompositionUpload.tsx @@ -49,19 +49,20 @@ export const CompositionUpload = forwardRef( AttachmentToastType | undefined >(); - const onFileInputChange: ChangeEventHandler = async event => { - const files = event.target.files || []; + const onFileInputChange: ChangeEventHandler = + async event => { + const files = event.target.files || []; - await processAttachments({ - addAttachment, - addPendingAttachment, - conversationId, - files: Array.from(files), - draftAttachments, - onShowToast: setToastType, - removeAttachment, - }); - }; + await processAttachments({ + addAttachment, + addPendingAttachment, + conversationId, + files: Array.from(files), + draftAttachments, + onShowToast: setToastType, + removeAttachment, + }); + }; function closeToast() { setToastType(undefined); diff --git a/ts/components/ContactListItem.tsx b/ts/components/ContactListItem.tsx index dcdd22d16..307bf603c 100644 --- a/ts/components/ContactListItem.tsx +++ b/ts/components/ContactListItem.tsx @@ -70,16 +70,8 @@ export class ContactListItem extends React.Component { } public render(): JSX.Element { - const { - about, - i18n, - isAdmin, - isMe, - name, - onClick, - title, - type, - } = this.props; + const { about, i18n, isAdmin, isMe, name, onClick, title, type } = + this.props; const displayName = isMe ? i18n('you') : title; diff --git a/ts/components/ConversationList.stories.tsx b/ts/components/ConversationList.stories.tsx index 747c4eb0f..9c0ebcf47 100644 --- a/ts/components/ConversationList.stories.tsx +++ b/ts/components/ConversationList.stories.tsx @@ -35,8 +35,7 @@ const defaultConversations: Array = [ title: 'Marc Barraca', lastMessage: { deletedForEveryone: false, - text: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.', + text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.', }, }), getDefaultConversation({ diff --git a/ts/components/CustomizingPreferredReactionsModal.stories.tsx b/ts/components/CustomizingPreferredReactionsModal.stories.tsx index d9922c072..0058585a1 100644 --- a/ts/components/CustomizingPreferredReactionsModal.stories.tsx +++ b/ts/components/CustomizingPreferredReactionsModal.stories.tsx @@ -17,27 +17,26 @@ const story = storiesOf( module ); -const defaultProps: ComponentProps< - typeof CustomizingPreferredReactionsModal -> = { - cancelCustomizePreferredReactionsModal: action( - 'cancelCustomizePreferredReactionsModal' - ), - deselectDraftEmoji: action('deselectDraftEmoji'), - draftPreferredReactions: ['✨', '❇️', '🎇', '🦈', '💖', '🅿️'], - hadSaveError: false, - i18n, - isSaving: false, - onSetSkinTone: action('onSetSkinTone'), - originalPreferredReactions: ['❤️', '👍', '👎', '😂', '😮', '😢'], - recentEmojis: ['cake'], - replaceSelectedDraftEmoji: action('replaceSelectedDraftEmoji'), - resetDraftEmoji: action('resetDraftEmoji'), - savePreferredReactions: action('savePreferredReactions'), - selectDraftEmojiToBeReplaced: action('selectDraftEmojiToBeReplaced'), - selectedDraftEmojiIndex: undefined, - skinTone: 4, -}; +const defaultProps: ComponentProps = + { + cancelCustomizePreferredReactionsModal: action( + 'cancelCustomizePreferredReactionsModal' + ), + deselectDraftEmoji: action('deselectDraftEmoji'), + draftPreferredReactions: ['✨', '❇️', '🎇', '🦈', '💖', '🅿️'], + hadSaveError: false, + i18n, + isSaving: false, + onSetSkinTone: action('onSetSkinTone'), + originalPreferredReactions: ['❤️', '👍', '👎', '😂', '😮', '😢'], + recentEmojis: ['cake'], + replaceSelectedDraftEmoji: action('replaceSelectedDraftEmoji'), + resetDraftEmoji: action('resetDraftEmoji'), + savePreferredReactions: action('savePreferredReactions'), + selectDraftEmojiToBeReplaced: action('selectDraftEmojiToBeReplaced'), + selectedDraftEmojiIndex: undefined, + skinTone: 4, + }; story.add('Default', () => ( diff --git a/ts/components/CustomizingPreferredReactionsModal.tsx b/ts/components/CustomizingPreferredReactionsModal.tsx index d564bd698..450d26c41 100644 --- a/ts/components/CustomizingPreferredReactionsModal.tsx +++ b/ts/components/CustomizingPreferredReactionsModal.tsx @@ -54,10 +54,8 @@ export function CustomizingPreferredReactionsModal({ selectedDraftEmojiIndex, skinTone, }: Readonly): JSX.Element { - const [ - referenceElement, - setReferenceElement, - ] = useState(null); + const [referenceElement, setReferenceElement] = + useState(null); const [popperElement, setPopperElement] = useState( null ); diff --git a/ts/components/DialogNetworkStatus.stories.tsx b/ts/components/DialogNetworkStatus.stories.tsx index 8ab30d236..d71b86953 100644 --- a/ts/components/DialogNetworkStatus.stories.tsx +++ b/ts/components/DialogNetworkStatus.stories.tsx @@ -60,10 +60,12 @@ story.add('Knobs Playground', () => { ); }); -([ - ['wide', WidthBreakpoint.Wide], - ['narrow', WidthBreakpoint.Narrow], -] as const).forEach(([name, containerWidthBreakpoint]) => { +( + [ + ['wide', WidthBreakpoint.Wide], + ['narrow', WidthBreakpoint.Narrow], + ] as const +).forEach(([name, containerWidthBreakpoint]) => { const defaultPropsForBreakpoint = { ...defaultProps, containerWidthBreakpoint, diff --git a/ts/components/DialogUpdate.stories.tsx b/ts/components/DialogUpdate.stories.tsx index ae224d7c0..0396ed987 100644 --- a/ts/components/DialogUpdate.stories.tsx +++ b/ts/components/DialogUpdate.stories.tsx @@ -54,10 +54,12 @@ story.add('Knobs Playground', () => { ); }); -([ - ['wide', WidthBreakpoint.Wide], - ['narrow', WidthBreakpoint.Narrow], -] as const).forEach(([name, containerWidthBreakpoint]) => { +( + [ + ['wide', WidthBreakpoint.Wide], + ['narrow', WidthBreakpoint.Narrow], + ] as const +).forEach(([name, containerWidthBreakpoint]) => { const defaultPropsForBreakpoint = { ...defaultProps, containerWidthBreakpoint, diff --git a/ts/components/DisappearingTimerSelect.tsx b/ts/components/DisappearingTimerSelect.tsx index 13f096190..f84de20ef 100644 --- a/ts/components/DisappearingTimerSelect.tsx +++ b/ts/components/DisappearingTimerSelect.tsx @@ -38,9 +38,8 @@ export const DisappearingTimerSelect: React.FC = (props: Props) => { }; }); - const isCustomTimeSelected = !expirationTimer.DEFAULT_DURATIONS_SET.has( - value - ); + const isCustomTimeSelected = + !expirationTimer.DEFAULT_DURATIONS_SET.has(value); const onSelectChange = (newValue: string) => { const intValue = parseInt(newValue, 10); diff --git a/ts/components/GroupCallRemoteParticipant.tsx b/ts/components/GroupCallRemoteParticipant.tsx index 605c04434..6bbaf77e8 100644 --- a/ts/components/GroupCallRemoteParticipant.tsx +++ b/ts/components/GroupCallRemoteParticipant.tsx @@ -69,9 +69,8 @@ export const GroupCallRemoteParticipant: React.FC = React.memo( videoAspectRatio, } = props.remoteParticipant; - const [hasReceivedVideoRecently, setHasReceivedVideoRecently] = useState( - false - ); + const [hasReceivedVideoRecently, setHasReceivedVideoRecently] = + useState(false); const [isWide, setIsWide] = useState( videoAspectRatio ? videoAspectRatio >= 1 : true ); @@ -90,10 +89,8 @@ export const GroupCallRemoteParticipant: React.FC = React.memo( const remoteVideoRef = useRef(null); const canvasContextRef = useRef(null); - const [ - intersectionRef, - intersectionObserverEntry, - ] = useIntersectionObserver(); + const [intersectionRef, intersectionObserverEntry] = + useIntersectionObserver(); const isVisible = intersectionObserverEntry ? intersectionObserverEntry.isIntersecting : true; @@ -268,7 +265,8 @@ export const GroupCallRemoteParticipant: React.FC = React.memo( className={classNames( 'module-ongoing-call__group-call-remote-participant--title', { - 'module-ongoing-call__group-call-remote-participant--audio-muted': !hasRemoteAudio, + 'module-ongoing-call__group-call-remote-participant--audio-muted': + !hasRemoteAudio, } )} > diff --git a/ts/components/GroupCallRemoteParticipants.tsx b/ts/components/GroupCallRemoteParticipants.tsx index cddbcc848..184dfb56f 100644 --- a/ts/components/GroupCallRemoteParticipants.tsx +++ b/ts/components/GroupCallRemoteParticipants.tsx @@ -135,33 +135,34 @@ export const GroupCallRemoteParticipants: React.FC = ({ ), [remoteParticipants] ); - const gridParticipants: Array = useMemo(() => { - if (!sortedParticipants.length) { - return []; - } + const gridParticipants: Array = + useMemo(() => { + if (!sortedParticipants.length) { + return []; + } - const candidateParticipants = isInSpeakerView - ? [sortedParticipants[0]] - : sortedParticipants; + const candidateParticipants = isInSpeakerView + ? [sortedParticipants[0]] + : sortedParticipants; - // Imagine that we laid out all of the rows end-to-end. That's the maximum total - // width. So if there were 5 rows and the container was 100px wide, then we can't - // possibly fit more than 500px of participants. - const maxTotalWidth = maxRowCount * containerDimensions.width; + // Imagine that we laid out all of the rows end-to-end. That's the maximum total + // width. So if there were 5 rows and the container was 100px wide, then we can't + // possibly fit more than 500px of participants. + const maxTotalWidth = maxRowCount * containerDimensions.width; - // We do the same thing for participants, "laying them out end-to-end" until they - // exceed the maximum total width. - let totalWidth = 0; - return takeWhile(candidateParticipants, remoteParticipant => { - totalWidth += remoteParticipant.videoAspectRatio * MIN_RENDERED_HEIGHT; - return totalWidth < maxTotalWidth; - }).sort(stableParticipantComparator); - }, [ - containerDimensions.width, - isInSpeakerView, - maxRowCount, - sortedParticipants, - ]); + // We do the same thing for participants, "laying them out end-to-end" until they + // exceed the maximum total width. + let totalWidth = 0; + return takeWhile(candidateParticipants, remoteParticipant => { + totalWidth += remoteParticipant.videoAspectRatio * MIN_RENDERED_HEIGHT; + return totalWidth < maxTotalWidth; + }).sort(stableParticipantComparator); + }, [ + containerDimensions.width, + isInSpeakerView, + maxRowCount, + sortedParticipants, + ]); const overflowedParticipants: Array = useMemo( () => sortedParticipants diff --git a/ts/components/GroupV1MigrationDialog.tsx b/ts/components/GroupV1MigrationDialog.tsx index 46fd800e1..c95b01f25 100644 --- a/ts/components/GroupV1MigrationDialog.tsx +++ b/ts/components/GroupV1MigrationDialog.tsx @@ -24,8 +24,8 @@ export type HousekeepingPropsType = { export type PropsType = DataPropsType & HousekeepingPropsType; -export const GroupV1MigrationDialog: React.FunctionComponent = React.memo( - (props: PropsType) => { +export const GroupV1MigrationDialog: React.FunctionComponent = + React.memo((props: PropsType) => { const { areWeInvited, droppedMembers, @@ -94,8 +94,7 @@ export const GroupV1MigrationDialog: React.FunctionComponent = React. )} ); - } -); + }); function renderMembers( members: Array, diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index 4b760a493..ab6afed5e 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -330,9 +330,8 @@ export const LeftPane: React.FC = ({ const numericIndex = keyboardKeyToNumericIndex(event.key); if (commandOrCtrl && isNumber(numericIndex)) { - conversationToOpen = helper.getConversationAndMessageAtIndex( - numericIndex - ); + conversationToOpen = + helper.getConversationAndMessageAtIndex(numericIndex); } else { let toFind: undefined | ToFindType; if ( diff --git a/ts/components/Lightbox.tsx b/ts/components/Lightbox.tsx index 32adb84dd..3b27d6c98 100644 --- a/ts/components/Lightbox.tsx +++ b/ts/components/Lightbox.tsx @@ -63,9 +63,8 @@ export function Lightbox({ selectedIndex: initialSelectedIndex = 0, }: PropsType): JSX.Element | null { const [root, setRoot] = React.useState(); - const [selectedIndex, setSelectedIndex] = useState( - initialSelectedIndex - ); + const [selectedIndex, setSelectedIndex] = + useState(initialSelectedIndex); const [videoElement, setVideoElement] = useState( null @@ -224,8 +223,13 @@ export function Lightbox({ }; }, [onKeyDown]); - const { attachment, contentType, loop = false, objectURL, message } = - media[selectedIndex] || {}; + const { + attachment, + contentType, + loop = false, + objectURL, + message, + } = media[selectedIndex] || {}; const isAttachmentGIF = isGIF(attachment ? [attachment] : undefined); @@ -251,23 +255,23 @@ export function Lightbox({ () => INITIAL_IMAGE_TRANSFORM ); - const maxBoundsLimiter = useCallback((x: number, y: number): [ - number, - number - ] => { - const zoomCache = zoomCacheRef.current; + const maxBoundsLimiter = useCallback( + (x: number, y: number): [number, number] => { + const zoomCache = zoomCacheRef.current; - if (!zoomCache) { - return [0, 0]; - } + if (!zoomCache) { + return [0, 0]; + } - const { maxX, maxY } = zoomCache; + const { maxX, maxY } = zoomCache; - const posX = Math.min(maxX, Math.max(-maxX, x)); - const posY = Math.min(maxY, Math.max(-maxY, y)); + const posX = Math.min(maxX, Math.max(-maxX, x)); + const posY = Math.min(maxY, Math.max(-maxY, y)); - return [posX, posY]; - }, []); + return [posX, posY]; + }, + [] + ); const positionImage = useCallback( (ev: MouseEvent) => { @@ -352,12 +356,8 @@ export function Lightbox({ screenWidth: window.innerWidth, }; - const { - height, - left, - top, - width, - } = animateNode.getBoundingClientRect(); + const { height, left, top, width } = + animateNode.getBoundingClientRect(); const offsetX = ev.clientX - left - width / 2; const offsetY = ev.clientY - top - height / 2; diff --git a/ts/components/MediaQualitySelector.tsx b/ts/components/MediaQualitySelector.tsx index f2c73944d..ad330c8b5 100644 --- a/ts/components/MediaQualitySelector.tsx +++ b/ts/components/MediaQualitySelector.tsx @@ -133,7 +133,8 @@ export const MediaQualitySelector = ({
diff --git a/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx b/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx index 40aee1f28..06b945a77 100644 --- a/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx +++ b/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx @@ -17,67 +17,68 @@ type PropsType = { onClose: () => void; }; -export const NewlyCreatedGroupInvitedContactsDialog: FunctionComponent = ({ - contacts, - i18n, - onClose, -}) => { - let title: string; - let body: ReactNode; - if (contacts.length === 1) { - const contact = contacts[0]; +export const NewlyCreatedGroupInvitedContactsDialog: FunctionComponent = + ({ contacts, i18n, onClose }) => { + let title: string; + let body: ReactNode; + if (contacts.length === 1) { + const contact = contacts[0]; - title = i18n('NewlyCreatedGroupInvitedContactsDialog--title--one'); - body = ( - <> - - ]} - /> - - - {i18n('NewlyCreatedGroupInvitedContactsDialog--body--info-paragraph')} - - - ); - } else { - title = i18n('NewlyCreatedGroupInvitedContactsDialog--title--many', [ - contacts.length.toString(), - ]); - body = ( - <> - - {i18n( - 'NewlyCreatedGroupInvitedContactsDialog--body--user-paragraph--many' - )} - - - {i18n('NewlyCreatedGroupInvitedContactsDialog--body--info-paragraph')} - - - - ); - } + title = i18n('NewlyCreatedGroupInvitedContactsDialog--title--one'); + body = ( + <> + + ]} + /> + + + {i18n( + 'NewlyCreatedGroupInvitedContactsDialog--body--info-paragraph' + )} + + + ); + } else { + title = i18n('NewlyCreatedGroupInvitedContactsDialog--title--many', [ + contacts.length.toString(), + ]); + body = ( + <> + + {i18n( + 'NewlyCreatedGroupInvitedContactsDialog--body--user-paragraph--many' + )} + + + {i18n( + 'NewlyCreatedGroupInvitedContactsDialog--body--info-paragraph' + )} + + + + ); + } - return ( - { - openLinkInWebBrowser( - 'https://support.signal.org/hc/articles/360007319331-Group-chats' - ); - }} - onClose={onClose} - title={title} - > - {body} - - ); -}; + return ( + { + openLinkInWebBrowser( + 'https://support.signal.org/hc/articles/360007319331-Group-chats' + ); + }} + onClose={onClose} + title={title} + > + {body} + + ); + }; diff --git a/ts/components/Preferences.tsx b/ts/components/Preferences.tsx index 08bb39610..0b5329250 100644 --- a/ts/components/Preferences.tsx +++ b/ts/components/Preferences.tsx @@ -267,10 +267,8 @@ export const Preferences = ({ const [page, setPage] = useState(Page.General); const [showSyncFailed, setShowSyncFailed] = useState(false); const [nowSyncing, setNowSyncing] = useState(false); - const [ - showDisappearingTimerDialog, - setShowDisappearingTimerDialog, - ] = useState(false); + const [showDisappearingTimerDialog, setShowDisappearingTimerDialog] = + useState(false); useEffect(() => { doneRendering(); @@ -281,7 +279,7 @@ export const Preferences = ({ const onZoomSelectChange = useCallback( (value: string) => { const number = parseFloat(value); - onZoomFactorChange((number as unknown) as ZoomFactorType); + onZoomFactorChange(number as unknown as ZoomFactorType); }, [onZoomFactorChange] ); @@ -764,9 +762,8 @@ export const Preferences = ({ ); } else if (page === Page.Privacy) { - const isCustomDisappearingMessageValue = !DEFAULT_DURATIONS_SET.has( - universalExpireTimer - ); + const isCustomDisappearingMessageValue = + !DEFAULT_DURATIONS_SET.has(universalExpireTimer); settings = ( <> diff --git a/ts/components/conversation/ContactSpoofingReviewDialog.tsx b/ts/components/conversation/ContactSpoofingReviewDialog.tsx index 6b21aab57..71da0fd62 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialog.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialog.tsx @@ -57,281 +57,286 @@ enum ConfirmationStateType { ConfirmingGroupRemoval, } -export const ContactSpoofingReviewDialog: FunctionComponent = props => { - const { - i18n, - onBlock, - onBlockAndReportSpam, - onClose, - onDelete, - onShowContactModal, - onUnblock, - removeMember, - } = props; +export const ContactSpoofingReviewDialog: FunctionComponent = + props => { + const { + i18n, + onBlock, + onBlockAndReportSpam, + onClose, + onDelete, + onShowContactModal, + onUnblock, + removeMember, + } = props; - const [confirmationState, setConfirmationState] = useState< - | undefined - | { - type: ConfirmationStateType; - affectedConversation: ConversationType; - } - >(); + const [confirmationState, setConfirmationState] = useState< + | undefined + | { + type: ConfirmationStateType; + affectedConversation: ConversationType; + } + >(); - if (confirmationState) { - const { affectedConversation, type } = confirmationState; - switch (type) { - case ConfirmationStateType.ConfirmingDelete: - case ConfirmationStateType.ConfirmingBlock: - return ( - { - onBlock(affectedConversation.id); - }} - onBlockAndReportSpam={() => { - onBlockAndReportSpam(affectedConversation.id); - }} - onUnblock={() => { - onUnblock(affectedConversation.id); - }} - onDelete={() => { - onDelete(affectedConversation.id); - }} - title={affectedConversation.title} - conversationType="direct" - state={ - type === ConfirmationStateType.ConfirmingDelete - ? MessageRequestState.deleting - : MessageRequestState.blocking - } - onChangeState={messageRequestState => { - switch (messageRequestState) { - case MessageRequestState.blocking: - setConfirmationState({ - type: ConfirmationStateType.ConfirmingBlock, - affectedConversation, - }); - break; - case MessageRequestState.deleting: - setConfirmationState({ - type: ConfirmationStateType.ConfirmingDelete, - affectedConversation, - }); - break; - case MessageRequestState.unblocking: - assert( - false, - 'Got unexpected MessageRequestState.unblocking state. Clearing confiration state' - ); - setConfirmationState(undefined); - break; - case MessageRequestState.default: - setConfirmationState(undefined); - break; - default: - throw missingCaseError(messageRequestState); + if (confirmationState) { + const { affectedConversation, type } = confirmationState; + switch (type) { + case ConfirmationStateType.ConfirmingDelete: + case ConfirmationStateType.ConfirmingBlock: + return ( + { + onBlock(affectedConversation.id); + }} + onBlockAndReportSpam={() => { + onBlockAndReportSpam(affectedConversation.id); + }} + onUnblock={() => { + onUnblock(affectedConversation.id); + }} + onDelete={() => { + onDelete(affectedConversation.id); + }} + title={affectedConversation.title} + conversationType="direct" + state={ + type === ConfirmationStateType.ConfirmingDelete + ? MessageRequestState.deleting + : MessageRequestState.blocking } - }} - /> - ); - case ConfirmationStateType.ConfirmingGroupRemoval: - return ( - { - setConfirmationState(undefined); - }} - onRemove={() => { - removeMember(affectedConversation.id); - }} - /> - ); - default: - throw missingCaseError(type); + onChangeState={messageRequestState => { + switch (messageRequestState) { + case MessageRequestState.blocking: + setConfirmationState({ + type: ConfirmationStateType.ConfirmingBlock, + affectedConversation, + }); + break; + case MessageRequestState.deleting: + setConfirmationState({ + type: ConfirmationStateType.ConfirmingDelete, + affectedConversation, + }); + break; + case MessageRequestState.unblocking: + assert( + false, + 'Got unexpected MessageRequestState.unblocking state. Clearing confiration state' + ); + setConfirmationState(undefined); + break; + case MessageRequestState.default: + setConfirmationState(undefined); + break; + default: + throw missingCaseError(messageRequestState); + } + }} + /> + ); + case ConfirmationStateType.ConfirmingGroupRemoval: + return ( + { + setConfirmationState(undefined); + }} + onRemove={() => { + removeMember(affectedConversation.id); + }} + /> + ); + default: + throw missingCaseError(type); + } } - } - let title: string; - let contents: ReactChild; + let title: string; + let contents: ReactChild; - switch (props.type) { - case ContactSpoofingType.DirectConversationWithSameTitle: { - const { possiblyUnsafeConversation, safeConversation } = props; - assert( - possiblyUnsafeConversation.type === 'direct', - ' expected a direct conversation for the "possibly unsafe" conversation' - ); - assert( - safeConversation.type === 'direct', - ' expected a direct conversation for the "safe" conversation' - ); + switch (props.type) { + case ContactSpoofingType.DirectConversationWithSameTitle: { + const { possiblyUnsafeConversation, safeConversation } = props; + assert( + possiblyUnsafeConversation.type === 'direct', + ' expected a direct conversation for the "possibly unsafe" conversation' + ); + assert( + safeConversation.type === 'direct', + ' expected a direct conversation for the "safe" conversation' + ); - title = i18n('ContactSpoofingReviewDialog__title'); - contents = ( - <> -

{i18n('ContactSpoofingReviewDialog__description')}

-

{i18n('ContactSpoofingReviewDialog__possibly-unsafe-title')}

- -
- - -
-
-
-

{i18n('ContactSpoofingReviewDialog__safe-title')}

- { - onShowContactModal(safeConversation.id); - }} - /> - - ); - break; - } - case ContactSpoofingType.MultipleGroupMembersWithSameTitle: { - const { areWeAdmin, collisionInfoByTitle } = props; - - const unsortedConversationInfos = concat( - // This empty array exists to appease Lodash's type definitions. - [], - ...Object.values(collisionInfoByTitle) - ); - const conversationInfos = orderBy(unsortedConversationInfos, [ - // We normally use an `Intl.Collator` to sort by title. We do this instead, as we - // only really care about stability (not perfect ordering). - 'title', - 'id', - ]); - - title = i18n('ContactSpoofingReviewDialog__group__title'); - contents = ( - <> -

- {i18n('ContactSpoofingReviewDialog__group__description', [ - conversationInfos.length.toString(), - ])} -

-

{i18n('ContactSpoofingReviewDialog__group__members-header')}

- {conversationInfos.map((conversationInfo, index) => { - let button: ReactNode; - if (areWeAdmin) { - button = ( + title = i18n('ContactSpoofingReviewDialog__title'); + contents = ( + <> +

{i18n('ContactSpoofingReviewDialog__description')}

+

+ {i18n('ContactSpoofingReviewDialog__possibly-unsafe-title')} +

+ +
- ); - } else if (conversationInfo.conversation.isBlocked) { - button = ( - - ); - } else if (!isInSystemContacts(conversationInfo.conversation)) { - button = ( +
+
+
+

{i18n('ContactSpoofingReviewDialog__safe-title')}

+ { + onShowContactModal(safeConversation.id); + }} + /> + + ); + break; + } + case ContactSpoofingType.MultipleGroupMembersWithSameTitle: { + const { areWeAdmin, collisionInfoByTitle } = props; + + const unsortedConversationInfos = concat( + // This empty array exists to appease Lodash's type definitions. + [], + ...Object.values(collisionInfoByTitle) + ); + const conversationInfos = orderBy(unsortedConversationInfos, [ + // We normally use an `Intl.Collator` to sort by title. We do this instead, as + // we only really care about stability (not perfect ordering). + 'title', + 'id', + ]); + + title = i18n('ContactSpoofingReviewDialog__group__title'); + contents = ( + <> +

+ {i18n('ContactSpoofingReviewDialog__group__description', [ + conversationInfos.length.toString(), + ])} +

+

+ {i18n('ContactSpoofingReviewDialog__group__members-header')} +

+ {conversationInfos.map((conversationInfo, index) => { + let button: ReactNode; + if (areWeAdmin) { + button = ( + + ); + } else if (conversationInfo.conversation.isBlocked) { + button = ( + + ); + } else if (!isInSystemContacts(conversationInfo.conversation)) { + button = ( + + ); + } + + const { oldName } = conversationInfo; + const newName = + conversationInfo.conversation.profileName || + conversationInfo.conversation.title; + + return ( + <> + {index !== 0 &&
} + + {Boolean(oldName) && oldName !== newName && ( +
+ , + newName: , + }} + /> +
+ )} + {button && ( +
+ {button} +
+ )} +
+ ); - } - - const { oldName } = conversationInfo; - const newName = - conversationInfo.conversation.profileName || - conversationInfo.conversation.title; - - return ( - <> - {index !== 0 &&
} - - {Boolean(oldName) && oldName !== newName && ( -
- , - newName: , - }} - /> -
- )} - {button && ( -
- {button} -
- )} -
- - ); - })} - - ); - break; + })} + + ); + break; + } + default: + throw missingCaseError(props); } - default: - throw missingCaseError(props); - } - return ( - - {contents} - - ); -}; + return ( + + {contents} + + ); + }; diff --git a/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx b/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx index 609a992b2..48ffc470d 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx @@ -19,60 +19,56 @@ type PropsType = { onClick?: () => void; }; -export const ContactSpoofingReviewDialogPerson: FunctionComponent = ({ - children, - conversation, - i18n, - onClick, -}) => { - assert( - conversation.type === 'direct', - ' expected a direct conversation' - ); - - const contents = ( - <> - -
- - {conversation.phoneNumber ? ( -
- {conversation.phoneNumber} -
- ) : null} -
- -
- {children} -
- - ); - - if (onClick) { - return ( - +export const ContactSpoofingReviewDialogPerson: FunctionComponent = + ({ children, conversation, i18n, onClick }) => { + assert( + conversation.type === 'direct', + ' expected a direct conversation' ); - } - return ( -
{contents}
- ); -}; + const contents = ( + <> + +
+ + {conversation.phoneNumber ? ( +
+ {conversation.phoneNumber} +
+ ) : null} +
+ +
+ {children} +
+ + ); + + if (onClick) { + return ( + + ); + } + + return ( +
{contents}
+ ); + }; diff --git a/ts/components/conversation/ConversationHeader.tsx b/ts/components/conversation/ConversationHeader.tsx index 547911cb5..3e0cb4a03 100644 --- a/ts/components/conversation/ConversationHeader.tsx +++ b/ts/components/conversation/ConversationHeader.tsx @@ -523,12 +523,8 @@ export class ConversationHeader extends React.Component { } private renderHeader(): ReactNode { - const { - conversationTitle, - groupVersion, - onShowConversationDetails, - type, - } = this.props; + const { conversationTitle, groupVersion, onShowConversationDetails, type } = + this.props; if (conversationTitle !== undefined) { return ( @@ -592,13 +588,8 @@ export class ConversationHeader extends React.Component { } public render(): ReactNode { - const { - id, - isSMSOnly, - i18n, - onSetDisappearingMessages, - expireTimer, - } = this.props; + const { id, isSMSOnly, i18n, onSetDisappearingMessages, expireTimer } = + this.props; const { isNarrow, modalState } = this.state; const triggerId = `conversation-${id}`; diff --git a/ts/components/conversation/ConversationHero.tsx b/ts/components/conversation/ConversationHero.tsx index 9a6dee956..e38846313 100644 --- a/ts/components/conversation/ConversationHero.tsx +++ b/ts/components/conversation/ConversationHero.tsx @@ -118,10 +118,8 @@ export const ConversationHero = ({ }: Props): JSX.Element => { const firstRenderRef = useRef(true); - const [ - isShowingMessageRequestWarning, - setIsShowingMessageRequestWarning, - ] = useState(false); + const [isShowingMessageRequestWarning, setIsShowingMessageRequestWarning] = + useState(false); const closeMessageRequestWarning = () => { setIsShowingMessageRequestWarning(false); }; diff --git a/ts/components/conversation/GroupDescription.stories.tsx b/ts/components/conversation/GroupDescription.stories.tsx index 3fd06e4ed..f66b44427 100644 --- a/ts/components/conversation/GroupDescription.stories.tsx +++ b/ts/components/conversation/GroupDescription.stories.tsx @@ -26,8 +26,7 @@ story.add('Default', () => ); story.add('Long', () => ( )); @@ -51,8 +50,7 @@ story.add('With emoji', () => ( story.add('With link', () => ( )); @@ -60,8 +58,7 @@ story.add('With link', () => ( story.add('Kitchen sink', () => ( )); diff --git a/ts/components/conversation/Linkify.stories.tsx b/ts/components/conversation/Linkify.stories.tsx index 76f52e544..1206e508e 100644 --- a/ts/components/conversation/Linkify.stories.tsx +++ b/ts/components/conversation/Linkify.stories.tsx @@ -26,8 +26,7 @@ story.add('Only Link', () => { story.add('Links with Text', () => { const props = createProps({ - text: - 'you should see this: https://www.signal.org - it is good. Also: https://placekitten.com!', + text: 'you should see this: https://www.signal.org - it is good. Also: https://placekitten.com!', }); return ; @@ -43,8 +42,7 @@ story.add('Links with Emoji without space', () => { story.add('Links with Emoji and Text', () => { const props = createProps({ - text: - 'https://example.com ⚠️ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ https://example.com', + text: 'https://example.com ⚠️ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ https://example.com', }); return ; @@ -60,8 +58,7 @@ story.add('No Link', () => { story.add('Blocked Protocols', () => { const props = createProps({ - text: - 'smailto:someone@somewhere.com - ftp://something.com - //local/share - \\localshare', + text: 'smailto:someone@somewhere.com - ftp://something.com - //local/share - \\localshare', }); return ; @@ -69,8 +66,7 @@ story.add('Blocked Protocols', () => { story.add('Missing protocols', () => { const props = createProps({ - text: - 'I love example.com. I also love кц.рф. I also love مثال.تونس. But I do not love test.example.', + text: 'I love example.com. I also love кц.рф. I also love مثال.تونس. But I do not love test.example.', }); return ; @@ -78,8 +74,7 @@ story.add('Missing protocols', () => { story.add('Custom Text Render', () => { const props = createProps({ - text: - 'you should see this: https://www.signal.org - it is good. Also: https://placekitten.com!', + text: 'you should see this: https://www.signal.org - it is good. Also: https://placekitten.com!', renderNonLink: ({ text: theText, key }) => (
{theText} diff --git a/ts/components/conversation/Message.stories.tsx b/ts/components/conversation/Message.stories.tsx index a3b33ffac..f5a1b509f 100644 --- a/ts/components/conversation/Message.stories.tsx +++ b/ts/components/conversation/Message.stories.tsx @@ -188,8 +188,7 @@ const renderBothDirections = (props: Props) => ( story.add('Plain Message', () => { const props = createProps({ - text: - 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', + text: 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', }); return renderBothDirections(props); @@ -296,8 +295,7 @@ story.add('Delivered', () => { const props = createProps({ direction: 'outgoing', status: 'delivered', - text: - 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', + text: 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', }); return ; @@ -307,8 +305,7 @@ story.add('Read', () => { const props = createProps({ direction: 'outgoing', status: 'read', - text: - 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', + text: 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', }); return ; @@ -318,8 +315,7 @@ story.add('Sending', () => { const props = createProps({ direction: 'outgoing', status: 'sending', - text: - 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', + text: 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', }); return ; @@ -329,8 +325,7 @@ story.add('Expiring', () => { const props = createProps({ expirationLength: 30 * 1000, expirationTimestamp: Date.now() + 30 * 1000, - text: - 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', + text: 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', }); return renderBothDirections(props); @@ -338,8 +333,7 @@ story.add('Expiring', () => { story.add('Pending', () => { const props = createProps({ - text: - 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', + text: 'Hello there from a pal! I am sending a long message so that it will wrap a bit, since I like that look.', textPending: true, }); diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 1d54fcc93..e6d6e868c 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -296,7 +296,8 @@ export class Message extends React.PureComponent { public audioButtonRef: React.RefObject = React.createRef(); - public reactionsContainerRef: React.RefObject = React.createRef(); + public reactionsContainerRef: React.RefObject = + React.createRef(); public reactionsContainerRefMerger = createRefMerger(); @@ -1194,7 +1195,8 @@ export class Message extends React.PureComponent { return (
{ } public render(): JSX.Element | null { - const { - author, - attachments, - direction, - id, - isSticker, - timestamp, - } = this.props; + const { author, attachments, direction, id, isSticker, timestamp } = + this.props; const { expired, expiring, imageBroken, isSelected } = this.state; // This id is what connects our triple-dot click with our associated pop-up menu. diff --git a/ts/components/conversation/MessageBody.stories.tsx b/ts/components/conversation/MessageBody.stories.tsx index 88d234a3a..866645323 100644 --- a/ts/components/conversation/MessageBody.stories.tsx +++ b/ts/components/conversation/MessageBody.stories.tsx @@ -107,8 +107,7 @@ story.add('@Mention', () => { replacementText: 'Bender B Rodriguez 🤖', }, ], - text: - 'Like \uFFFC once said: My story is a lot like yours, only more interesting because it involves robots', + text: 'Like \uFFFC once said: My story is a lot like yours, only more interesting because it involves robots', }); return ; @@ -167,8 +166,7 @@ story.add('Complex MessageBody', () => { }, ], direction: 'outgoing', - text: - 'Hey \uFFFC\nCheck out https://www.signal.org I think you will really like it 😍\n\ncc \uFFFC \uFFFC', + text: 'Hey \uFFFC\nCheck out https://www.signal.org I think you will really like it 😍\n\ncc \uFFFC \uFFFC', }); return ; diff --git a/ts/components/conversation/MessageMetadata.tsx b/ts/components/conversation/MessageMetadata.tsx index 4563a155f..78b8225cb 100644 --- a/ts/components/conversation/MessageMetadata.tsx +++ b/ts/components/conversation/MessageMetadata.tsx @@ -85,7 +85,8 @@ export const MessageMetadata: FunctionComponent = props => { 'module-message__metadata__date': true, 'module-message__metadata__date--with-sticker': isSticker, [`module-message__metadata__date--${direction}`]: !isSticker, - 'module-message__metadata__date--with-image-no-caption': withImageNoCaption, + 'module-message__metadata__date--with-image-no-caption': + withImageNoCaption, })} > {statusInfo} diff --git a/ts/components/conversation/Quote.tsx b/ts/components/conversation/Quote.tsx index 40d4a3ddd..59cc583c9 100644 --- a/ts/components/conversation/Quote.tsx +++ b/ts/components/conversation/Quote.tsx @@ -127,10 +127,8 @@ export class Quote extends React.Component { } componentDidMount(): void { - const { - doubleCheckMissingQuoteReference, - referencedMessageNotFound, - } = this.props; + const { doubleCheckMissingQuoteReference, referencedMessageNotFound } = + this.props; if (referencedMessageNotFound) { doubleCheckMissingQuoteReference?.(); @@ -275,14 +273,8 @@ export class Quote extends React.Component { } public renderText(): JSX.Element | null { - const { - bodyRanges, - i18n, - text, - rawAttachment, - isIncoming, - isViewOnce, - } = this.props; + const { bodyRanges, i18n, text, rawAttachment, isIncoming, isViewOnce } = + this.props; if (text) { const quoteText = bodyRanges diff --git a/ts/components/conversation/ReactionViewer.tsx b/ts/components/conversation/ReactionViewer.tsx index 477a9fdf9..761ded3f3 100644 --- a/ts/components/conversation/ReactionViewer.tsx +++ b/ts/components/conversation/ReactionViewer.tsx @@ -123,10 +123,8 @@ export const ReactionViewer = React.forwardRef( [reactionsWithEmojiData, groupedAndSortedReactions] ); - const [ - selectedReactionCategory, - setSelectedReactionCategory, - ] = React.useState(pickedReaction || 'all'); + const [selectedReactionCategory, setSelectedReactionCategory] = + React.useState(pickedReaction || 'all'); // Handle escape key useEscapeHandling(onClose); diff --git a/ts/components/conversation/RemoveGroupMemberConfirmationDialog.tsx b/ts/components/conversation/RemoveGroupMemberConfirmationDialog.tsx index 07a171f07..f799c9ee5 100644 --- a/ts/components/conversation/RemoveGroupMemberConfirmationDialog.tsx +++ b/ts/components/conversation/RemoveGroupMemberConfirmationDialog.tsx @@ -18,30 +18,26 @@ type PropsType = { onRemove: () => void; }; -export const RemoveGroupMemberConfirmationDialog: FunctionComponent = ({ - conversation, - i18n, - onClose, - onRemove, -}) => ( - , - }} - /> - } - /> -); +export const RemoveGroupMemberConfirmationDialog: FunctionComponent = + ({ conversation, i18n, onClose, onRemove }) => ( + , + }} + /> + } + /> + ); diff --git a/ts/components/conversation/Timeline.stories.tsx b/ts/components/conversation/Timeline.stories.tsx index 1ebfcee83..ff9b57ac4 100644 --- a/ts/components/conversation/Timeline.stories.tsx +++ b/ts/components/conversation/Timeline.stories.tsx @@ -263,8 +263,7 @@ const items: Record = { previews: [], readStatus: ReadStatus.Read, status: 'sent', - text: - 'Hello there from the new world! And this is multiple lines of text. Lines and lines and lines.', + text: 'Hello there from the new world! And this is multiple lines of text. Lines and lines and lines.', timestamp: Date.now(), }, }, @@ -285,8 +284,7 @@ const items: Record = { previews: [], readStatus: ReadStatus.Read, status: 'read', - text: - 'Hello there from the new world! And this is multiple lines of text. Lines and lines and lines.', + text: 'Hello there from the new world! And this is multiple lines of text. Lines and lines and lines.', timestamp: Date.now(), }, }, diff --git a/ts/components/conversation/Timeline.tsx b/ts/components/conversation/Timeline.tsx index fdd0fb481..9dcd62612 100644 --- a/ts/components/conversation/Timeline.tsx +++ b/ts/components/conversation/Timeline.tsx @@ -710,12 +710,8 @@ export class Timeline extends React.PureComponent { ); public loadOlderMessages = (): void => { - const { - haveOldest, - isLoadingMessages, - items, - loadOlderMessages, - } = this.props; + const { haveOldest, isLoadingMessages, items, loadOlderMessages } = + this.props; if (this.loadCountdownTimeout) { clearTimeout(this.loadCountdownTimeout); diff --git a/ts/components/conversation/conversation-details/AddGroupMembersModal.tsx b/ts/components/conversation/conversation-details/AddGroupMembersModal.tsx index 7f4968478..fb4079434 100644 --- a/ts/components/conversation/conversation-details/AddGroupMembersModal.tsx +++ b/ts/components/conversation/conversation-details/AddGroupMembersModal.tsx @@ -185,9 +185,10 @@ export const AddGroupMembersModal: FunctionComponent = ({ stage: Stage.ChoosingContacts, }); - const contactLookup = useMemo(() => makeLookup(candidateContacts, 'id'), [ - candidateContacts, - ]); + const contactLookup = useMemo( + () => makeLookup(candidateContacts, 'id'), + [candidateContacts] + ); const selectedContacts = deconstructLookup( contactLookup, diff --git a/ts/components/conversation/conversation-details/ConversationDetails.tsx b/ts/components/conversation/conversation-details/ConversationDetails.tsx index 3f858c9a9..1dde593c0 100644 --- a/ts/components/conversation/conversation-details/ConversationDetails.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetails.tsx @@ -148,17 +148,12 @@ export const ConversationDetails: React.ComponentType = ({ const [modalState, setModalState] = useState( ModalState.NothingOpen ); - const [ - editGroupAttributesRequestState, - setEditGroupAttributesRequestState, - ] = useState(RequestState.Inactive); - const [ - addGroupMembersRequestState, - setAddGroupMembersRequestState, - ] = useState(RequestState.Inactive); - const [membersMissingCapability, setMembersMissingCapability] = useState( - false - ); + const [editGroupAttributesRequestState, setEditGroupAttributesRequestState] = + useState(RequestState.Inactive); + const [addGroupMembersRequestState, setAddGroupMembersRequestState] = + useState(RequestState.Inactive); + const [membersMissingCapability, setMembersMissingCapability] = + useState(false); if (conversation === undefined) { throw new Error('ConversationDetails rendered without a conversation'); diff --git a/ts/components/conversation/conversation-details/ConversationNotificationsSettings.tsx b/ts/components/conversation/conversation-details/ConversationNotificationsSettings.tsx index e38f480c3..b22d5ff75 100644 --- a/ts/components/conversation/conversation-details/ConversationNotificationsSettings.tsx +++ b/ts/components/conversation/conversation-details/ConversationNotificationsSettings.tsx @@ -25,98 +25,103 @@ type PropsType = { setMuteExpiration: (muteExpiresAt: undefined | number) => unknown; }; -export const ConversationNotificationsSettings: FunctionComponent = ({ - conversationType, - dontNotifyForMentionsIfMuted, - i18n, - muteExpiresAt, - setMuteExpiration, - setDontNotifyForMentionsIfMuted, -}) => { - const muteOptions = useMemo( - () => [ - ...(isMuted(muteExpiresAt) - ? [] - : [ - { - disabled: true, - text: i18n('notMuted'), - value: -1, - }, - ]), - ...getMuteOptions(muteExpiresAt, i18n).map( - ({ disabled, name, value }) => ({ - disabled, - text: name, - value, - }) - ), - ], - [i18n, muteExpiresAt] - ); - - const onMuteChange = (rawValue: string) => { - const ms = parseIntOrThrow( - rawValue, - 'NotificationSettings: mute ms was not an integer' +export const ConversationNotificationsSettings: FunctionComponent = + ({ + conversationType, + dontNotifyForMentionsIfMuted, + i18n, + muteExpiresAt, + setMuteExpiration, + setDontNotifyForMentionsIfMuted, + }) => { + const muteOptions = useMemo( + () => [ + ...(isMuted(muteExpiresAt) + ? [] + : [ + { + disabled: true, + text: i18n('notMuted'), + value: -1, + }, + ]), + ...getMuteOptions(muteExpiresAt, i18n).map( + ({ disabled, name, value }) => ({ + disabled, + text: name, + value, + }) + ), + ], + [i18n, muteExpiresAt] ); - setMuteExpiration(ms); - }; - const onChangeDontNotifyForMentionsIfMuted = (rawValue: string) => { - setDontNotifyForMentionsIfMuted(rawValue === 'yes'); - }; + const onMuteChange = (rawValue: string) => { + const ms = parseIntOrThrow( + rawValue, + 'NotificationSettings: mute ms was not an integer' + ); + setMuteExpiration(ms); + }; - return ( -
- - - } - label={i18n('muteNotificationsTitle')} - right={ - } /> - )} - -
- ); -}; + {conversationType === 'group' && ( + + } + label={i18n('ConversationNotificationsSettings__mentions__label')} + info={i18n('ConversationNotificationsSettings__mentions__info')} + right={ +