diff --git a/.buildkite/tunnelbroker_client.yml b/.buildkite/tunnelbroker_client.yml --- a/.buildkite/tunnelbroker_client.yml +++ b/.buildkite/tunnelbroker_client.yml @@ -1,5 +1,5 @@ env: - PATH: "$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH" + PATH: '$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH' steps: - label: ':nix: Tunnelbroker Client (Shared)' command: diff --git a/keyserver/docker-compose.yml b/keyserver/docker-compose.yml --- a/keyserver/docker-compose.yml +++ b/keyserver/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.9" +version: '3.9' services: node: build: @@ -12,7 +12,7 @@ image: commapp/node-keyserver:1.0 restart: always ports: - - "3000:3000" + - '3000:3000' env_file: - .env environment: @@ -30,7 +30,7 @@ image: mariadb:10.8.3-jammy restart: always expose: - - "3306" + - '3306' command: > --max-allowed-packet=256M --local-infile=0 @@ -47,7 +47,7 @@ image: redis:6.2.6-bullseye restart: always expose: - - "6379" + - '6379' command: redis-server --loglevel warning volumes: mysqldata: diff --git a/keyserver/src/creators/account-creator.js b/keyserver/src/creators/account-creator.js --- a/keyserver/src/creators/account-creator.js +++ b/keyserver/src/creators/account-creator.js @@ -178,17 +178,13 @@ text: message, })); const messageDatas = [...ashoatMessageDatas, ...privateMessageDatas]; - const [ - messageInfos, - threadsResult, - userInfos, - currentUserInfo, - ] = await Promise.all([ - createMessages(viewer, messageDatas), - fetchThreadInfos(viewer), - fetchKnownUserInfos(viewer), - fetchLoggedInUserInfo(viewer), - ]); + const [messageInfos, threadsResult, userInfos, currentUserInfo] = + await Promise.all([ + createMessages(viewer, messageDatas), + fetchThreadInfos(viewer), + fetchKnownUserInfos(viewer), + fetchLoggedInUserInfo(viewer), + ]); const rawMessageInfos = [ ...ashoatThreadResult.newMessageInfos, ...privateThreadResult.newMessageInfos, diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js --- a/keyserver/src/creators/message-creator.js +++ b/keyserver/src/creators/message-creator.js @@ -127,9 +127,8 @@ } messageIndices.push(i); - const content = messageSpecs[messageData.type].messageContentForServerDB?.( - messageData, - ); + const content = + messageSpecs[messageData.type].messageContentForServerDB?.(messageData); const creation = messageData.localID && viewer.hasSessionInfo @@ -497,11 +496,8 @@ threadsToMessageIndices: $ReadOnlyMap>, messageInfos: $ReadOnlyArray, ) { - const { - threadIDs, - notFocusedThreadIDs, - subthreadsCanSetToUnread, - } = preUserPushInfo; + const { threadIDs, notFocusedThreadIDs, subthreadsCanSetToUnread } = + preUserPushInfo; const latestMessagesPerThread = new Map(); for (const threadID of threadIDs) { const messageIndices = threadsToMessageIndices.get(threadID); diff --git a/keyserver/src/creators/thread-creator.js b/keyserver/src/creators/thread-creator.js --- a/keyserver/src/creators/thread-creator.js +++ b/keyserver/src/creators/thread-creator.js @@ -301,15 +301,13 @@ newMessageInfos = joinThreadResult.rawMessageInfos; } - const { - viewerUpdates: newUpdates, - userInfos: changesetUserInfos, - } = await getChangesetCommitResultForExistingThread( - viewer, - existingThreadID, - joinUpdateInfos, - { calendarQuery, updatesForCurrentSession }, - ); + const { viewerUpdates: newUpdates, userInfos: changesetUserInfos } = + await getChangesetCommitResultForExistingThread( + viewer, + existingThreadID, + joinUpdateInfos, + { calendarQuery, updatesForCurrentSession }, + ); userInfos = { ...userInfos, ...changesetUserInfos }; return { @@ -390,13 +388,10 @@ } const changeset = { membershipRows, relationshipChangeset }; - const { - threadInfos, - viewerUpdates, - userInfos, - } = await commitMembershipChangeset(viewer, changeset, { - updatesForCurrentSession, - }); + const { threadInfos, viewerUpdates, userInfos } = + await commitMembershipChangeset(viewer, changeset, { + updatesForCurrentSession, + }); const initialMemberAndCreatorIDs = initialMemberIDs ? [...initialMemberIDs, viewer.userID] diff --git a/keyserver/src/cron/daily-updates.js b/keyserver/src/cron/daily-updates.js --- a/keyserver/src/cron/daily-updates.js +++ b/keyserver/src/cron/daily-updates.js @@ -48,10 +48,8 @@ // Figure out which day the dev sync is on let devSyncDay = 1; // default to Monday - const entryInfosInDevSyncScheduleThreadThisWeek = await fetchEntryInfosForThreadThisWeek( - viewer, - weeklyDevSyncScheduleThread, - ); + const entryInfosInDevSyncScheduleThreadThisWeek = + await fetchEntryInfosForThreadThisWeek(viewer, weeklyDevSyncScheduleThread); for (const entryInfo of entryInfosInDevSyncScheduleThreadThisWeek) { const entryInfoDate = getDate( entryInfo.year, diff --git a/keyserver/src/deleters/thread-deleters.js b/keyserver/src/deleters/thread-deleters.js --- a/keyserver/src/deleters/thread-deleters.js +++ b/keyserver/src/deleters/thread-deleters.js @@ -30,13 +30,11 @@ } const { threadID } = threadDeletionRequest; - const [ - permissionsBlob, - { threadInfos: serverThreadInfos }, - ] = await Promise.all([ - fetchThreadPermissionsBlob(viewer, threadID), - fetchServerThreadInfos(SQL`t.id = ${threadID}`), - ]); + const [permissionsBlob, { threadInfos: serverThreadInfos }] = + await Promise.all([ + fetchThreadPermissionsBlob(viewer, threadID), + fetchServerThreadInfos(SQL`t.id = ${threadID}`), + ]); if (!permissionsBlob) { // This should only occur if the first request goes through but the client diff --git a/keyserver/src/fetchers/message-fetchers.js b/keyserver/src/fetchers/message-fetchers.js --- a/keyserver/src/fetchers/message-fetchers.js +++ b/keyserver/src/fetchers/message-fetchers.js @@ -275,10 +275,8 @@ criteria: MessageSelectionCriteria, numberPerThread: number, ): Promise { - const { - sqlClause: selectionClause, - timeFilterData, - } = parseMessageSelectionCriteria(viewer, criteria); + const { sqlClause: selectionClause, timeFilterData } = + parseMessageSelectionCriteria(viewer, criteria); const truncationStatuses = {}; const viewerID = viewer.id; @@ -502,10 +500,11 @@ viewer, criteria, ); - const truncationStatuses = messageSelectionCriteriaToInitialTruncationStatuses( - criteria, - messageTruncationStatus.UNCHANGED, - ); + const truncationStatuses = + messageSelectionCriteriaToInitialTruncationStatuses( + criteria, + messageTruncationStatus.UNCHANGED, + ); const viewerID = viewer.id; const query = SQL` diff --git a/keyserver/src/fetchers/thread-permission-fetchers.js b/keyserver/src/fetchers/thread-permission-fetchers.js --- a/keyserver/src/fetchers/thread-permission-fetchers.js +++ b/keyserver/src/fetchers/thread-permission-fetchers.js @@ -275,15 +275,12 @@ return results; })(); - const [ - fetchedMembers, - parentPermissions, - memberOfContainingThread, - ] = await Promise.all([ - fetchMembersPromise, - parentPermissionsPromise, - memberOfContainingThreadPromise, - ]); + const [fetchedMembers, parentPermissions, memberOfContainingThread] = + await Promise.all([ + fetchMembersPromise, + parentPermissionsPromise, + memberOfContainingThreadPromise, + ]); const ignoreMembers = new Set(); for (const memberID of allCandidates) { diff --git a/keyserver/src/fetchers/upload-fetchers.js b/keyserver/src/fetchers/upload-fetchers.js --- a/keyserver/src/fetchers/upload-fetchers.js +++ b/keyserver/src/fetchers/upload-fetchers.js @@ -120,9 +120,8 @@ viewer: Viewer, mediaMessageContents: $ReadOnlyArray, ): Promise<$ReadOnlyArray> { - const uploadIDs = getUploadIDsFromMediaMessageServerDBContents( - mediaMessageContents, - ); + const uploadIDs = + getUploadIDsFromMediaMessageServerDBContents(mediaMessageContents); const query = SQL` SELECT id AS uploadID, secret AS uploadSecret, type AS uploadType, extra AS uploadExtra diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js --- a/keyserver/src/push/send.js +++ b/keyserver/src/push/send.js @@ -122,10 +122,8 @@ ...newMessageInfos, ...existingMessageInfos, ]); - const [ - firstNewMessageInfo, - ...remainingNewMessageInfos - ] = newMessageInfos; + const [firstNewMessageInfo, ...remainingNewMessageInfos] = + newMessageInfos; const threadID = firstNewMessageInfo.threadID; const threadInfo = threadInfos[threadID]; diff --git a/keyserver/src/responders/entry-responders.js b/keyserver/src/responders/entry-responders.js --- a/keyserver/src/responders/entry-responders.js +++ b/keyserver/src/responders/entry-responders.js @@ -221,11 +221,8 @@ throw new ServerError('not_logged_in'); } - const { - difference, - oldCalendarQuery, - sessionUpdate, - } = compareNewCalendarQuery(viewer, request); + const { difference, oldCalendarQuery, sessionUpdate } = + compareNewCalendarQuery(viewer, request); const [response] = await Promise.all([ fetchEntriesForSession(viewer, difference, oldCalendarQuery), diff --git a/keyserver/src/responders/message-responders.js b/keyserver/src/responders/message-responders.js --- a/keyserver/src/responders/message-responders.js +++ b/keyserver/src/responders/message-responders.js @@ -220,15 +220,12 @@ throw new ServerError('invalid_parameters'); } - const [ - serverThreadInfos, - hasPermission, - targetMessageUserInfos, - ] = await Promise.all([ - fetchServerThreadInfos(SQL`t.id = ${threadID}`), - checkThreadPermission(viewer, threadID, threadPermissions.VOICED), - fetchKnownUserInfos(viewer, [targetMessageInfo.creatorID]), - ]); + const [serverThreadInfos, hasPermission, targetMessageUserInfos] = + await Promise.all([ + fetchServerThreadInfos(SQL`t.id = ${threadID}`), + checkThreadPermission(viewer, threadID, threadPermissions.VOICED), + fetchKnownUserInfos(viewer, [targetMessageInfo.creatorID]), + ]); const targetMessageThreadInfo = serverThreadInfos.threadInfos[threadID]; if (targetMessageThreadInfo.sourceMessageID === targetMessageID) { diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js --- a/keyserver/src/responders/user-responders.js +++ b/keyserver/src/responders/user-responders.js @@ -333,9 +333,8 @@ : null; const promises = {}; if (calendarQuery) { - promises.verifyCalendarQueryThreadIDs = verifyCalendarQueryThreadIDs( - calendarQuery, - ); + promises.verifyCalendarQueryThreadIDs = + verifyCalendarQueryThreadIDs(calendarQuery); } const username = request.username ?? request.usernameOrEmail; if (!username) { @@ -395,12 +394,8 @@ ): Promise { await validateInput(viewer, siweAuthRequestInputValidator, input); const request: SIWEAuthRequest = input; - const { - message, - signature, - deviceTokenUpdateRequest, - platformDetails, - } = request; + const { message, signature, deviceTokenUpdateRequest, platformDetails } = + request; const calendarQuery = normalizeCalendarQuery(request.calendarQuery); // 1. Ensure that `message` is a well formed Comm SIWE Auth message. diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -232,17 +232,13 @@ })(); const navInfoPromise = (async () => { - const [ - { threadInfos }, - messageStore, - currentUserInfo, - userStore, - ] = await Promise.all([ - threadInfoPromise, - messageStorePromise, - currentUserInfoPromise, - userStorePromise, - ]); + const [{ threadInfos }, messageStore, currentUserInfo, userStore] = + await Promise.all([ + threadInfoPromise, + messageStorePromise, + currentUserInfoPromise, + userStorePromise, + ]); const finalNavInfo = initialNavInfo; const requestedActiveChatThreadID = finalNavInfo.activeChatThreadID; diff --git a/keyserver/src/socket/socket.js b/keyserver/src/socket/socket.js --- a/keyserver/src/socket/socket.js +++ b/keyserver/src/socket/socket.js @@ -437,17 +437,15 @@ joinedThreads: true, newerThan: oldMessagesCurrentAsOf, }; - const [ - fetchMessagesResult, - { serverRequests, activityUpdateResult }, - ] = await Promise.all([ - fetchMessageInfosSince( - viewer, - messageSelectionCriteria, - defaultNumberPerThread, - ), - processClientResponses(viewer, clientResponses), - ]); + const [fetchMessagesResult, { serverRequests, activityUpdateResult }] = + await Promise.all([ + fetchMessageInfosSince( + viewer, + messageSelectionCriteria, + defaultNumberPerThread, + ), + processClientResponses(viewer, clientResponses), + ]); const messagesResult = { rawMessageInfos: fetchMessagesResult.rawMessageInfos, truncationStatuses: fetchMessagesResult.truncationStatuses, @@ -458,17 +456,13 @@ }; if (!sessionInitializationResult.sessionContinued) { - const [ - threadsResult, - entriesResult, - currentUserInfo, - knownUserInfos, - ] = await Promise.all([ - fetchThreadInfos(viewer), - fetchEntryInfos(viewer, [calendarQuery]), - fetchCurrentUserInfo(viewer), - fetchKnownUserInfos(viewer), - ]); + const [threadsResult, entriesResult, currentUserInfo, knownUserInfos] = + await Promise.all([ + fetchThreadInfos(viewer), + fetchEntryInfos(viewer, [calendarQuery]), + fetchCurrentUserInfo(viewer), + fetchKnownUserInfos(viewer), + ]); const payload: ServerStateSyncFullSocketPayload = { type: stateSyncPayloadTypes.FULL, messagesResult, @@ -497,10 +491,8 @@ payload, }); } else { - const { - sessionUpdate, - deltaEntryInfoResult, - } = sessionInitializationResult; + const { sessionUpdate, deltaEntryInfoResult } = + sessionInitializationResult; const promises = {}; promises.deleteExpiredUpdates = deleteUpdatesBeforeTimeTargetingSession( @@ -665,12 +657,10 @@ const rawUpdateInfos = message.updates; this.redisPromiseResolver.add( (async () => { - const { - updateInfos, - userInfos, - } = await fetchUpdateInfosWithRawUpdateInfos(rawUpdateInfos, { - viewer, - }); + const { updateInfos, userInfos } = + await fetchUpdateInfosWithRawUpdateInfos(rawUpdateInfos, { + viewer, + }); if (updateInfos.length === 0) { console.warn( 'could not get any UpdateInfos from redisMessageTypes.NEW_UPDATES', diff --git a/keyserver/src/updaters/activity-updaters.js b/keyserver/src/updaters/activity-updaters.js --- a/keyserver/src/updaters/activity-updaters.js +++ b/keyserver/src/updaters/activity-updaters.js @@ -138,13 +138,11 @@ unfocusedLatestMessages.set(threadID, newLastReadMessage ?? 0); } } - const [ - unfocusedThreadsWithNewerMessages, - lastMessageInfos, - ] = await Promise.all([ - checkForNewerMessages(viewer, unfocusedLatestMessages), - fetchLastMessageInfo(viewer, [...memberThreadIDs]), - ]); + const [unfocusedThreadsWithNewerMessages, lastMessageInfos] = + await Promise.all([ + checkForNewerMessages(viewer, unfocusedLatestMessages), + fetchLastMessageInfo(viewer, [...memberThreadIDs]), + ]); const threadStatuses: ThreadStatus[] = []; for (const partialThreadStatus of memberPartialThreadStatuses) { @@ -155,10 +153,8 @@ lastMessageInfo !== undefined, `no lastMessageInfo for thread ID ${threadID}`, ); - const { - lastMessage, - lastReadMessage: curLastReadMessage, - } = lastMessageInfo; + const { lastMessage, lastReadMessage: curLastReadMessage } = + lastMessageInfo; if (focusActive) { threadStatuses.push({ @@ -179,9 +175,8 @@ rescindCondition: newLastReadMessage ? SQL`(n.thread = ${threadID} AND n.message <= ${newLastReadMessage})` : null, - newerMessageFromOtherAuthor: unfocusedThreadsWithNewerMessages.has( - threadID, - ), + newerMessageFromOtherAuthor: + unfocusedThreadsWithNewerMessages.has(threadID), }); } } diff --git a/keyserver/src/updaters/relationship-updaters.js b/keyserver/src/updaters/relationship-updaters.js --- a/keyserver/src/updaters/relationship-updaters.js +++ b/keyserver/src/updaters/relationship-updaters.js @@ -61,10 +61,8 @@ // one PERSONAL thread per a pair of users and we can safely call it // repeatedly. const threadIDPerUser = await createPersonalThreads(viewer, request); - const { - userRelationshipOperations, - errors: friendRequestErrors, - } = await fetchFriendRequestRelationshipOperations(viewer, userIDs); + const { userRelationshipOperations, errors: friendRequestErrors } = + await fetchFriendRequestRelationshipOperations(viewer, userIDs); errors = { ...errors, ...friendRequestErrors }; const undirectedInsertRows = []; diff --git a/keyserver/src/updaters/thread-permission-updaters.js b/keyserver/src/updaters/thread-permission-updaters.js --- a/keyserver/src/updaters/thread-permission-updaters.js +++ b/keyserver/src/updaters/thread-permission-updaters.js @@ -472,9 +472,8 @@ threadID, threadType, ); - const permissionsForChildren = makePermissionsForChildrenBlob( - permissions, - ); + const permissionsForChildren = + makePermissionsForChildrenBlob(permissions); const newRole = getRoleForPermissions(targetRole, permissions); const userLostMembership = Number(curRole) > 0 && Number(newRole) <= 0; @@ -628,11 +627,8 @@ const { threadID, changesByUser } = ancestor; for (const [userID, changes] of changesByUser) { for (const descendantThreadInfo of descendantThreadInfos.values()) { - const { - users, - parentThreadID, - containingThreadID, - } = descendantThreadInfo; + const { users, parentThreadID, containingThreadID } = + descendantThreadInfo; if (threadID !== parentThreadID && threadID !== containingThreadID) { continue; } @@ -723,15 +719,12 @@ INNER JOIN memberships pm ON pm.thread = t.parent_thread_id WHERE t.id = ${threadID} `; - const [ - [threadResults], - [membershipResults], - [parentMembershipResults], - ] = await Promise.all([ - dbQuery(threadQuery), - dbQuery(membershipQuery), - dbQuery(parentMembershipQuery), - ]); + const [[threadResults], [membershipResults], [parentMembershipResults]] = + await Promise.all([ + dbQuery(threadQuery), + dbQuery(membershipQuery), + dbQuery(parentMembershipQuery), + ]); if (threadResults.length !== 1) { throw new ServerError('internal_error'); @@ -742,10 +735,8 @@ const hasContainingThreadID = threadResult.containing_thread_id !== null; const parentThreadID = threadResult.parent_thread_id?.toString(); - const membershipInfo: Map< - string, - RecalculatePermissionsMemberInfo, - > = new Map(); + const membershipInfo: Map = + new Map(); for (const row of membershipResults) { const userID = row.user.toString(); membershipInfo.set(userID, { @@ -786,10 +777,8 @@ const membershipRows = []; const toUpdateDescendants = new Map(); for (const [userID, membership] of membershipInfo) { - const { - rolePermissions: intendedRolePermissions, - permissionsFromParent, - } = membership; + const { rolePermissions: intendedRolePermissions, permissionsFromParent } = + membership; const oldPermissions = membership?.permissions ?? null; const oldPermissionsForChildren = membership?.permissionsForChildren ?? null; diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js --- a/keyserver/src/updaters/thread-updaters.js +++ b/keyserver/src/updaters/thread-updaters.js @@ -629,10 +629,8 @@ })(); } - const { - addMembersChangeset, - recalculatePermissionsChangeset, - } = await promiseAll(intermediatePromises); + const { addMembersChangeset, recalculatePermissionsChangeset } = + await promiseAll(intermediatePromises); const membershipRows = []; const relationshipChangeset = new RelationshipChangeset(); diff --git a/keyserver/src/updaters/upload-updaters.js b/keyserver/src/updaters/upload-updaters.js --- a/keyserver/src/updaters/upload-updaters.js +++ b/keyserver/src/updaters/upload-updaters.js @@ -24,9 +24,8 @@ mediaMessageContents: $ReadOnlyArray, containerID: string, ): Promise { - const uploadIDs = getUploadIDsFromMediaMessageServerDBContents( - mediaMessageContents, - ); + const uploadIDs = + getUploadIDsFromMediaMessageServerDBContents(mediaMessageContents); const query = SQL` UPDATE uploads SET container = ${containerID} diff --git a/keyserver/src/uploads/media-utils.js b/keyserver/src/uploads/media-utils.js --- a/keyserver/src/uploads/media-utils.js +++ b/keyserver/src/uploads/media-utils.js @@ -143,10 +143,8 @@ }); const convertedDimensions = { width: info.width, height: info.height }; - const { - mime: convertedMIME, - mediaType: convertedMediaType, - } = deepFileInfoFromData(convertedBuffer); + const { mime: convertedMIME, mediaType: convertedMediaType } = + deepFileInfoFromData(convertedBuffer); if ( !convertedMIME || !convertedMediaType || diff --git a/landing/investor-data.js b/landing/investor-data.js --- a/landing/investor-data.js +++ b/landing/investor-data.js @@ -779,12 +779,10 @@ }, ]; -const shuffledInvestorsData: $ReadOnlyArray = _shuffle( - investorsData, -); +const shuffledInvestorsData: $ReadOnlyArray = + _shuffle(investorsData); -const keyedInvestorData: { [key: string]: Investors } = _keyBy('id')( - investorsData, -); +const keyedInvestorData: { [key: string]: Investors } = + _keyBy('id')(investorsData); export { shuffledInvestorsData, keyedInvestorData }; diff --git a/landing/siwe.react.js b/landing/siwe.react.js --- a/landing/siwe.react.js +++ b/landing/siwe.react.js @@ -74,9 +74,8 @@ function SIWE(): React.Node { const { address } = useAccount(); const { data: signer } = useSigner(); - const { siweNonce, siwePrimaryIdentityPublicKey } = React.useContext( - SIWEContext, - ); + const { siweNonce, siwePrimaryIdentityPublicKey } = + React.useContext(SIWEContext); const onClick = React.useCallback(() => { invariant(siweNonce, 'nonce must be present during SIWE attempt'); const statement = siwePrimaryIdentityPublicKey diff --git a/landing/subscription-form.react.js b/landing/subscription-form.react.js --- a/landing/subscription-form.react.js +++ b/landing/subscription-form.react.js @@ -14,10 +14,8 @@ function SubscriptionForm(): React.Node { const [email, setEmail] = React.useState(''); - const [ - subscriptionFormStatus, - setSubscriptionFormStatus, - ] = React.useState({ status: 'pending' }); + const [subscriptionFormStatus, setSubscriptionFormStatus] = + React.useState({ status: 'pending' }); const onEmailSubmitted = React.useCallback( async (e: Event) => { diff --git a/lib/actions/activity-actions.js b/lib/actions/activity-actions.js --- a/lib/actions/activity-actions.js +++ b/lib/actions/activity-actions.js @@ -14,41 +14,45 @@ success: 'UPDATE_ACTIVITY_SUCCESS', failed: 'UPDATE_ACTIVITY_FAILED', }); -const updateActivity = ( - callServerEndpoint: CallServerEndpoint, -): (( - activityUpdates: $ReadOnlyArray, -) => Promise) => async activityUpdates => { - const response = await callServerEndpoint('update_activity', { - updates: activityUpdates, - }); - return { - activityUpdates, - result: { - unfocusedToUnread: response.unfocusedToUnread, - }, +const updateActivity = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + activityUpdates: $ReadOnlyArray, + ) => Promise) => + async activityUpdates => { + const response = await callServerEndpoint('update_activity', { + updates: activityUpdates, + }); + return { + activityUpdates, + result: { + unfocusedToUnread: response.unfocusedToUnread, + }, + }; }; -}; const setThreadUnreadStatusActionTypes = Object.freeze({ started: 'SET_THREAD_UNREAD_STATUS_STARTED', success: 'SET_THREAD_UNREAD_STATUS_SUCCESS', failed: 'SET_THREAD_UNREAD_STATUS_FAILED', }); -const setThreadUnreadStatus = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: SetThreadUnreadStatusRequest, -) => Promise) => async request => { - const response: SetThreadUnreadStatusResult = await callServerEndpoint( - 'set_thread_unread_status', - request, - ); - return { - resetToUnread: response.resetToUnread, - threadID: request.threadID, +const setThreadUnreadStatus = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + request: SetThreadUnreadStatusRequest, + ) => Promise) => + async request => { + const response: SetThreadUnreadStatusResult = await callServerEndpoint( + 'set_thread_unread_status', + request, + ); + return { + resetToUnread: response.resetToUnread, + threadID: request.threadID, + }; }; -}; export { updateActivityActionTypes, diff --git a/lib/actions/device-actions.js b/lib/actions/device-actions.js --- a/lib/actions/device-actions.js +++ b/lib/actions/device-actions.js @@ -8,14 +8,16 @@ success: 'SET_DEVICE_TOKEN_SUCCESS', failed: 'SET_DEVICE_TOKEN_FAILED', }); -const setDeviceToken = ( - callServerEndpoint: CallServerEndpoint, -): ((deviceToken: ?string) => Promise) => async deviceToken => { - await callServerEndpoint('update_device_token', { - deviceToken, - platformDetails: getConfig().platformDetails, - }); - return deviceToken; -}; +const setDeviceToken = + ( + callServerEndpoint: CallServerEndpoint, + ): ((deviceToken: ?string) => Promise) => + async deviceToken => { + await callServerEndpoint('update_device_token', { + deviceToken, + platformDetails: getConfig().platformDetails, + }); + return deviceToken; + }; export { setDeviceTokenActionTypes, setDeviceToken }; diff --git a/lib/actions/entry-actions.js b/lib/actions/entry-actions.js --- a/lib/actions/entry-actions.js +++ b/lib/actions/entry-actions.js @@ -24,43 +24,42 @@ success: 'FETCH_ENTRIES_SUCCESS', failed: 'FETCH_ENTRIES_FAILED', }); -const fetchEntries = ( - callServerEndpoint: CallServerEndpoint, -): (( - calendarQuery: CalendarQuery, -) => Promise) => async calendarQuery => { - const response = await callServerEndpoint('fetch_entries', calendarQuery); - return { - rawEntryInfos: response.rawEntryInfos, +const fetchEntries = + ( + callServerEndpoint: CallServerEndpoint, + ): ((calendarQuery: CalendarQuery) => Promise) => + async calendarQuery => { + const response = await callServerEndpoint('fetch_entries', calendarQuery); + return { + rawEntryInfos: response.rawEntryInfos, + }; }; -}; const updateCalendarQueryActionTypes = Object.freeze({ started: 'UPDATE_CALENDAR_QUERY_STARTED', success: 'UPDATE_CALENDAR_QUERY_SUCCESS', failed: 'UPDATE_CALENDAR_QUERY_FAILED', }); -const updateCalendarQuery = ( - callServerEndpoint: CallServerEndpoint, -): (( - calendarQuery: CalendarQuery, - reduxAlreadyUpdated?: boolean, -) => Promise) => async ( - calendarQuery, - reduxAlreadyUpdated = false, -) => { - const response = await callServerEndpoint( - 'update_calendar_query', - calendarQuery, - ); - const { rawEntryInfos, deletedEntryIDs } = response; - return { - rawEntryInfos, - deletedEntryIDs, - calendarQuery, - calendarQueryAlreadyUpdated: reduxAlreadyUpdated, +const updateCalendarQuery = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + calendarQuery: CalendarQuery, + reduxAlreadyUpdated?: boolean, + ) => Promise) => + async (calendarQuery, reduxAlreadyUpdated = false) => { + const response = await callServerEndpoint( + 'update_calendar_query', + calendarQuery, + ); + const { rawEntryInfos, deletedEntryIDs } = response; + return { + rawEntryInfos, + deletedEntryIDs, + calendarQuery, + calendarQueryAlreadyUpdated: reduxAlreadyUpdated, + }; }; -}; const createLocalEntryActionType = 'CREATE_LOCAL_ENTRY'; function createLocalEntry( @@ -89,20 +88,20 @@ success: 'CREATE_ENTRY_SUCCESS', failed: 'CREATE_ENTRY_FAILED', }); -const createEntry = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: CreateEntryInfo, -) => Promise) => async request => { - const result = await callServerEndpoint('create_entry', request); - return { - entryID: result.entryID, - newMessageInfos: result.newMessageInfos, - threadID: request.threadID, - localID: request.localID, - updatesResult: result.updatesResult, +const createEntry = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: CreateEntryInfo) => Promise) => + async request => { + const result = await callServerEndpoint('create_entry', request); + return { + entryID: result.entryID, + newMessageInfos: result.newMessageInfos, + threadID: request.threadID, + localID: request.localID, + updatesResult: result.updatesResult, + }; }; -}; const saveEntryActionTypes = Object.freeze({ started: 'SAVE_ENTRY_STARTED', @@ -110,69 +109,75 @@ failed: 'SAVE_ENTRY_FAILED', }); const concurrentModificationResetActionType = 'CONCURRENT_MODIFICATION_RESET'; -const saveEntry = ( - callServerEndpoint: CallServerEndpoint, -): ((request: SaveEntryInfo) => Promise) => async request => { - const result = await callServerEndpoint('update_entry', request); - return { - entryID: result.entryID, - newMessageInfos: result.newMessageInfos, - updatesResult: result.updatesResult, +const saveEntry = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: SaveEntryInfo) => Promise) => + async request => { + const result = await callServerEndpoint('update_entry', request); + return { + entryID: result.entryID, + newMessageInfos: result.newMessageInfos, + updatesResult: result.updatesResult, + }; }; -}; const deleteEntryActionTypes = Object.freeze({ started: 'DELETE_ENTRY_STARTED', success: 'DELETE_ENTRY_SUCCESS', failed: 'DELETE_ENTRY_FAILED', }); -const deleteEntry = ( - callServerEndpoint: CallServerEndpoint, -): ((info: DeleteEntryInfo) => Promise) => async info => { - const response = await callServerEndpoint('delete_entry', { - ...info, - timestamp: Date.now(), - }); - return { - newMessageInfos: response.newMessageInfos, - threadID: response.threadID, - updatesResult: response.updatesResult, +const deleteEntry = + ( + callServerEndpoint: CallServerEndpoint, + ): ((info: DeleteEntryInfo) => Promise) => + async info => { + const response = await callServerEndpoint('delete_entry', { + ...info, + timestamp: Date.now(), + }); + return { + newMessageInfos: response.newMessageInfos, + threadID: response.threadID, + updatesResult: response.updatesResult, + }; }; -}; const fetchRevisionsForEntryActionTypes = Object.freeze({ started: 'FETCH_REVISIONS_FOR_ENTRY_STARTED', success: 'FETCH_REVISIONS_FOR_ENTRY_SUCCESS', failed: 'FETCH_REVISIONS_FOR_ENTRY_FAILED', }); -const fetchRevisionsForEntry = ( - callServerEndpoint: CallServerEndpoint, -): (( - entryID: string, -) => Promise<$ReadOnlyArray>) => async entryID => { - const response = await callServerEndpoint('fetch_entry_revisions', { - id: entryID, - }); - return response.result; -}; +const fetchRevisionsForEntry = + ( + callServerEndpoint: CallServerEndpoint, + ): ((entryID: string) => Promise<$ReadOnlyArray>) => + async entryID => { + const response = await callServerEndpoint('fetch_entry_revisions', { + id: entryID, + }); + return response.result; + }; const restoreEntryActionTypes = Object.freeze({ started: 'RESTORE_ENTRY_STARTED', success: 'RESTORE_ENTRY_SUCCESS', failed: 'RESTORE_ENTRY_FAILED', }); -const restoreEntry = ( - callServerEndpoint: CallServerEndpoint, -): ((info: RestoreEntryInfo) => Promise) => async info => { - const response = await callServerEndpoint('restore_entry', { - ...info, - timestamp: Date.now(), - }); - return { - newMessageInfos: response.newMessageInfos, - updatesResult: response.updatesResult, +const restoreEntry = + ( + callServerEndpoint: CallServerEndpoint, + ): ((info: RestoreEntryInfo) => Promise) => + async info => { + const response = await callServerEndpoint('restore_entry', { + ...info, + timestamp: Date.now(), + }); + return { + newMessageInfos: response.newMessageInfos, + updatesResult: response.updatesResult, + }; }; -}; export { fetchEntriesActionTypes, diff --git a/lib/actions/message-actions.js b/lib/actions/message-actions.js --- a/lib/actions/message-actions.js +++ b/lib/actions/message-actions.js @@ -19,108 +19,109 @@ success: 'FETCH_MESSAGES_BEFORE_CURSOR_SUCCESS', failed: 'FETCH_MESSAGES_BEFORE_CURSOR_FAILED', }); -const fetchMessagesBeforeCursor = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, - beforeMessageID: string, -) => Promise) => async ( - threadID, - beforeMessageID, -) => { - const response = await callServerEndpoint('fetch_messages', { - cursors: { - [threadID]: beforeMessageID, - }, - }); - return { - threadID, - rawMessageInfos: response.rawMessageInfos, - truncationStatus: response.truncationStatuses[threadID], +const fetchMessagesBeforeCursor = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + beforeMessageID: string, + ) => Promise) => + async (threadID, beforeMessageID) => { + const response = await callServerEndpoint('fetch_messages', { + cursors: { + [threadID]: beforeMessageID, + }, + }); + return { + threadID, + rawMessageInfos: response.rawMessageInfos, + truncationStatus: response.truncationStatuses[threadID], + }; }; -}; const fetchMostRecentMessagesActionTypes = Object.freeze({ started: 'FETCH_MOST_RECENT_MESSAGES_STARTED', success: 'FETCH_MOST_RECENT_MESSAGES_SUCCESS', failed: 'FETCH_MOST_RECENT_MESSAGES_FAILED', }); -const fetchMostRecentMessages = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, -) => Promise) => async threadID => { - const response = await callServerEndpoint('fetch_messages', { - cursors: { - [threadID]: null, - }, - }); - return { - threadID, - rawMessageInfos: response.rawMessageInfos, - truncationStatus: response.truncationStatuses[threadID], +const fetchMostRecentMessages = + ( + callServerEndpoint: CallServerEndpoint, + ): ((threadID: string) => Promise) => + async threadID => { + const response = await callServerEndpoint('fetch_messages', { + cursors: { + [threadID]: null, + }, + }); + return { + threadID, + rawMessageInfos: response.rawMessageInfos, + truncationStatus: response.truncationStatuses[threadID], + }; }; -}; const fetchSingleMostRecentMessagesFromThreadsActionTypes = Object.freeze({ started: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_STARTED', success: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_SUCCESS', failed: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_FAILED', }); -const fetchSingleMostRecentMessagesFromThreads = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadIDs: $ReadOnlyArray, -) => Promise) => async threadIDs => { - const cursors = Object.fromEntries( - threadIDs.map(threadID => [threadID, null]), - ); - const response = await callServerEndpoint('fetch_messages', { - cursors, - numberPerThread: 1, - }); - return { - rawMessageInfos: response.rawMessageInfos, - truncationStatuses: response.truncationStatuses, +const fetchSingleMostRecentMessagesFromThreads = + ( + callServerEndpoint: CallServerEndpoint, + ): ((threadIDs: $ReadOnlyArray) => Promise) => + async threadIDs => { + const cursors = Object.fromEntries( + threadIDs.map(threadID => [threadID, null]), + ); + const response = await callServerEndpoint('fetch_messages', { + cursors, + numberPerThread: 1, + }); + return { + rawMessageInfos: response.rawMessageInfos, + truncationStatuses: response.truncationStatuses, + }; }; -}; const sendTextMessageActionTypes = Object.freeze({ started: 'SEND_TEXT_MESSAGE_STARTED', success: 'SEND_TEXT_MESSAGE_SUCCESS', failed: 'SEND_TEXT_MESSAGE_FAILED', }); -const sendTextMessage = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, - localID: string, - text: string, -) => Promise) => async (threadID, localID, text) => { - let resultInfo; - const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { - resultInfo = passedResultInfo; - }; - const response = await callServerEndpoint( - 'create_text_message', - { - threadID, - localID, - text, - }, - { getResultInfo }, - ); - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callServerEndpoint resolves', - ); - return { - id: response.newMessageInfo.id, - time: response.newMessageInfo.time, - interface: resultInterface, +const sendTextMessage = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + localID: string, + text: string, + ) => Promise) => + async (threadID, localID, text) => { + let resultInfo; + const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { + resultInfo = passedResultInfo; + }; + const response = await callServerEndpoint( + 'create_text_message', + { + threadID, + localID, + text, + }, + { getResultInfo }, + ); + const resultInterface = resultInfo?.interface; + invariant( + resultInterface, + 'getResultInfo not called before callServerEndpoint resolves', + ); + return { + id: response.newMessageInfo.id, + time: response.newMessageInfo.time, + interface: resultInterface, + }; }; -}; const createLocalMessageActionType = 'CREATE_LOCAL_MESSAGE'; @@ -129,113 +130,113 @@ success: 'SEND_MULTIMEDIA_MESSAGE_SUCCESS', failed: 'SEND_MULTIMEDIA_MESSAGE_FAILED', }); -const sendMultimediaMessage = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, - localID: string, - mediaMessageContents: $ReadOnlyArray, -) => Promise) => async ( - threadID, - localID, - mediaMessageContents, -) => { - let resultInfo; - const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { - resultInfo = passedResultInfo; +const sendMultimediaMessage = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + localID: string, + mediaMessageContents: $ReadOnlyArray, + ) => Promise) => + async (threadID, localID, mediaMessageContents) => { + let resultInfo; + const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { + resultInfo = passedResultInfo; + }; + const response = await callServerEndpoint( + 'create_multimedia_message', + { + threadID, + localID, + mediaMessageContents, + }, + { getResultInfo }, + ); + const resultInterface = resultInfo?.interface; + invariant( + resultInterface, + 'getResultInfo not called before callServerEndpoint resolves', + ); + return { + id: response.newMessageInfo.id, + time: response.newMessageInfo.time, + interface: resultInterface, + }; }; - const response = await callServerEndpoint( - 'create_multimedia_message', - { - threadID, - localID, - mediaMessageContents, - }, - { getResultInfo }, - ); - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callServerEndpoint resolves', - ); - return { - id: response.newMessageInfo.id, - time: response.newMessageInfo.time, - interface: resultInterface, - }; -}; -const legacySendMultimediaMessage = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, - localID: string, - mediaIDs: $ReadOnlyArray, -) => Promise) => async (threadID, localID, mediaIDs) => { - let resultInfo; - const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { - resultInfo = passedResultInfo; - }; - const response = await callServerEndpoint( - 'create_multimedia_message', - { - threadID, - localID, - mediaIDs, - }, - { getResultInfo }, - ); - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callServerEndpoint resolves', - ); - return { - id: response.newMessageInfo.id, - time: response.newMessageInfo.time, - interface: resultInterface, +const legacySendMultimediaMessage = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + localID: string, + mediaIDs: $ReadOnlyArray, + ) => Promise) => + async (threadID, localID, mediaIDs) => { + let resultInfo; + const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { + resultInfo = passedResultInfo; + }; + const response = await callServerEndpoint( + 'create_multimedia_message', + { + threadID, + localID, + mediaIDs, + }, + { getResultInfo }, + ); + const resultInterface = resultInfo?.interface; + invariant( + resultInterface, + 'getResultInfo not called before callServerEndpoint resolves', + ); + return { + id: response.newMessageInfo.id, + time: response.newMessageInfo.time, + interface: resultInterface, + }; }; -}; const sendReactionMessageActionTypes = Object.freeze({ started: 'SEND_REACTION_MESSAGE_STARTED', success: 'SEND_REACTION_MESSAGE_SUCCESS', failed: 'SEND_REACTION_MESSAGE_FAILED', }); -const sendReactionMessage = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: SendReactionMessageRequest, -) => Promise) => async request => { - let resultInfo; - const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { - resultInfo = passedResultInfo; - }; +const sendReactionMessage = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: SendReactionMessageRequest) => Promise) => + async request => { + let resultInfo; + const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { + resultInfo = passedResultInfo; + }; - const response = await callServerEndpoint( - 'create_reaction_message', - { - threadID: request.threadID, - localID: request.localID, - targetMessageID: request.targetMessageID, - reaction: request.reaction, - action: request.action, - }, - { getResultInfo }, - ); + const response = await callServerEndpoint( + 'create_reaction_message', + { + threadID: request.threadID, + localID: request.localID, + targetMessageID: request.targetMessageID, + reaction: request.reaction, + action: request.action, + }, + { getResultInfo }, + ); - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callServerEndpoint resolves', - ); + const resultInterface = resultInfo?.interface; + invariant( + resultInterface, + 'getResultInfo not called before callServerEndpoint resolves', + ); - return { - id: response.newMessageInfo.id, - time: response.newMessageInfo.time, - interface: resultInterface, + return { + id: response.newMessageInfo.id, + time: response.newMessageInfo.time, + interface: resultInterface, + }; }; -}; const saveMessagesActionType = 'SAVE_MESSAGES'; const processMessagesActionType = 'PROCESS_MESSAGES'; diff --git a/lib/actions/message-report-actions.js b/lib/actions/message-report-actions.js --- a/lib/actions/message-report-actions.js +++ b/lib/actions/message-report-actions.js @@ -11,12 +11,14 @@ success: 'SEND_MESSAGE_REPORT_SUCCESS', failed: 'SEND_MESSAGE_REPORT_FAILED', }); -const sendMessageReport = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: MessageReportCreationRequest, -) => Promise) => async request => { - return await callServerEndpoint('create_message_report', request); -}; +const sendMessageReport = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + request: MessageReportCreationRequest, + ) => Promise) => + async request => { + return await callServerEndpoint('create_message_report', request); + }; export { sendMessageReportActionTypes, sendMessageReport }; diff --git a/lib/actions/relationship-actions.js b/lib/actions/relationship-actions.js --- a/lib/actions/relationship-actions.js +++ b/lib/actions/relationship-actions.js @@ -12,23 +12,23 @@ success: 'UPDATE_RELATIONSHIPS_SUCCESS', failed: 'UPDATE_RELATIONSHIPS_FAILED', }); -const updateRelationships = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: RelationshipRequest, -) => Promise) => async request => { - const errors = await callServerEndpoint('update_relationships', request); +const updateRelationships = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: RelationshipRequest) => Promise) => + async request => { + const errors = await callServerEndpoint('update_relationships', request); - const { invalid_user, already_friends, user_blocked } = errors; - if (invalid_user) { - throw new ServerError('invalid_user', errors); - } else if (already_friends) { - throw new ServerError('already_friends', errors); - } else if (user_blocked) { - throw new ServerError('user_blocked', errors); - } + const { invalid_user, already_friends, user_blocked } = errors; + if (invalid_user) { + throw new ServerError('invalid_user', errors); + } else if (already_friends) { + throw new ServerError('already_friends', errors); + } else if (user_blocked) { + throw new ServerError('user_blocked', errors); + } - return errors; -}; + return errors; + }; export { updateRelationshipsActionTypes, updateRelationships }; diff --git a/lib/actions/report-actions.js b/lib/actions/report-actions.js --- a/lib/actions/report-actions.js +++ b/lib/actions/report-actions.js @@ -12,35 +12,39 @@ failed: 'SEND_REPORT_FAILED', }); const callServerEndpointOptions = { timeout: 60000 }; -const sendReport = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: ClientReportCreationRequest, -) => Promise) => async request => { - const response = await callServerEndpoint( - 'create_report', - request, - callServerEndpointOptions, - ); - return { id: response.id }; -}; +const sendReport = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + request: ClientReportCreationRequest, + ) => Promise) => + async request => { + const response = await callServerEndpoint( + 'create_report', + request, + callServerEndpointOptions, + ); + return { id: response.id }; + }; const sendReportsActionTypes = Object.freeze({ started: 'SEND_REPORTS_STARTED', success: 'SEND_REPORTS_SUCCESS', failed: 'SEND_REPORTS_FAILED', }); -const sendReports = ( - callServerEndpoint: CallServerEndpoint, -): (( - reports: $ReadOnlyArray, -) => Promise) => async reports => { - await callServerEndpoint( - 'create_reports', - { reports }, - callServerEndpointOptions, - ); -}; +const sendReports = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + reports: $ReadOnlyArray, + ) => Promise) => + async reports => { + await callServerEndpoint( + 'create_reports', + { reports }, + callServerEndpointOptions, + ); + }; const queueReportsActionType = 'QUEUE_REPORTS'; diff --git a/lib/actions/siwe-actions.js b/lib/actions/siwe-actions.js --- a/lib/actions/siwe-actions.js +++ b/lib/actions/siwe-actions.js @@ -15,12 +15,12 @@ success: 'GET_SIWE_NONCE_SUCCESS', failed: 'GET_SIWE_NONCE_FAILED', }); -const getSIWENonce = ( - callServerEndpoint: CallServerEndpoint, -): (() => Promise) => async () => { - const response = await callServerEndpoint('siwe_nonce'); - return response.nonce; -}; +const getSIWENonce = + (callServerEndpoint: CallServerEndpoint): (() => Promise) => + async () => { + const response = await callServerEndpoint('siwe_nonce'); + return response.nonce; + }; const siweAuthActionTypes = Object.freeze({ started: 'SIWE_AUTH_STARTED', @@ -28,43 +28,43 @@ failed: 'SIWE_AUTH_FAILED', }); const siweAuthCallServerEndpointOptions = { timeout: 60000 }; -const siweAuth = ( - callServerEndpoint: CallServerEndpoint, -): (( - siweAuthPayload: SIWEAuthServerCall, -) => Promise) => async siweAuthPayload => { - const watchedIDs = threadWatcher.getWatchedIDs(); - const response = await callServerEndpoint( - 'siwe_auth', - { - ...siweAuthPayload, - watchedIDs, - platformDetails: getConfig().platformDetails, - }, - siweAuthCallServerEndpointOptions, - ); - const userInfos = mergeUserInfos( - response.userInfos, - response.cookieChange.userInfos, - ); - return { - threadInfos: response.cookieChange.threadInfos, - currentUserInfo: response.currentUserInfo, - calendarResult: { - calendarQuery: siweAuthPayload.calendarQuery, - rawEntryInfos: response.rawEntryInfos, - }, - messagesResult: { - messageInfos: response.rawMessageInfos, - truncationStatus: response.truncationStatuses, - watchedIDsAtRequestTime: watchedIDs, - currentAsOf: response.serverTime, - }, - userInfos, - updatesCurrentAsOf: response.serverTime, - logInActionSource: logInActionSources.logInFromNativeSIWE, - notAcknowledgedPolicies: response.notAcknowledgedPolicies, +const siweAuth = + ( + callServerEndpoint: CallServerEndpoint, + ): ((siweAuthPayload: SIWEAuthServerCall) => Promise) => + async siweAuthPayload => { + const watchedIDs = threadWatcher.getWatchedIDs(); + const response = await callServerEndpoint( + 'siwe_auth', + { + ...siweAuthPayload, + watchedIDs, + platformDetails: getConfig().platformDetails, + }, + siweAuthCallServerEndpointOptions, + ); + const userInfos = mergeUserInfos( + response.userInfos, + response.cookieChange.userInfos, + ); + return { + threadInfos: response.cookieChange.threadInfos, + currentUserInfo: response.currentUserInfo, + calendarResult: { + calendarQuery: siweAuthPayload.calendarQuery, + rawEntryInfos: response.rawEntryInfos, + }, + messagesResult: { + messageInfos: response.rawMessageInfos, + truncationStatus: response.truncationStatuses, + watchedIDsAtRequestTime: watchedIDs, + currentAsOf: response.serverTime, + }, + userInfos, + updatesCurrentAsOf: response.serverTime, + logInActionSource: logInActionSources.logInFromNativeSIWE, + notAcknowledgedPolicies: response.notAcknowledgedPolicies, + }; }; -}; export { getSIWENonceActionTypes, getSIWENonce, siweAuthActionTypes, siweAuth }; diff --git a/lib/actions/thread-actions.js b/lib/actions/thread-actions.js --- a/lib/actions/thread-actions.js +++ b/lib/actions/thread-actions.js @@ -19,148 +19,149 @@ success: 'DELETE_THREAD_SUCCESS', failed: 'DELETE_THREAD_FAILED', }); -const deleteThread = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, - currentAccountPassword: ?string, -) => Promise) => async ( - threadID, - currentAccountPassword, -) => { - const response = await callServerEndpoint('delete_thread', { - threadID, - accountPassword: currentAccountPassword, - }); - return { - updatesResult: response.updatesResult, +const deleteThread = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + currentAccountPassword: ?string, + ) => Promise) => + async (threadID, currentAccountPassword) => { + const response = await callServerEndpoint('delete_thread', { + threadID, + accountPassword: currentAccountPassword, + }); + return { + updatesResult: response.updatesResult, + }; }; -}; const changeThreadSettingsActionTypes = Object.freeze({ started: 'CHANGE_THREAD_SETTINGS_STARTED', success: 'CHANGE_THREAD_SETTINGS_SUCCESS', failed: 'CHANGE_THREAD_SETTINGS_FAILED', }); -const changeThreadSettings = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: UpdateThreadRequest, -) => Promise) => async request => { - const response = await callServerEndpoint('update_thread', request); - invariant( - Object.keys(request.changes).length > 0, - 'No changes provided to changeThreadSettings!', - ); - return { - threadID: request.threadID, - updatesResult: response.updatesResult, - newMessageInfos: response.newMessageInfos, +const changeThreadSettings = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: UpdateThreadRequest) => Promise) => + async request => { + const response = await callServerEndpoint('update_thread', request); + invariant( + Object.keys(request.changes).length > 0, + 'No changes provided to changeThreadSettings!', + ); + return { + threadID: request.threadID, + updatesResult: response.updatesResult, + newMessageInfos: response.newMessageInfos, + }; }; -}; const removeUsersFromThreadActionTypes = Object.freeze({ started: 'REMOVE_USERS_FROM_THREAD_STARTED', success: 'REMOVE_USERS_FROM_THREAD_SUCCESS', failed: 'REMOVE_USERS_FROM_THREAD_FAILED', }); -const removeUsersFromThread = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, - memberIDs: $ReadOnlyArray, -) => Promise) => async (threadID, memberIDs) => { - const response = await callServerEndpoint('remove_members', { - threadID, - memberIDs, - }); - return { - threadID, - updatesResult: response.updatesResult, - newMessageInfos: response.newMessageInfos, +const removeUsersFromThread = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + memberIDs: $ReadOnlyArray, + ) => Promise) => + async (threadID, memberIDs) => { + const response = await callServerEndpoint('remove_members', { + threadID, + memberIDs, + }); + return { + threadID, + updatesResult: response.updatesResult, + newMessageInfos: response.newMessageInfos, + }; }; -}; const changeThreadMemberRolesActionTypes = Object.freeze({ started: 'CHANGE_THREAD_MEMBER_ROLES_STARTED', success: 'CHANGE_THREAD_MEMBER_ROLES_SUCCESS', failed: 'CHANGE_THREAD_MEMBER_ROLES_FAILED', }); -const changeThreadMemberRoles = ( - callServerEndpoint: CallServerEndpoint, -): (( - threadID: string, - memberIDs: $ReadOnlyArray, - newRole: string, -) => Promise) => async ( - threadID, - memberIDs, - newRole, -) => { - const response = await callServerEndpoint('update_role', { - threadID, - memberIDs, - role: newRole, - }); - return { - threadID, - updatesResult: response.updatesResult, - newMessageInfos: response.newMessageInfos, +const changeThreadMemberRoles = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + memberIDs: $ReadOnlyArray, + newRole: string, + ) => Promise) => + async (threadID, memberIDs, newRole) => { + const response = await callServerEndpoint('update_role', { + threadID, + memberIDs, + role: newRole, + }); + return { + threadID, + updatesResult: response.updatesResult, + newMessageInfos: response.newMessageInfos, + }; }; -}; const newThreadActionTypes = Object.freeze({ started: 'NEW_THREAD_STARTED', success: 'NEW_THREAD_SUCCESS', failed: 'NEW_THREAD_FAILED', }); -const newThread = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: ClientNewThreadRequest, -) => Promise) => async request => { - const response = await callServerEndpoint('create_thread', request); - return { - newThreadID: response.newThreadID, - updatesResult: response.updatesResult, - newMessageInfos: response.newMessageInfos, - userInfos: response.userInfos, +const newThread = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: ClientNewThreadRequest) => Promise) => + async request => { + const response = await callServerEndpoint('create_thread', request); + return { + newThreadID: response.newThreadID, + updatesResult: response.updatesResult, + newMessageInfos: response.newMessageInfos, + userInfos: response.userInfos, + }; }; -}; const joinThreadActionTypes = Object.freeze({ started: 'JOIN_THREAD_STARTED', success: 'JOIN_THREAD_SUCCESS', failed: 'JOIN_THREAD_FAILED', }); -const joinThread = ( - callServerEndpoint: CallServerEndpoint, -): (( - request: ClientThreadJoinRequest, -) => Promise) => async request => { - const response = await callServerEndpoint('join_thread', request); - const userInfos = values(response.userInfos); - return { - updatesResult: response.updatesResult, - rawMessageInfos: response.rawMessageInfos, - truncationStatuses: response.truncationStatuses, - userInfos, +const joinThread = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: ClientThreadJoinRequest) => Promise) => + async request => { + const response = await callServerEndpoint('join_thread', request); + const userInfos = values(response.userInfos); + return { + updatesResult: response.updatesResult, + rawMessageInfos: response.rawMessageInfos, + truncationStatuses: response.truncationStatuses, + userInfos, + }; }; -}; const leaveThreadActionTypes = Object.freeze({ started: 'LEAVE_THREAD_STARTED', success: 'LEAVE_THREAD_SUCCESS', failed: 'LEAVE_THREAD_FAILED', }); -const leaveThread = ( - callServerEndpoint: CallServerEndpoint, -): ((threadID: string) => Promise) => async threadID => { - const response = await callServerEndpoint('leave_thread', { threadID }); - return { - updatesResult: response.updatesResult, +const leaveThread = + ( + callServerEndpoint: CallServerEndpoint, + ): ((threadID: string) => Promise) => + async threadID => { + const response = await callServerEndpoint('leave_thread', { threadID }); + return { + updatesResult: response.updatesResult, + }; }; -}; export { deleteThreadActionTypes, diff --git a/lib/actions/upload-actions.js b/lib/actions/upload-actions.js --- a/lib/actions/upload-actions.js +++ b/lib/actions/upload-actions.js @@ -15,62 +15,60 @@ }>; export type MultimediaUploadExtras = Shape<{ ...Dimensions, loop: boolean }>; -const uploadMultimedia = ( - callServerEndpoint: CallServerEndpoint, -): (( - multimedia: Object, - extras: MultimediaUploadExtras, - callbacks?: MultimediaUploadCallbacks, -) => Promise) => async ( - multimedia, - extras, - callbacks, -) => { - const onProgress = callbacks && callbacks.onProgress; - const abortHandler = callbacks && callbacks.abortHandler; - const uploadBlob = callbacks && callbacks.uploadBlob; +const uploadMultimedia = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + multimedia: Object, + extras: MultimediaUploadExtras, + callbacks?: MultimediaUploadCallbacks, + ) => Promise) => + async (multimedia, extras, callbacks) => { + const onProgress = callbacks && callbacks.onProgress; + const abortHandler = callbacks && callbacks.abortHandler; + const uploadBlob = callbacks && callbacks.uploadBlob; - const stringExtras = {}; - if (extras.height !== null && extras.height !== undefined) { - stringExtras.height = extras.height.toString(); - } - if (extras.width !== null && extras.width !== undefined) { - stringExtras.width = extras.width.toString(); - } - if (extras.loop) { - stringExtras.loop = '1'; - } + const stringExtras = {}; + if (extras.height !== null && extras.height !== undefined) { + stringExtras.height = extras.height.toString(); + } + if (extras.width !== null && extras.width !== undefined) { + stringExtras.width = extras.width.toString(); + } + if (extras.loop) { + stringExtras.loop = '1'; + } - const response = await callServerEndpoint( - 'upload_multimedia', - { - multimedia: [multimedia], - ...stringExtras, - }, - { - onProgress, - abortHandler, - blobUpload: uploadBlob ? uploadBlob : true, - }, - ); - const [uploadResult] = response.results; - return { - id: uploadResult.id, - uri: uploadResult.uri, - dimensions: uploadResult.dimensions, - mediaType: uploadResult.mediaType, - loop: uploadResult.loop, + const response = await callServerEndpoint( + 'upload_multimedia', + { + multimedia: [multimedia], + ...stringExtras, + }, + { + onProgress, + abortHandler, + blobUpload: uploadBlob ? uploadBlob : true, + }, + ); + const [uploadResult] = response.results; + return { + id: uploadResult.id, + uri: uploadResult.uri, + dimensions: uploadResult.dimensions, + mediaType: uploadResult.mediaType, + loop: uploadResult.loop, + }; }; -}; const updateMultimediaMessageMediaActionType = 'UPDATE_MULTIMEDIA_MESSAGE_MEDIA'; -const deleteUpload = ( - callServerEndpoint: CallServerEndpoint, -): ((id: string) => Promise) => async id => { - await callServerEndpoint('delete_upload', { id }); -}; +const deleteUpload = + (callServerEndpoint: CallServerEndpoint): ((id: string) => Promise) => + async id => { + await callServerEndpoint('delete_upload', { id }); + }; export { uploadMultimedia, diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -30,39 +30,41 @@ success: 'LOG_OUT_SUCCESS', failed: 'LOG_OUT_FAILED', }); -const logOut = ( - callServerEndpoint: CallServerEndpoint, -): (( - preRequestUserState: PreRequestUserState, -) => Promise) => async preRequestUserState => { - let response = null; - try { - response = await Promise.race([ - callServerEndpoint('log_out', {}), - (async () => { - await sleep(500); - throw new Error('log_out took more than 500ms'); - })(), - ]); - } catch {} - const currentUserInfo = response ? response.currentUserInfo : null; - return { currentUserInfo, preRequestUserState }; -}; +const logOut = + ( + callServerEndpoint: CallServerEndpoint, + ): ((preRequestUserState: PreRequestUserState) => Promise) => + async preRequestUserState => { + let response = null; + try { + response = await Promise.race([ + callServerEndpoint('log_out', {}), + (async () => { + await sleep(500); + throw new Error('log_out took more than 500ms'); + })(), + ]); + } catch {} + const currentUserInfo = response ? response.currentUserInfo : null; + return { currentUserInfo, preRequestUserState }; + }; const deleteAccountActionTypes = Object.freeze({ started: 'DELETE_ACCOUNT_STARTED', success: 'DELETE_ACCOUNT_SUCCESS', failed: 'DELETE_ACCOUNT_FAILED', }); -const deleteAccount = ( - callServerEndpoint: CallServerEndpoint, -): (( - password: ?string, - preRequestUserState: PreRequestUserState, -) => Promise) => async (password, preRequestUserState) => { - const response = await callServerEndpoint('delete_account', { password }); - return { currentUserInfo: response.currentUserInfo, preRequestUserState }; -}; +const deleteAccount = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + password: ?string, + preRequestUserState: PreRequestUserState, + ) => Promise) => + async (password, preRequestUserState) => { + const response = await callServerEndpoint('delete_account', { password }); + return { currentUserInfo: response.currentUserInfo, preRequestUserState }; + }; const registerActionTypes = Object.freeze({ started: 'REGISTER_STARTED', @@ -70,27 +72,27 @@ failed: 'REGISTER_FAILED', }); const registerCallServerEndpointOptions = { timeout: 60000 }; -const register = ( - callServerEndpoint: CallServerEndpoint, -): (( - registerInfo: RegisterInfo, -) => Promise) => async registerInfo => { - const response = await callServerEndpoint( - 'create_account', - { - ...registerInfo, - platformDetails: getConfig().platformDetails, - }, - registerCallServerEndpointOptions, - ); - return { - currentUserInfo: response.currentUserInfo, - rawMessageInfos: response.rawMessageInfos, - threadInfos: response.cookieChange.threadInfos, - userInfos: response.cookieChange.userInfos, - calendarQuery: registerInfo.calendarQuery, +const register = + ( + callServerEndpoint: CallServerEndpoint, + ): ((registerInfo: RegisterInfo) => Promise) => + async registerInfo => { + const response = await callServerEndpoint( + 'create_account', + { + ...registerInfo, + platformDetails: getConfig().platformDetails, + }, + registerCallServerEndpointOptions, + ); + return { + currentUserInfo: response.currentUserInfo, + rawMessageInfos: response.rawMessageInfos, + threadInfos: response.cookieChange.threadInfos, + userInfos: response.cookieChange.userInfos, + calendarQuery: registerInfo.calendarQuery, + }; }; -}; function mergeUserInfos(...userInfoArrays: UserInfo[][]): UserInfo[] { const merged = {}; @@ -112,95 +114,99 @@ failed: 'LOG_IN_FAILED', }); const logInCallServerEndpointOptions = { timeout: 60000 }; -const logIn = ( - callServerEndpoint: CallServerEndpoint, -): ((logInInfo: LogInInfo) => Promise) => async logInInfo => { - const watchedIDs = threadWatcher.getWatchedIDs(); - const { logInActionSource, ...restLogInInfo } = logInInfo; - const response = await callServerEndpoint( - 'log_in', - { - ...restLogInInfo, - source: logInActionSource, - watchedIDs, - platformDetails: getConfig().platformDetails, - }, - logInCallServerEndpointOptions, - ); - const userInfos = mergeUserInfos( - response.userInfos, - response.cookieChange.userInfos, - ); - return { - threadInfos: response.cookieChange.threadInfos, - currentUserInfo: response.currentUserInfo, - calendarResult: { - calendarQuery: logInInfo.calendarQuery, - rawEntryInfos: response.rawEntryInfos, - }, - messagesResult: { - messageInfos: response.rawMessageInfos, - truncationStatus: response.truncationStatuses, - watchedIDsAtRequestTime: watchedIDs, - currentAsOf: response.serverTime, - }, - userInfos, - updatesCurrentAsOf: response.serverTime, - logInActionSource: logInInfo.logInActionSource, - notAcknowledgedPolicies: response.notAcknowledgedPolicies, +const logIn = + ( + callServerEndpoint: CallServerEndpoint, + ): ((logInInfo: LogInInfo) => Promise) => + async logInInfo => { + const watchedIDs = threadWatcher.getWatchedIDs(); + const { logInActionSource, ...restLogInInfo } = logInInfo; + const response = await callServerEndpoint( + 'log_in', + { + ...restLogInInfo, + source: logInActionSource, + watchedIDs, + platformDetails: getConfig().platformDetails, + }, + logInCallServerEndpointOptions, + ); + const userInfos = mergeUserInfos( + response.userInfos, + response.cookieChange.userInfos, + ); + return { + threadInfos: response.cookieChange.threadInfos, + currentUserInfo: response.currentUserInfo, + calendarResult: { + calendarQuery: logInInfo.calendarQuery, + rawEntryInfos: response.rawEntryInfos, + }, + messagesResult: { + messageInfos: response.rawMessageInfos, + truncationStatus: response.truncationStatuses, + watchedIDsAtRequestTime: watchedIDs, + currentAsOf: response.serverTime, + }, + userInfos, + updatesCurrentAsOf: response.serverTime, + logInActionSource: logInInfo.logInActionSource, + notAcknowledgedPolicies: response.notAcknowledgedPolicies, + }; }; -}; const changeUserPasswordActionTypes = Object.freeze({ started: 'CHANGE_USER_PASSWORD_STARTED', success: 'CHANGE_USER_PASSWORD_SUCCESS', failed: 'CHANGE_USER_PASSWORD_FAILED', }); -const changeUserPassword = ( - callServerEndpoint: CallServerEndpoint, -): (( - passwordUpdate: PasswordUpdate, -) => Promise) => async passwordUpdate => { - await callServerEndpoint('update_account', passwordUpdate); -}; +const changeUserPassword = + ( + callServerEndpoint: CallServerEndpoint, + ): ((passwordUpdate: PasswordUpdate) => Promise) => + async passwordUpdate => { + await callServerEndpoint('update_account', passwordUpdate); + }; const searchUsersActionTypes = Object.freeze({ started: 'SEARCH_USERS_STARTED', success: 'SEARCH_USERS_SUCCESS', failed: 'SEARCH_USERS_FAILED', }); -const searchUsers = ( - callServerEndpoint: CallServerEndpoint, -): (( - usernamePrefix: string, -) => Promise) => async usernamePrefix => { - const response = await callServerEndpoint('search_users', { - prefix: usernamePrefix, - }); - return { - userInfos: response.userInfos, +const searchUsers = + ( + callServerEndpoint: CallServerEndpoint, + ): ((usernamePrefix: string) => Promise) => + async usernamePrefix => { + const response = await callServerEndpoint('search_users', { + prefix: usernamePrefix, + }); + return { + userInfos: response.userInfos, + }; }; -}; const updateSubscriptionActionTypes = Object.freeze({ started: 'UPDATE_SUBSCRIPTION_STARTED', success: 'UPDATE_SUBSCRIPTION_SUCCESS', failed: 'UPDATE_SUBSCRIPTION_FAILED', }); -const updateSubscription = ( - callServerEndpoint: CallServerEndpoint, -): (( - subscriptionUpdate: SubscriptionUpdateRequest, -) => Promise) => async subscriptionUpdate => { - const response = await callServerEndpoint( - 'update_user_subscription', - subscriptionUpdate, - ); - return { - threadID: subscriptionUpdate.threadID, - subscription: response.threadSubscription, +const updateSubscription = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + subscriptionUpdate: SubscriptionUpdateRequest, + ) => Promise) => + async subscriptionUpdate => { + const response = await callServerEndpoint( + 'update_user_subscription', + subscriptionUpdate, + ); + return { + threadID: subscriptionUpdate.threadID, + subscription: response.threadSubscription, + }; }; -}; const setUserSettingsActionTypes = Object.freeze({ started: 'SET_USER_SETTINGS_STARTED', @@ -208,34 +214,34 @@ failed: 'SET_USER_SETTINGS_FAILED', }); -const setUserSettings = ( - callServerEndpoint: CallServerEndpoint, -): (( - userSettingsRequest: UpdateUserSettingsRequest, -) => Promise) => async userSettingsRequest => { - await callServerEndpoint('update_user_settings', userSettingsRequest); -}; +const setUserSettings = + ( + callServerEndpoint: CallServerEndpoint, + ): ((userSettingsRequest: UpdateUserSettingsRequest) => Promise) => + async userSettingsRequest => { + await callServerEndpoint('update_user_settings', userSettingsRequest); + }; -const getSessionPublicKeys = ( - callServerEndpoint: CallServerEndpoint, -): (( - data: GetSessionPublicKeysArgs, -) => Promise) => async data => { - return await callServerEndpoint('get_session_public_keys', data); -}; +const getSessionPublicKeys = + ( + callServerEndpoint: CallServerEndpoint, + ): ((data: GetSessionPublicKeysArgs) => Promise) => + async data => { + return await callServerEndpoint('get_session_public_keys', data); + }; const policyAcknowledgmentActionTypes = Object.freeze({ started: 'POLICY_ACKNOWLEDGMENT_STARTED', success: 'POLICY_ACKNOWLEDGMENT_SUCCESS', failed: 'POLICY_ACKNOWLEDGMENT_FAILED', }); -const policyAcknowledgment = ( - callServerEndpoint: CallServerEndpoint, -): (( - policyRequest: PolicyAcknowledgmentRequest, -) => Promise) => async policyRequest => { - await callServerEndpoint('policy_acknowledgment', policyRequest); -}; +const policyAcknowledgment = + ( + callServerEndpoint: CallServerEndpoint, + ): ((policyRequest: PolicyAcknowledgmentRequest) => Promise) => + async policyRequest => { + await callServerEndpoint('policy_acknowledgment', policyRequest); + }; export { changeUserPasswordActionTypes, diff --git a/lib/components/connected-wallet-info.react.js b/lib/components/connected-wallet-info.react.js --- a/lib/components/connected-wallet-info.react.js +++ b/lib/components/connected-wallet-info.react.js @@ -35,9 +35,10 @@ [emojiAvatar.color], ); - const emojiAvatarView = React.useMemo(() =>

{emojiAvatar.emoji}

, [ - emojiAvatar.emoji, - ]); + const emojiAvatarView = React.useMemo( + () =>

{emojiAvatar.emoji}

, + [emojiAvatar.emoji], + ); const { data: ensAvatarURI } = useEnsAvatar({ addressOrName: potentiallyENSName, diff --git a/lib/components/ens-cache-provider.react.js b/lib/components/ens-cache-provider.react.js --- a/lib/components/ens-cache-provider.react.js +++ b/lib/components/ens-cache-provider.react.js @@ -16,9 +16,8 @@ ensCache: undefined, getENSNames: undefined, }; -const ENSCacheContext: React.Context = React.createContext( - defaultContext, -); +const ENSCacheContext: React.Context = + React.createContext(defaultContext); type Props = { +provider: ?EthersProvider, diff --git a/lib/components/modal-provider.react.js b/lib/components/modal-provider.react.js --- a/lib/components/modal-provider.react.js +++ b/lib/components/modal-provider.react.js @@ -17,14 +17,13 @@ +clearModals: () => void, }; -const ModalContext: React.Context = React.createContext( - { +const ModalContext: React.Context = + React.createContext({ modals: [], pushModal: () => '', popModal: () => {}, clearModals: () => {}, - }, -); + }); function ModalProvider(props: Props): React.Node { const { children } = props; diff --git a/lib/hooks/disconnected-bar.js b/lib/hooks/disconnected-bar.js --- a/lib/hooks/disconnected-bar.js +++ b/lib/hooks/disconnected-bar.js @@ -82,10 +82,8 @@ function useDisconnectedBar( changeShowing: boolean => void, ): DisconnectedBarCause { - const { - disconnected, - shouldShowDisconnectedBar, - } = useShouldShowDisconnectedBar(); + const { disconnected, shouldShowDisconnectedBar } = + useShouldShowDisconnectedBar(); const prevShowDisconnectedBar = React.useRef(); React.useEffect(() => { @@ -98,9 +96,8 @@ prevShowDisconnectedBar.current = shouldShowDisconnectedBar; }, [shouldShowDisconnectedBar, changeShowing]); - const [barCause, setBarCause] = React.useState( - 'connecting', - ); + const [barCause, setBarCause] = + React.useState('connecting'); React.useEffect(() => { if (shouldShowDisconnectedBar && disconnected) { setBarCause('disconnected'); diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js --- a/lib/reducers/master-reducer.js +++ b/lib/reducers/master-reducer.js @@ -34,11 +34,8 @@ state: T, action: BaseAction, ): { state: T, storeOperations: StoreOperations } { - const { - threadStore, - newThreadInconsistencies, - threadStoreOperations, - } = reduceThreadInfos(state.threadStore, action); + const { threadStore, newThreadInconsistencies, threadStoreOperations } = + reduceThreadInfos(state.threadStore, action); const { threadInfos } = threadStore; const [entryStore, newEntryInconsistencies] = reduceEntryInfos( @@ -53,10 +50,8 @@ ]; // Only allow checkpoints to increase if we are connected // or if the action is a STATE_SYNC - const { - messageStoreOperations, - messageStore: reducedMessageStore, - } = reduceMessageStore(state.messageStore, action, threadInfos); + const { messageStoreOperations, messageStore: reducedMessageStore } = + reduceMessageStore(state.messageStore, action, threadInfos); let messageStore = reducedMessageStore; let updatesCurrentAsOf = reduceUpdatesCurrentAsOf( state.updatesCurrentAsOf, diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js --- a/lib/reducers/message-reducer.js +++ b/lib/reducers/message-reducer.js @@ -163,9 +163,8 @@ ...messageStoreReplaceOperations, ]; - const threadsToMessageIDs = mapThreadsToMessageIDsFromOrderedMessageInfos( - orderedMessageInfos, - ); + const threadsToMessageIDs = + mapThreadsToMessageIDsFromOrderedMessageInfos(orderedMessageInfos); const threads = _mapValuesWithKeys( (messageIDs: string[], threadID: string) => ({ ...newThread(), @@ -201,9 +200,8 @@ messageStore: MessageStore, threadInfos: { +[threadID: string]: RawThreadInfo }, ): ReassignmentResult { - const pendingToRealizedThreadIDs = pendingToRealizedThreadIDsSelector( - threadInfos, - ); + const pendingToRealizedThreadIDs = + pendingToRealizedThreadIDsSelector(threadInfos); const messageStoreOperations: MessageStoreOperation[] = []; const messages = {}; @@ -639,9 +637,8 @@ payload: T, threadInfos: { +[id: string]: RawThreadInfo }, ): T { - const pendingToRealizedThreadIDs = pendingToRealizedThreadIDsSelector( - threadInfos, - ); + const pendingToRealizedThreadIDs = + pendingToRealizedThreadIDsSelector(threadInfos); const realizedThreadID = pendingToRealizedThreadIDs.get(payload.threadID); return realizedThreadID ? { ...payload, threadID: realizedThreadID } @@ -698,15 +695,13 @@ action.type === siweAuthActionTypes.success ) { const messagesResult = action.payload.messagesResult; - const { - messageStoreOperations, - messageStore: freshStore, - } = freshMessageStore( - messagesResult.messageInfos, - messagesResult.truncationStatus, - messagesResult.currentAsOf, - newThreadInfos, - ); + const { messageStoreOperations, messageStore: freshStore } = + freshMessageStore( + messagesResult.messageInfos, + messagesResult.truncationStatus, + messagesResult.currentAsOf, + newThreadInfos, + ); const processedMessageStore = processMessageStoreOperations( messageStore, @@ -747,15 +742,13 @@ action.payload.updatesResult.newUpdates, ); - const { - messageStoreOperations, - messageStore: newMessageStore, - } = mergeNewMessages( - messageStore, - messagesResult.rawMessageInfos, - messagesResult.truncationStatuses, - newThreadInfos, - ); + const { messageStoreOperations, messageStore: newMessageStore } = + mergeNewMessages( + messageStore, + messagesResult.rawMessageInfos, + messagesResult.truncationStatuses, + newThreadInfos, + ); return { messageStoreOperations, messageStore: { @@ -802,10 +795,8 @@ action.type === leaveThreadActionTypes.success || action.type === setNewSessionActionType ) { - const { - messageStoreOperations, - messageStore: filteredMessageStore, - } = updateMessageStoreWithLatestThreadInfos(messageStore, newThreadInfos); + const { messageStoreOperations, messageStore: filteredMessageStore } = + updateMessageStoreWithLatestThreadInfos(messageStore, newThreadInfos); const processedMessageStore = processMessageStoreOperations( messageStore, @@ -1103,15 +1094,13 @@ truncationStatuses[messageInfo.threadID] = messageTruncationStatus.UNCHANGED; } - const { - messageStoreOperations, - messageStore: newMessageStore, - } = mergeNewMessages( - messageStore, - action.payload.rawMessageInfos, - truncationStatuses, - newThreadInfos, - ); + const { messageStoreOperations, messageStore: newMessageStore } = + mergeNewMessages( + messageStore, + action.payload.rawMessageInfos, + truncationStatuses, + newThreadInfos, + ); return { messageStoreOperations, messageStore: { @@ -1329,10 +1318,8 @@ }, }; } else if (action.type === setClientDBStoreActionType) { - const { - messageStoreOperations, - messageStore: updatedMessageStore, - } = updateMessageStoreWithLatestThreadInfos(messageStore, newThreadInfos); + const { messageStoreOperations, messageStore: updatedMessageStore } = + updateMessageStoreWithLatestThreadInfos(messageStore, newThreadInfos); let threads = { ...updatedMessageStore.threads }; let local = { ...updatedMessageStore.local }; @@ -1346,9 +1333,8 @@ }); } const threadsNeedMsgIDsResorting = new Set(); - const actionPayloadMessages = translateClientDBMessageInfosToRawMessageInfos( - action.payload.messages, - ); + const actionPayloadMessages = + translateClientDBMessageInfosToRawMessageInfos(action.payload.messages); // When starting the app on native, we filter out any local-only multimedia // messages because the relevant context is no longer available @@ -1447,12 +1433,11 @@ messageIDs.add(messageInfo.id); } - mergedTruncationStatuses[ - updateInfo.threadInfo.id - ] = combineTruncationStatuses( - updateInfo.truncationStatus, - mergedTruncationStatuses[updateInfo.threadInfo.id], - ); + mergedTruncationStatuses[updateInfo.threadInfo.id] = + combineTruncationStatuses( + updateInfo.truncationStatus, + mergedTruncationStatuses[updateInfo.threadInfo.id], + ); } return { rawMessageInfos: mergedMessageInfos, diff --git a/lib/reducers/message-reducer.test.js b/lib/reducers/message-reducer.test.js --- a/lib/reducers/message-reducer.test.js +++ b/lib/reducers/message-reducer.test.js @@ -18,15 +18,13 @@ media: [ { id: 'localUpload2', - uri: - 'assets-library://asset/asset.HEIC?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=HEIC', + uri: 'assets-library://asset/asset.HEIC?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=HEIC', type: 'photo', dimensions: { height: 3024, width: 4032 }, localMediaSelection: { step: 'photo_library', dimensions: { height: 3024, width: 4032 }, - uri: - 'assets-library://asset/asset.HEIC?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=HEIC', + uri: 'assets-library://asset/asset.HEIC?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=HEIC', filename: 'IMG_0006.HEIC', mediaNativeID: 'CC95F08C-88C3-4012-9D6D-64A413D254B3/L0/001', selectTime: 1639522317349, @@ -118,13 +116,12 @@ }, }, }; - const { - messageStore: storeWithoutLocalMediaSelectionUpdate, - } = reduceMessageStore( - messageStoreBeforeMediaUpdate, - actionWithoutLocalMediaSelectionUpdate, - {}, - ); + const { messageStore: storeWithoutLocalMediaSelectionUpdate } = + reduceMessageStore( + messageStoreBeforeMediaUpdate, + actionWithoutLocalMediaSelectionUpdate, + {}, + ); const prevMsg = messageStoreBeforeMediaUpdate.messages[ actionWithoutLocalMediaSelectionUpdate.payload.messageID @@ -171,13 +168,12 @@ }, }, }; - const { - messageStore: updatedMessageStoreWithReplacement, - } = reduceMessageStore( - messageStoreBeforeMediaUpdate, - updateMultiMediaMessageMediaActionWithReplacement, - {}, - ); + const { messageStore: updatedMessageStoreWithReplacement } = + reduceMessageStore( + messageStoreBeforeMediaUpdate, + updateMultiMediaMessageMediaActionWithReplacement, + {}, + ); const updatedMsg = updatedMessageStoreWithReplacement.messages[ updateMultiMediaMessageMediaActionWithReplacement.payload.messageID @@ -233,8 +229,7 @@ media_infos: [ { id: 'localUpload0', - uri: - 'assets-library://asset/asset.heic?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=heic', + uri: 'assets-library://asset/asset.heic?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=heic', type: 'photo', extras: '{"dimensions":{"height":3024,"width":4032},"loop":false,"local_media_selection":{"step":"photo_library","dimensions":{"height":3024,"width":4032},"uri":"assets-library://asset/asset.heic?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=heic","filename":"IMG_0006.HEIC","mediaNativeID":"CC95F08C-88C3-4012-9D6D-64A413D254B3/L0/001","selectTime":1658172650370,"sendTime":1658172650370,"retries":0}}', @@ -253,16 +248,14 @@ media_infos: [ { id: 'localUpload2', - uri: - 'assets-library://asset/asset.heic?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=heic', + uri: 'assets-library://asset/asset.heic?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=heic', type: 'photo', extras: '{"dimensions":{"height":3024,"width":4032},"loop":false,"local_media_selection":{"step":"photo_library","dimensions":{"height":3024,"width":4032},"uri":"assets-library://asset/asset.heic?id=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=heic","filename":"IMG_0006.HEIC","mediaNativeID":"CC95F08C-88C3-4012-9D6D-64A413D254B3/L0/001","selectTime":1658172656826,"sendTime":1658172656826,"retries":0}}', }, { id: 'localUpload4', - uri: - 'assets-library://asset/asset.jpg?id=ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED&ext=jpg', + uri: 'assets-library://asset/asset.jpg?id=ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED&ext=jpg', type: 'photo', extras: '{"dimensions":{"height":2002,"width":3000},"loop":false,"local_media_selection":{"step":"photo_library","dimensions":{"height":2002,"width":3000},"uri":"assets-library://asset/asset.jpg?id=ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED&ext=jpg","filename":"IMG_0005.JPG","mediaNativeID":"ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED/L0/001","selectTime":1658172656826,"sendTime":1658172656826,"retries":0}}', diff --git a/lib/selectors/account-selectors.js b/lib/selectors/account-selectors.js --- a/lib/selectors/account-selectors.js +++ b/lib/selectors/account-selectors.js @@ -33,17 +33,20 @@ }, ); -const preRequestUserStateSelector: ( - state: AppState, -) => PreRequestUserState = createSelector( - (state: AppState) => state.currentUserInfo, - (state: AppState) => state.cookie, - (state: AppState) => state.sessionID, - (currentUserInfo: ?CurrentUserInfo, cookie: ?string, sessionID: ?string) => ({ - currentUserInfo, - cookie, - sessionID, - }), -); +const preRequestUserStateSelector: (state: AppState) => PreRequestUserState = + createSelector( + (state: AppState) => state.currentUserInfo, + (state: AppState) => state.cookie, + (state: AppState) => state.sessionID, + ( + currentUserInfo: ?CurrentUserInfo, + cookie: ?string, + sessionID: ?string, + ) => ({ + currentUserInfo, + cookie, + sessionID, + }), + ); export { logInExtraInfoSelector, preRequestUserStateSelector }; diff --git a/lib/selectors/calendar-filter-selectors.js b/lib/selectors/calendar-filter-selectors.js --- a/lib/selectors/calendar-filter-selectors.js +++ b/lib/selectors/calendar-filter-selectors.js @@ -84,13 +84,12 @@ return false; } -const includeDeletedSelector: ( - state: BaseAppState<*>, -) => boolean = createSelector( - (state: BaseAppState<*>) => state.calendarFilters, - (calendarFilters: $ReadOnlyArray) => - !filterExists(calendarFilters, calendarThreadFilterTypes.NOT_DELETED), -); +const includeDeletedSelector: (state: BaseAppState<*>) => boolean = + createSelector( + (state: BaseAppState<*>) => state.calendarFilters, + (calendarFilters: $ReadOnlyArray) => + !filterExists(calendarFilters, calendarThreadFilterTypes.NOT_DELETED), + ); export { filteredThreadIDs, diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js --- a/lib/selectors/chat-selectors.js +++ b/lib/selectors/chat-selectors.js @@ -76,9 +76,9 @@ +pendingPersonalThreadUserInfo?: UserInfo, }; -const messageInfoSelector: ( - state: BaseAppState<*>, -) => { +[id: string]: ?MessageInfo } = createObjectSelector( +const messageInfoSelector: (state: BaseAppState<*>) => { + +[id: string]: ?MessageInfo, +} = createObjectSelector( (state: BaseAppState<*>) => state.messageStore.messages, (state: BaseAppState<*>) => state.currentUserInfo && state.currentUserInfo.id, (state: BaseAppState<*>) => state.userStore.userInfos, @@ -201,27 +201,26 @@ }; } -const chatListData: ( - state: BaseAppState<*>, -) => $ReadOnlyArray = createSelector( - threadInfoSelector, - (state: BaseAppState<*>) => state.messageStore, - messageInfoSelector, - sidebarInfoSelector, - ( - threadInfos: { +[id: string]: ThreadInfo }, - messageStore: MessageStore, - messageInfos: { +[id: string]: ?MessageInfo }, - sidebarInfos: { +[id: string]: $ReadOnlyArray }, - ): $ReadOnlyArray => - getChatThreadItems( - threadInfos, - messageStore, - messageInfos, - sidebarInfos, - threadIsTopLevel, - ), -); +const chatListData: (state: BaseAppState<*>) => $ReadOnlyArray = + createSelector( + threadInfoSelector, + (state: BaseAppState<*>) => state.messageStore, + messageInfoSelector, + sidebarInfoSelector, + ( + threadInfos: { +[id: string]: ThreadInfo }, + messageStore: MessageStore, + messageInfos: { +[id: string]: ?MessageInfo }, + sidebarInfos: { +[id: string]: $ReadOnlyArray }, + ): $ReadOnlyArray => + getChatThreadItems( + threadInfos, + messageStore, + messageInfos, + sidebarInfos, + threadIsTopLevel, + ), + ); function useFlattenedChatListData(): $ReadOnlyArray { return useFilteredChatListData(threadInChatList); @@ -409,43 +408,41 @@ ? threadInfoFromSourceMessageID[messageInfo.id] : undefined; - const renderedReactions: $ReadOnlyMap< - string, - MessageReactionInfo, - > = (() => { - const result = new Map(); - - let messageReactsMap; - if (originalMessageInfo.id) { - messageReactsMap = targetMessageReactionsMap.get( - originalMessageInfo.id, - ); - } - - if (!messageReactsMap) { - return result; - } + const renderedReactions: $ReadOnlyMap = + (() => { + const result = new Map(); - for (const reaction of messageReactsMap.keys()) { - const reactionUsersInfoMap = messageReactsMap.get(reaction); - invariant(reactionUsersInfoMap, 'reactionUsersInfoMap should be set'); + let messageReactsMap; + if (originalMessageInfo.id) { + messageReactsMap = targetMessageReactionsMap.get( + originalMessageInfo.id, + ); + } - if (reactionUsersInfoMap.size === 0) { - continue; + if (!messageReactsMap) { + return result; } - const reactionUserInfos = [...reactionUsersInfoMap.values()]; + for (const reaction of messageReactsMap.keys()) { + const reactionUsersInfoMap = messageReactsMap.get(reaction); + invariant(reactionUsersInfoMap, 'reactionUsersInfoMap should be set'); - const messageReactionInfo = { - users: reactionUserInfos, - viewerReacted: reactionUsersInfoMap.has(viewerID), - }; + if (reactionUsersInfoMap.size === 0) { + continue; + } - result.set(reaction, messageReactionInfo); - } + const reactionUserInfos = [...reactionUsersInfoMap.values()]; - return result; - })(); + const messageReactionInfo = { + users: reactionUserInfos, + viewerReacted: reactionUsersInfoMap.has(viewerID), + }; + + result.set(reaction, messageReactionInfo); + } + + return result; + })(); if (isComposableMessageType(originalMessageInfo.type)) { // We use these invariants instead of just checking the messageInfo.type @@ -544,9 +541,8 @@ const messageListData: ( threadID: ?string, additionalMessages: $ReadOnlyArray, -) => (state: BaseAppState<*>) => MessageListData = memoize2( - baseMessageListData, -); +) => (state: BaseAppState<*>) => MessageListData = + memoize2(baseMessageListData); type UseMessageListDataArgs = { +searching: boolean, diff --git a/lib/selectors/loading-selectors.js b/lib/selectors/loading-selectors.js --- a/lib/selectors/loading-selectors.js +++ b/lib/selectors/loading-selectors.js @@ -77,18 +77,19 @@ return errorExists ? 'error' : 'inactive'; } -const globalLoadingStatusSelector: ( - state: BaseAppState<*>, -) => LoadingStatus = createSelector( - (state: BaseAppState<*>) => state.loadingStatuses, - (loadingStatusInfos: { - [key: string]: { [idx: number]: LoadingStatus }, - }): LoadingStatus => { - const loadingStatusInfoValues = values(loadingStatusInfos); - const loadingStatuses = loadingStatusInfoValues.map(loadingStatusFromInfo); - return combineLoadingStatuses(...loadingStatuses); - }, -); +const globalLoadingStatusSelector: (state: BaseAppState<*>) => LoadingStatus = + createSelector( + (state: BaseAppState<*>) => state.loadingStatuses, + (loadingStatusInfos: { + [key: string]: { [idx: number]: LoadingStatus }, + }): LoadingStatus => { + const loadingStatusInfoValues = values(loadingStatusInfos); + const loadingStatuses = loadingStatusInfoValues.map( + loadingStatusFromInfo, + ); + return combineLoadingStatuses(...loadingStatuses); + }, + ); export { createLoadingStatusSelector, diff --git a/lib/selectors/nav-selectors.js b/lib/selectors/nav-selectors.js --- a/lib/selectors/nav-selectors.js +++ b/lib/selectors/nav-selectors.js @@ -146,9 +146,10 @@ function useGlobalThreadSearchIndex(): SearchIndex { const threadInfos = useSelector(state => state.threadStore.threadInfos); - const threadInfosArray = React.useMemo(() => values(threadInfos), [ - threadInfos, - ]); + const threadInfosArray = React.useMemo( + () => values(threadInfos), + [threadInfos], + ); return useThreadSearchIndex(threadInfosArray); } diff --git a/lib/selectors/relationship-selectors.js b/lib/selectors/relationship-selectors.js --- a/lib/selectors/relationship-selectors.js +++ b/lib/selectors/relationship-selectors.js @@ -10,41 +10,40 @@ } from '../types/relationship-types.js'; import type { UserInfos } from '../types/user-types.js'; -const userRelationshipsSelector: ( - state: BaseAppState<*>, -) => UserRelationships = createSelector( - (state: BaseAppState<*>) => state.userStore.userInfos, - (userInfos: UserInfos) => { - const unorderedFriendRequests = []; - const unorderedFriends = []; - const blocked = []; - for (const userID in userInfos) { - const userInfo = userInfos[userID]; - const { id, username, relationshipStatus } = userInfo; - if (!username) { - continue; +const userRelationshipsSelector: (state: BaseAppState<*>) => UserRelationships = + createSelector( + (state: BaseAppState<*>) => state.userStore.userInfos, + (userInfos: UserInfos) => { + const unorderedFriendRequests = []; + const unorderedFriends = []; + const blocked = []; + for (const userID in userInfos) { + const userInfo = userInfos[userID]; + const { id, username, relationshipStatus } = userInfo; + if (!username) { + continue; + } + if ( + relationshipStatus === userRelationshipStatus.REQUEST_RECEIVED || + relationshipStatus === userRelationshipStatus.REQUEST_SENT + ) { + unorderedFriendRequests.push({ id, username, relationshipStatus }); + } else if (relationshipStatus === userRelationshipStatus.FRIEND) { + unorderedFriends.push({ id, username, relationshipStatus }); + } else if ( + relationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER || + relationshipStatus === userRelationshipStatus.BOTH_BLOCKED + ) { + blocked.push({ id, username, relationshipStatus }); + } } - if ( - relationshipStatus === userRelationshipStatus.REQUEST_RECEIVED || - relationshipStatus === userRelationshipStatus.REQUEST_SENT - ) { - unorderedFriendRequests.push({ id, username, relationshipStatus }); - } else if (relationshipStatus === userRelationshipStatus.FRIEND) { - unorderedFriends.push({ id, username, relationshipStatus }); - } else if ( - relationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER || - relationshipStatus === userRelationshipStatus.BOTH_BLOCKED - ) { - blocked.push({ id, username, relationshipStatus }); - } - } - const friendRequests = _orderBy('relationshipStatus')('desc')( - unorderedFriendRequests, - ); - const friends = friendRequests.concat(unorderedFriends); + const friendRequests = _orderBy('relationshipStatus')('desc')( + unorderedFriendRequests, + ); + const friends = friendRequests.concat(unorderedFriends); - return { friends, blocked }; - }, -); + return { friends, blocked }; + }, + ); export { userRelationshipsSelector }; diff --git a/lib/selectors/server-calls.js b/lib/selectors/server-calls.js --- a/lib/selectors/server-calls.js +++ b/lib/selectors/server-calls.js @@ -14,27 +14,26 @@ +connectionStatus: ConnectionStatus, }; -const serverCallStateSelector: ( - state: AppState, -) => ServerCallState = createSelector( - (state: AppState) => state.cookie, - (state: AppState) => state.urlPrefix, - (state: AppState) => state.sessionID, - (state: AppState) => state.currentUserInfo, - (state: AppState) => state.connection.status, - ( - cookie: ?string, - urlPrefix: string, - sessionID: ?string, - currentUserInfo: ?CurrentUserInfo, - connectionStatus: ConnectionStatus, - ) => ({ - cookie, - urlPrefix, - sessionID, - currentUserInfo, - connectionStatus, - }), -); +const serverCallStateSelector: (state: AppState) => ServerCallState = + createSelector( + (state: AppState) => state.cookie, + (state: AppState) => state.urlPrefix, + (state: AppState) => state.sessionID, + (state: AppState) => state.currentUserInfo, + (state: AppState) => state.connection.status, + ( + cookie: ?string, + urlPrefix: string, + sessionID: ?string, + currentUserInfo: ?CurrentUserInfo, + connectionStatus: ConnectionStatus, + ) => ({ + cookie, + urlPrefix, + sessionID, + currentUserInfo, + connectionStatus, + }), + ); export { serverCallStateSelector }; diff --git a/lib/selectors/socket-selectors.js b/lib/selectors/socket-selectors.js --- a/lib/selectors/socket-selectors.js +++ b/lib/selectors/socket-selectors.js @@ -47,119 +47,120 @@ (state: AppState) => state.currentUserInfo, currentCalendarQuery, ( - threadInfos: { +[id: string]: RawThreadInfo }, - entryInfos: { +[id: string]: RawEntryInfo }, - userInfos: UserInfos, - currentUserInfo: ?CurrentUserInfo, - calendarQuery: (calendarActive: boolean) => CalendarQuery, - ) => ( - calendarActive: boolean, - oneTimeKeyGenerator: ?OneTimeKeyGenerator, - serverRequests: $ReadOnlyArray, - ): $ReadOnlyArray => { - const clientResponses = []; - const serverRequestedPlatformDetails = serverRequests.some( - request => request.type === serverRequestTypes.PLATFORM_DETAILS, - ); - for (const serverRequest of serverRequests) { - if ( - serverRequest.type === serverRequestTypes.PLATFORM && - !serverRequestedPlatformDetails - ) { - clientResponses.push({ - type: serverRequestTypes.PLATFORM, - platform: getConfig().platformDetails.platform, - }); - } else if (serverRequest.type === serverRequestTypes.PLATFORM_DETAILS) { - clientResponses.push({ - type: serverRequestTypes.PLATFORM_DETAILS, - platformDetails: getConfig().platformDetails, - }); - } else if (serverRequest.type === serverRequestTypes.CHECK_STATE) { - const filteredEntryInfos = filterRawEntryInfosByCalendarQuery( - serverEntryInfosObject(values(entryInfos)), - calendarQuery(calendarActive), - ); - const hashResults = {}; - for (const key in serverRequest.hashesToCheck) { - const expectedHashValue = serverRequest.hashesToCheck[key]; - let hashValue; - if (key === 'threadInfos') { - hashValue = hash(threadInfos); - } else if (key === 'entryInfos') { - hashValue = hash(filteredEntryInfos); - } else if (key === 'userInfos') { - hashValue = hash(userInfos); - } else if (key === 'currentUserInfo') { - hashValue = hash(currentUserInfo); - } else if (key.startsWith('threadInfo|')) { - const [, threadID] = key.split('|'); - hashValue = hash(threadInfos[threadID]); - } else if (key.startsWith('entryInfo|')) { - const [, entryID] = key.split('|'); - let rawEntryInfo = filteredEntryInfos[entryID]; - if (rawEntryInfo) { - rawEntryInfo = serverEntryInfo(rawEntryInfo); + threadInfos: { +[id: string]: RawThreadInfo }, + entryInfos: { +[id: string]: RawEntryInfo }, + userInfos: UserInfos, + currentUserInfo: ?CurrentUserInfo, + calendarQuery: (calendarActive: boolean) => CalendarQuery, + ) => + ( + calendarActive: boolean, + oneTimeKeyGenerator: ?OneTimeKeyGenerator, + serverRequests: $ReadOnlyArray, + ): $ReadOnlyArray => { + const clientResponses = []; + const serverRequestedPlatformDetails = serverRequests.some( + request => request.type === serverRequestTypes.PLATFORM_DETAILS, + ); + for (const serverRequest of serverRequests) { + if ( + serverRequest.type === serverRequestTypes.PLATFORM && + !serverRequestedPlatformDetails + ) { + clientResponses.push({ + type: serverRequestTypes.PLATFORM, + platform: getConfig().platformDetails.platform, + }); + } else if (serverRequest.type === serverRequestTypes.PLATFORM_DETAILS) { + clientResponses.push({ + type: serverRequestTypes.PLATFORM_DETAILS, + platformDetails: getConfig().platformDetails, + }); + } else if (serverRequest.type === serverRequestTypes.CHECK_STATE) { + const filteredEntryInfos = filterRawEntryInfosByCalendarQuery( + serverEntryInfosObject(values(entryInfos)), + calendarQuery(calendarActive), + ); + const hashResults = {}; + for (const key in serverRequest.hashesToCheck) { + const expectedHashValue = serverRequest.hashesToCheck[key]; + let hashValue; + if (key === 'threadInfos') { + hashValue = hash(threadInfos); + } else if (key === 'entryInfos') { + hashValue = hash(filteredEntryInfos); + } else if (key === 'userInfos') { + hashValue = hash(userInfos); + } else if (key === 'currentUserInfo') { + hashValue = hash(currentUserInfo); + } else if (key.startsWith('threadInfo|')) { + const [, threadID] = key.split('|'); + hashValue = hash(threadInfos[threadID]); + } else if (key.startsWith('entryInfo|')) { + const [, entryID] = key.split('|'); + let rawEntryInfo = filteredEntryInfos[entryID]; + if (rawEntryInfo) { + rawEntryInfo = serverEntryInfo(rawEntryInfo); + } + hashValue = hash(rawEntryInfo); + } else if (key.startsWith('userInfo|')) { + const [, userID] = key.split('|'); + hashValue = hash(userInfos[userID]); + } else { + continue; } - hashValue = hash(rawEntryInfo); - } else if (key.startsWith('userInfo|')) { - const [, userID] = key.split('|'); - hashValue = hash(userInfos[userID]); - } else { - continue; + hashResults[key] = expectedHashValue === hashValue; } - hashResults[key] = expectedHashValue === hashValue; - } - const { failUnmentioned } = serverRequest; - if (failUnmentioned && failUnmentioned.threadInfos) { - for (const threadID in threadInfos) { - const key = `threadInfo|${threadID}`; - const hashResult = hashResults[key]; - if (hashResult === null || hashResult === undefined) { - hashResults[key] = false; + const { failUnmentioned } = serverRequest; + if (failUnmentioned && failUnmentioned.threadInfos) { + for (const threadID in threadInfos) { + const key = `threadInfo|${threadID}`; + const hashResult = hashResults[key]; + if (hashResult === null || hashResult === undefined) { + hashResults[key] = false; + } } } - } - if (failUnmentioned && failUnmentioned.entryInfos) { - for (const entryID in filteredEntryInfos) { - const key = `entryInfo|${entryID}`; - const hashResult = hashResults[key]; - if (hashResult === null || hashResult === undefined) { - hashResults[key] = false; + if (failUnmentioned && failUnmentioned.entryInfos) { + for (const entryID in filteredEntryInfos) { + const key = `entryInfo|${entryID}`; + const hashResult = hashResults[key]; + if (hashResult === null || hashResult === undefined) { + hashResults[key] = false; + } } } - } - if (failUnmentioned && failUnmentioned.userInfos) { - for (const userID in userInfos) { - const key = `userInfo|${userID}`; - const hashResult = hashResults[key]; - if (hashResult === null || hashResult === undefined) { - hashResults[key] = false; + if (failUnmentioned && failUnmentioned.userInfos) { + for (const userID in userInfos) { + const key = `userInfo|${userID}`; + const hashResult = hashResults[key]; + if (hashResult === null || hashResult === undefined) { + hashResults[key] = false; + } } } - } - clientResponses.push({ - type: serverRequestTypes.CHECK_STATE, - hashResults, - }); - } else if ( - serverRequest.type === serverRequestTypes.MORE_ONE_TIME_KEYS && - oneTimeKeyGenerator - ) { - const keys: string[] = []; - for (let i = 0; i < minimumOneTimeKeysRequired; ++i) { - keys.push(oneTimeKeyGenerator(i)); + clientResponses.push({ + type: serverRequestTypes.CHECK_STATE, + hashResults, + }); + } else if ( + serverRequest.type === serverRequestTypes.MORE_ONE_TIME_KEYS && + oneTimeKeyGenerator + ) { + const keys: string[] = []; + for (let i = 0; i < minimumOneTimeKeysRequired; ++i) { + keys.push(oneTimeKeyGenerator(i)); + } + clientResponses.push({ + type: serverRequestTypes.MORE_ONE_TIME_KEYS, + keys, + }); } - clientResponses.push({ - type: serverRequestTypes.MORE_ONE_TIME_KEYS, - keys, - }); } - } - return clientResponses; - }, + return clientResponses; + }, ); const sessionStateFuncSelector: ( @@ -169,15 +170,16 @@ (state: AppState) => state.updatesCurrentAsOf, currentCalendarQuery, ( - messagesCurrentAsOf: number, - updatesCurrentAsOf: number, - calendarQuery: (calendarActive: boolean) => CalendarQuery, - ) => (calendarActive: boolean): SessionState => ({ - calendarQuery: calendarQuery(calendarActive), - messagesCurrentAsOf, - updatesCurrentAsOf, - watchedIDs: threadWatcher.getWatchedIDs(), - }), + messagesCurrentAsOf: number, + updatesCurrentAsOf: number, + calendarQuery: (calendarActive: boolean) => CalendarQuery, + ) => + (calendarActive: boolean): SessionState => ({ + calendarQuery: calendarQuery(calendarActive), + messagesCurrentAsOf, + updatesCurrentAsOf, + watchedIDs: threadWatcher.getWatchedIDs(), + }), ); export { queuedReports, getClientResponsesSelector, sessionStateFuncSelector }; diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js --- a/lib/selectors/thread-selectors.js +++ b/lib/selectors/thread-selectors.js @@ -48,9 +48,9 @@ const _mapValuesWithKeys = _mapValues.convert({ cap: false }); -type ThreadInfoSelectorType = ( - state: BaseAppState<*>, -) => { +[id: string]: ThreadInfo }; +type ThreadInfoSelectorType = (state: BaseAppState<*>) => { + +[id: string]: ThreadInfo, +}; const threadInfoSelector: ThreadInfoSelectorType = createObjectSelector( (state: BaseAppState<*>) => state.threadStore.threadInfos, (state: BaseAppState<*>) => state.currentUserInfo && state.currentUserInfo.id, @@ -119,9 +119,9 @@ ), ); -const entryInfoSelector: ( - state: BaseAppState<*>, -) => { +[id: string]: EntryInfo } = createObjectSelector( +const entryInfoSelector: (state: BaseAppState<*>) => { + +[id: string]: EntryInfo, +} = createObjectSelector( (state: BaseAppState<*>) => state.entryStore.entryInfos, (state: BaseAppState<*>) => state.currentUserInfo && state.currentUserInfo.id, (state: BaseAppState<*>) => state.userStore.userInfos, @@ -130,9 +130,9 @@ // "current" means within startDate/endDate range, not deleted, and in // onScreenThreadInfos -const currentDaysToEntries: ( - state: BaseAppState<*>, -) => { +[dayString: string]: EntryInfo[] } = createSelector( +const currentDaysToEntries: (state: BaseAppState<*>) => { + +[dayString: string]: EntryInfo[], +} = createSelector( entryInfoSelector, (state: BaseAppState<*>) => state.entryStore.daysToEntries, (state: BaseAppState<*>) => state.navInfo.startDate, @@ -172,9 +172,9 @@ }, ); -const childThreadInfos: ( - state: BaseAppState<*>, -) => { +[id: string]: $ReadOnlyArray } = createSelector( +const childThreadInfos: (state: BaseAppState<*>) => { + +[id: string]: $ReadOnlyArray, +} = createSelector( threadInfoSelector, (threadInfos: { +[id: string]: ThreadInfo }) => { const result = {}; @@ -207,9 +207,9 @@ return null; } -const sidebarInfoSelector: ( - state: BaseAppState<*>, -) => { +[id: string]: $ReadOnlyArray } = createObjectSelector( +const sidebarInfoSelector: (state: BaseAppState<*>) => { + +[id: string]: $ReadOnlyArray, +} = createObjectSelector( childThreadInfos, (state: BaseAppState<*>) => state.messageStore, (childThreads: $ReadOnlyArray, messageStore: MessageStore) => { @@ -250,16 +250,16 @@ ).length, ); -const unreadBackgroundCount: ( - state: BaseAppState<*>, -) => number = createSelector( - (state: BaseAppState<*>) => state.threadStore.threadInfos, - (threadInfos: { +[id: string]: RawThreadInfo }): number => - values(threadInfos).filter( - threadInfo => - threadInBackgroundChatList(threadInfo) && threadInfo.currentUser.unread, - ).length, -); +const unreadBackgroundCount: (state: BaseAppState<*>) => number = + createSelector( + (state: BaseAppState<*>) => state.threadStore.threadInfos, + (threadInfos: { +[id: string]: RawThreadInfo }): number => + values(threadInfos).filter( + threadInfo => + threadInBackgroundChatList(threadInfo) && + threadInfo.currentUser.unread, + ).length, + ); const baseAncestorThreadInfos = (threadID: string) => createSelector( @@ -352,26 +352,24 @@ return mostRecent ? mostRecent.threadID : null; } -const mostRecentlyReadThreadSelector: ( - state: BaseAppState<*>, -) => ?string = createSelector( - (state: BaseAppState<*>) => state.messageStore, - (state: BaseAppState<*>) => state.threadStore.threadInfos, - mostRecentlyReadThread, -); +const mostRecentlyReadThreadSelector: (state: BaseAppState<*>) => ?string = + createSelector( + (state: BaseAppState<*>) => state.messageStore, + (state: BaseAppState<*>) => state.threadStore.threadInfos, + mostRecentlyReadThread, + ); -const threadInfoFromSourceMessageIDSelector: ( - state: BaseAppState<*>, -) => { +[id: string]: ThreadInfo } = createSelector( +const threadInfoFromSourceMessageIDSelector: (state: BaseAppState<*>) => { + +[id: string]: ThreadInfo, +} = createSelector( (state: BaseAppState<*>) => state.threadStore.threadInfos, threadInfoSelector, ( rawThreadInfos: { +[id: string]: RawThreadInfo }, threadInfos: { +[id: string]: ThreadInfo }, ) => { - const pendingToRealizedThreadIDs = pendingToRealizedThreadIDsSelector( - rawThreadInfos, - ); + const pendingToRealizedThreadIDs = + pendingToRealizedThreadIDsSelector(rawThreadInfos); const result = {}; for (const realizedID of pendingToRealizedThreadIDs.values()) { const threadInfo = threadInfos[realizedID]; diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js --- a/lib/selectors/user-selectors.js +++ b/lib/selectors/user-selectors.js @@ -113,9 +113,9 @@ baseRelativeMemberInfoSelectorForMembersOfThread, ); -const userInfoSelectorForPotentialMembers: ( - state: BaseAppState<*>, -) => { [id: string]: AccountUserInfo } = createSelector( +const userInfoSelectorForPotentialMembers: (state: BaseAppState<*>) => { + [id: string]: AccountUserInfo, +} = createSelector( (state: BaseAppState<*>) => state.userStore.userInfos, (state: BaseAppState<*>) => state.currentUserInfo && state.currentUserInfo.id, ( @@ -164,22 +164,21 @@ state.dataLoaded ); -const userStoreSearchIndex: ( - state: BaseAppState<*>, -) => SearchIndex = createSelector( - (state: BaseAppState<*>) => state.userStore.userInfos, - (userInfos: UserInfos) => { - const searchIndex = new SearchIndex(); - for (const id in userInfos) { - const { username } = userInfos[id]; - if (!username) { - continue; +const userStoreSearchIndex: (state: BaseAppState<*>) => SearchIndex = + createSelector( + (state: BaseAppState<*>) => state.userStore.userInfos, + (userInfos: UserInfos) => { + const searchIndex = new SearchIndex(); + for (const id in userInfos) { + const { username } = userInfos[id]; + if (!username) { + continue; + } + searchIndex.addEntry(id, username); } - searchIndex.addEntry(id, username); - } - return searchIndex; - }, -); + return searchIndex; + }, + ); const usersWithPersonalThreadSelector: ( state: BaseAppState<*>, diff --git a/lib/shared/entry-utils.js b/lib/shared/entry-utils.js --- a/lib/shared/entry-utils.js +++ b/lib/shared/entry-utils.js @@ -234,9 +234,9 @@ return { ...rest }; // we only do this for Flow } -function serverEntryInfosObject( - array: $ReadOnlyArray, -): { +[id: string]: RawEntryInfo } { +function serverEntryInfosObject(array: $ReadOnlyArray): { + +[id: string]: RawEntryInfo, +} { const obj = {}; for (const rawEntryInfo of array) { const entryInfo = serverEntryInfo(rawEntryInfo); diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js --- a/lib/shared/markdown.js +++ b/lib/shared/markdown.js @@ -77,13 +77,16 @@ const paragraphStripTrailingNewlineRegex: RegExp = /^([^\n]*)(?:\n|$)/; const headingRegex: RegExp = /^ *(#{1,6}) ([^\n]+?)#* *(?![^\n])/; -const headingStripFollowingNewlineRegex: RegExp = /^ *(#{1,6}) ([^\n]+?)#* *(?:\n|$)/; +const headingStripFollowingNewlineRegex: RegExp = + /^ *(#{1,6}) ([^\n]+?)#* *(?:\n|$)/; const fenceRegex: RegExp = /^(`{3,}|~{3,})[^\n]*\n([\s\S]*?\n)\1(?:\n|$)/; -const fenceStripTrailingNewlineRegex: RegExp = /^(`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n\1(?:\n|$)/; +const fenceStripTrailingNewlineRegex: RegExp = + /^(`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n\1(?:\n|$)/; const codeBlockRegex: RegExp = /^(?: {4}[^\n]*\n*?)+(?!\n* {4}[^\n])(?:\n|$)/; -const codeBlockStripTrailingNewlineRegex: RegExp = /^((?: {4}[^\n]*\n*?)+)(?!\n* {4}[^\n])(?:\n|$)/; +const codeBlockStripTrailingNewlineRegex: RegExp = + /^((?: {4}[^\n]*\n*?)+)(?!\n* {4}[^\n])(?:\n|$)/; const urlRegex: RegExp = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/i; @@ -135,7 +138,8 @@ } const listRegex = /^( *)([*+-]|\d+\.) ([\s\S]+?)(?:\n{2}|\s*\n*$)/; -const listItemRegex = /^( *)([*+-]|\d+\.) [^\n]*(?:\n(?!\1(?:[*+-]|\d+\.) )[^\n]*)*(\n|$)/gm; +const listItemRegex = + /^( *)([*+-]|\d+\.) [^\n]*(?:\n(?!\1(?:[*+-]|\d+\.) )[^\n]*)*(\n|$)/gm; const listItemPrefixRegex = /^( *)([*+-]|\d+\.) /; const listLookBehindRegex = /(?:^|\n)( *)$/; @@ -217,7 +221,8 @@ } const blockQuoteRegex: RegExp = /^( *>[^\n]+(?:\n[^\n]+)*)(?:\n|$)/; -const blockQuoteStripFollowingNewlineRegex: RegExp = /^( *>[^\n]+(?:\n[^\n]+)*)(?:\n|$){2}/; +const blockQuoteStripFollowingNewlineRegex: RegExp = + /^( *>[^\n]+(?:\n[^\n]+)*)(?:\n|$){2}/; const maxNestedQuotations = 5; // Custom match and parse functions implementation for block quotes diff --git a/lib/shared/markdown.test.js b/lib/shared/markdown.test.js --- a/lib/shared/markdown.test.js +++ b/lib/shared/markdown.test.js @@ -43,13 +43,17 @@ }); it('We expect a spoiler containing a single space to match, even when split across multiple lines.', () => { - expect('|| \ - ||').toMatch(spoilerRegex); + expect( + '|| \ + ||', + ).toMatch(spoilerRegex); }); it('We do not expect a spoiler containing a new line character to match (3).', () => { - expect('|| \n\ - ||').not.toMatch(spoilerRegex); + expect( + '|| \n\ + ||', + ).not.toMatch(spoilerRegex); }); it("We expect to extract 'hello' from the following spoiler: ||hello||", () => { diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -455,10 +455,8 @@ const initialMembers = new Map(); if (userIsMember(parentThreadInfo, sourceMessageInfo.creator.id)) { - const { - id: sourceAuthorID, - username: sourceAuthorUsername, - } = sourceMessageInfo.creator; + const { id: sourceAuthorID, username: sourceAuthorUsername } = + sourceMessageInfo.creator; invariant( sourceAuthorUsername, 'sourceAuthorUsername should be set in createPendingSidebar', @@ -507,12 +505,8 @@ function createUnresolvedPendingSidebar( input: CreateUnresolvedPendingSidebarInput, ): ThreadInfo { - const { - sourceMessageInfo, - parentThreadInfo, - viewerID, - markdownRules, - } = input; + const { sourceMessageInfo, parentThreadInfo, viewerID, markdownRules } = + input; const messageTitleEntityText = getMessageTitle( sourceMessageInfo, @@ -775,11 +769,8 @@ if (!shouldFilter) { return permissions; } - const { - edit_thread_color, - edit_thread_description, - ...newPermissions - } = permissions; + const { edit_thread_color, edit_thread_description, ...newPermissions } = + permissions; return newPermissions; } @@ -1013,13 +1004,14 @@ permissionsDisabledByBlockArray, ); -const disabledPermissions: ThreadPermissionsInfo = permissionsDisabledByBlockArray.reduce( - (permissions: ThreadPermissionsInfo, permission: string) => ({ - ...permissions, - [permission]: { value: false, source: null }, - }), - {}, -); +const disabledPermissions: ThreadPermissionsInfo = + permissionsDisabledByBlockArray.reduce( + (permissions: ThreadPermissionsInfo, permission: string) => ({ + ...permissions, + [permission]: { value: false, source: null }, + }), + {}, + ); // Consider updating itemHeight in native/chat/chat-thread-list.react.js // if you change this diff --git a/lib/socket/api-request-handler.react.js b/lib/socket/api-request-handler.react.js --- a/lib/socket/api-request-handler.react.js +++ b/lib/socket/api-request-handler.react.js @@ -89,11 +89,10 @@ }; } -const ConnectedAPIRequestHandler: React.ComponentType = React.memo( - function ConnectedAPIRequestHandler(props) { +const ConnectedAPIRequestHandler: React.ComponentType = + React.memo(function ConnectedAPIRequestHandler(props) { const connection = useSelector(state => state.connection); return ; - }, -); + }); export default ConnectedAPIRequestHandler; diff --git a/lib/socket/calendar-query-handler.react.js b/lib/socket/calendar-query-handler.react.js --- a/lib/socket/calendar-query-handler.react.js +++ b/lib/socket/calendar-query-handler.react.js @@ -120,8 +120,8 @@ }; } -const ConnectedCalendarQueryHandler: React.ComponentType = React.memo( - function ConnectedCalendarQueryHandler(props) { +const ConnectedCalendarQueryHandler: React.ComponentType = + React.memo(function ConnectedCalendarQueryHandler(props) { const connection = useSelector(state => state.connection); const lastUserInteractionCalendar = useSelector( state => state.entryStore.lastUserInteractionCalendar, @@ -141,6 +141,5 @@ dispatchActionPromise={dispatchActionPromise} /> ); - }, -); + }); export default ConnectedCalendarQueryHandler; diff --git a/lib/socket/report-handler.react.js b/lib/socket/report-handler.react.js --- a/lib/socket/report-handler.react.js +++ b/lib/socket/report-handler.react.js @@ -78,8 +78,8 @@ } } -const ConnectedReportHandler: React.ComponentType = React.memo( - function ConnectedReportHandler(props) { +const ConnectedReportHandler: React.ComponentType = + React.memo(function ConnectedReportHandler(props) { const queuedReports = useSelector(queuedReportsSelector); const callSendReports = useServerCall(sendReports); const dispatchActionPromise = useDispatchActionPromise(); @@ -92,7 +92,6 @@ dispatchActionPromise={dispatchActionPromise} /> ); - }, -); + }); export default ConnectedReportHandler; diff --git a/lib/socket/request-response-handler.react.js b/lib/socket/request-response-handler.react.js --- a/lib/socket/request-response-handler.react.js +++ b/lib/socket/request-response-handler.react.js @@ -132,8 +132,8 @@ } } -const ConnectedRequestResponseHandler: React.ComponentType = React.memo( - function ConnectedRequestResponseHandler(props) { +const ConnectedRequestResponseHandler: React.ComponentType = + React.memo(function ConnectedRequestResponseHandler(props) { const connection = useSelector(state => state.connection); const dispatch = useDispatch(); @@ -144,6 +144,5 @@ dispatch={dispatch} /> ); - }, -); + }); export default ConnectedRequestResponseHandler; diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js --- a/lib/socket/socket.react.js +++ b/lib/socket/socket.react.js @@ -363,27 +363,28 @@ ); } - sendMessageWithoutID: ( - message: ClientSocketMessageWithoutID, - ) => number = message => { - const id = this.nextClientMessageID++; - // These conditions all do the same thing and the runtime checks are only - // necessary for Flow - if (message.type === clientSocketMessageTypes.INITIAL) { - this.sendMessage(({ ...message, id }: ClientInitialClientSocketMessage)); - } else if (message.type === clientSocketMessageTypes.RESPONSES) { - this.sendMessage( - ({ ...message, id }: ClientResponsesClientSocketMessage), - ); - } else if (message.type === clientSocketMessageTypes.PING) { - this.sendMessage(({ ...message, id }: PingClientSocketMessage)); - } else if (message.type === clientSocketMessageTypes.ACK_UPDATES) { - this.sendMessage(({ ...message, id }: AckUpdatesClientSocketMessage)); - } else if (message.type === clientSocketMessageTypes.API_REQUEST) { - this.sendMessage(({ ...message, id }: APIRequestClientSocketMessage)); - } - return id; - }; + sendMessageWithoutID: (message: ClientSocketMessageWithoutID) => number = + message => { + const id = this.nextClientMessageID++; + // These conditions all do the same thing and the runtime checks are only + // necessary for Flow + if (message.type === clientSocketMessageTypes.INITIAL) { + this.sendMessage( + ({ ...message, id }: ClientInitialClientSocketMessage), + ); + } else if (message.type === clientSocketMessageTypes.RESPONSES) { + this.sendMessage( + ({ ...message, id }: ClientResponsesClientSocketMessage), + ); + } else if (message.type === clientSocketMessageTypes.PING) { + this.sendMessage(({ ...message, id }: PingClientSocketMessage)); + } else if (message.type === clientSocketMessageTypes.ACK_UPDATES) { + this.sendMessage(({ ...message, id }: AckUpdatesClientSocketMessage)); + } else if (message.type === clientSocketMessageTypes.API_REQUEST) { + this.sendMessage(({ ...message, id }: APIRequestClientSocketMessage)); + } + return id; + }; sendMessage(message: ClientClientSocketMessage) { const socket = this.socket; @@ -743,33 +744,33 @@ } } - detectUnsupervisedBackground: ( - alreadyClosed: boolean, - ) => boolean = alreadyClosed => { - // On native, sometimes the app is backgrounded without the proper callbacks - // getting triggered. This leaves us in an incorrect state for two reasons: - // (1) The connection is still considered to be active, causing API requests - // to be processed via socket and failing. - // (2) We rely on flipping foreground state in Redux to detect activity - // changes, and thus won't think we need to update activity. - if ( - this.props.connection.status !== 'connected' || - !this.messageLastReceived || - this.messageLastReceived + serverRequestSocketTimeout >= Date.now() || - (actionLogger.mostRecentActionTime && - actionLogger.mostRecentActionTime + 3000 < Date.now()) - ) { - return false; - } - if (!alreadyClosed) { - this.cleanUpServerTerminatedSocket(); - } - this.props.dispatch({ - type: unsupervisedBackgroundActionType, - payload: null, - }); - return true; - }; + detectUnsupervisedBackground: (alreadyClosed: boolean) => boolean = + alreadyClosed => { + // On native, sometimes the app is backgrounded without the proper + // callbacks getting triggered. This leaves us in an incorrect state for + // two reasons: + // (1) The connection is still considered to be active, causing API + // requests to be processed via socket and failing. + // (2) We rely on flipping foreground state in Redux to detect activity + // changes, and thus won't think we need to update activity. + if ( + this.props.connection.status !== 'connected' || + !this.messageLastReceived || + this.messageLastReceived + serverRequestSocketTimeout >= Date.now() || + (actionLogger.mostRecentActionTime && + actionLogger.mostRecentActionTime + 3000 < Date.now()) + ) { + return false; + } + if (!alreadyClosed) { + this.cleanUpServerTerminatedSocket(); + } + this.props.dispatch({ + type: unsupervisedBackgroundActionType, + payload: null, + }); + return true; + }; } export default Socket; diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -187,6 +187,5 @@ export type NotificationTypes = $Values; -export const notificationTypeValues: $ReadOnlyArray = values( - notificationTypes, -); +export const notificationTypeValues: $ReadOnlyArray = + values(notificationTypes); diff --git a/lib/types/relationship-types.js b/lib/types/relationship-types.js --- a/lib/types/relationship-types.js +++ b/lib/types/relationship-types.js @@ -32,9 +32,8 @@ UNBLOCK: 'unblock', }); export type RelationshipAction = $Values; -export const relationshipActionsList: $ReadOnlyArray = values( - relationshipActions, -); +export const relationshipActionsList: $ReadOnlyArray = + values(relationshipActions); export const relationshipButtons = Object.freeze({ FRIEND: 'friend', diff --git a/lib/utils/action-logger.js b/lib/utils/action-logger.js --- a/lib/utils/action-logger.js +++ b/lib/utils/action-logger.js @@ -166,15 +166,13 @@ const actionLogger: ActionLogger = new ActionLogger(); -const reduxLoggerMiddleware: Middleware< - Object, - Object, -> = store => next => action => { - const beforeState = store.getState(); - const result = next(action); - const afterState = store.getState(); - actionLogger.addReduxAction(action, beforeState, afterState); - return result; -}; +const reduxLoggerMiddleware: Middleware = + store => next => action => { + const beforeState = store.getState(); + const result = next(action); + const afterState = store.getState(); + actionLogger.addReduxAction(action, beforeState, afterState); + return result; + }; export { actionLogger, reduxLoggerMiddleware }; diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js --- a/lib/utils/action-utils.js +++ b/lib/utils/action-utils.js @@ -410,9 +410,8 @@ type CreateBoundServerCallsSelectorType = ( ActionFunc, ) => BindServerCallsParams => F; -const createBoundServerCallsSelector: CreateBoundServerCallsSelectorType = (_memoize( - baseCreateBoundServerCallsSelector, -): any); +const createBoundServerCallsSelector: CreateBoundServerCallsSelectorType = + (_memoize(baseCreateBoundServerCallsSelector): any); function useServerCall(serverCall: ActionFunc): F { const dispatch = useDispatch(); diff --git a/lib/utils/call-server-endpoint.js b/lib/utils/call-server-endpoint.js --- a/lib/utils/call-server-endpoint.js +++ b/lib/utils/call-server-endpoint.js @@ -144,25 +144,26 @@ // is not logged in on web. mergedData.sessionID = sessionID ? sessionID : null; } - const callEndpointPromise = (async (): Promise => { - const response = await fetch(url, { - method: 'POST', - // This is necessary to allow cookie headers to get passed down to us - credentials: 'same-origin', - body: JSON.stringify(mergedData), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - }, - }); - const text = await response.text(); - try { - return JSON.parse(text); - } catch (e) { - console.log(text); - throw e; - } - })(); + const callEndpointPromise = + (async (): Promise => { + const response = await fetch(url, { + method: 'POST', + // This is necessary to allow cookie headers to get passed down to us + credentials: 'same-origin', + body: JSON.stringify(mergedData), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + }); + const text = await response.text(); + try { + return JSON.parse(text); + } catch (e) { + console.log(text); + throw e; + } + })(); const timeout = options && options.timeout ? options.timeout : callServerEndpointTimeout; diff --git a/lib/utils/date-utils.js b/lib/utils/date-utils.js --- a/lib/utils/date-utils.js +++ b/lib/utils/date-utils.js @@ -123,9 +123,10 @@ } } -function thisMonthDates( - timeZone?: ?string, -): { startDate: string, endDate: string } { +function thisMonthDates(timeZone?: ?string): { + startDate: string, + endDate: string, +} { const now = currentDateInTimeZone(timeZone); const year = now.getFullYear(); const month = now.getMonth() + 1; diff --git a/lib/utils/entity-helpers.js b/lib/utils/entity-helpers.js --- a/lib/utils/entity-helpers.js +++ b/lib/utils/entity-helpers.js @@ -79,9 +79,10 @@ function useResolvedThreadInfosObj(threadInfosObj: { +[id: string]: ThreadInfo, }): { +[id: string]: ResolvedThreadInfo } { - const threadInfosArray = React.useMemo(() => values(threadInfosObj), [ - threadInfosObj, - ]); + const threadInfosArray = React.useMemo( + () => values(threadInfosObj), + [threadInfosObj], + ); const resolvedThreadInfosArray = useResolvedThreadInfos(threadInfosArray); return React.useMemo(() => { const obj = {}; diff --git a/lib/utils/message-ops-utils.js b/lib/utils/message-ops-utils.js --- a/lib/utils/message-ops-utils.js +++ b/lib/utils/message-ops-utils.js @@ -95,9 +95,8 @@ if (!clientDBMessageInfo.content) { return []; } - const messageContent: $ReadOnlyArray = JSON.parse( - clientDBMessageInfo.content, - ); + const messageContent: $ReadOnlyArray = + JSON.parse(clientDBMessageInfo.content); const translatedMedia = []; for (const media of messageContent) { @@ -151,9 +150,10 @@ ? rawMessageInfo.unsupportedMessageInfo.type.toString() : null, time: rawMessageInfo.time.toString(), - content: messageSpecs[rawMessageInfo.type].messageContentForClientDB?.( - rawMessageInfo, - ), + content: + messageSpecs[rawMessageInfo.type].messageContentForClientDB?.( + rawMessageInfo, + ), media_infos: rawMessageInfo.type === messageTypes.IMAGES || rawMessageInfo.type === messageTypes.MULTIMEDIA diff --git a/lib/utils/message-ops-utils.test.js b/lib/utils/message-ops-utils.test.js --- a/lib/utils/message-ops-utils.test.js +++ b/lib/utils/message-ops-utils.test.js @@ -348,8 +348,7 @@ threadID: '85466', time: 1637778853216, creatorID: '256', - text: - 'as you inevitably discover bugs, have feature requests, or design suggestions, feel free to message them to me in the app.', + text: 'as you inevitably discover bugs, have feature requests, or design suggestions, feel free to message them to me in the app.', }, id: '86223', }; @@ -398,16 +397,14 @@ media_infos: [ { id: 'localUpload0', - uri: - 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', + uri: 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', type: 'video', extras: '{"dimensions":{"height":1010,"width":576},"loop":false,"local_media_selection":{"step":"video_library","dimensions":{"height":1010,"width":576},"uri":"assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov","filename":"IMG_0007.MOV","mediaNativeID":"6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2/L0/001","duration":25.866666666666667,"selectTime":1665014144968,"sendTime":1665014144968,"retries":0}}', }, { id: 'localUpload1', - uri: - 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', + uri: 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', type: 'photo', extras: '{"dimensions":{"height":1010,"width":576},"loop":false}', }, @@ -421,15 +418,13 @@ media: [ { id: 'localUpload0', - uri: - 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', + uri: 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', type: 'video', dimensions: { height: 1010, width: 576 }, localMediaSelection: { step: 'video_library', dimensions: { height: 1010, width: 576 }, - uri: - 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', + uri: 'assets-library://asset/asset.mov?id=6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2&ext=mov', filename: 'IMG_0007.MOV', mediaNativeID: '6F1BEA56-3875-474C-B3AF-B11DEDCBAFF2/L0/001', duration: 25.866666666666667, diff --git a/lib/utils/objects.js b/lib/utils/objects.js --- a/lib/utils/objects.js +++ b/lib/utils/objects.js @@ -60,12 +60,10 @@ const processedObjectKeys = Object.keys(processedObject); const expectedObjectKeys = Object.keys(expectedObject); - const inProcessedButNotExpected = _difference(processedObjectKeys)( - expectedObjectKeys, - ); - const inExpectedButNotProcessed = _difference(expectedObjectKeys)( - processedObjectKeys, - ); + const inProcessedButNotExpected = + _difference(processedObjectKeys)(expectedObjectKeys); + const inExpectedButNotProcessed = + _difference(expectedObjectKeys)(processedObjectKeys); invariant( _isEqual(processedObject)(expectedObject), diff --git a/lib/utils/siwe-utils.js b/lib/utils/siwe-utils.js --- a/lib/utils/siwe-utils.js +++ b/lib/utils/siwe-utils.js @@ -80,7 +80,8 @@ return `Device IdPubKey: ${publicKey} ${siweStatementWithoutPublicKey}`; } -const siweStatementWithPublicKeyRegex = /^Device IdPubKey: [a-zA-Z0-9+/]{43} By continuing, I accept the Comm Terms of Service: https:\/\/comm.app\/terms$/; +const siweStatementWithPublicKeyRegex = + /^Device IdPubKey: [a-zA-Z0-9+/]{43} By continuing, I accept the Comm Terms of Service: https:\/\/comm.app\/terms$/; function isValidSIWEStatementWithPublicKey(candidate: string): boolean { return siweStatementWithPublicKeyRegex.test(candidate); } diff --git a/native/account/log-in-panel.react.js b/native/account/log-in-panel.react.js --- a/native/account/log-in-panel.react.js +++ b/native/account/log-in-panel.react.js @@ -363,8 +363,8 @@ const loadingStatusSelector = createLoadingStatusSelector(logInActionTypes); -const ConnectedLogInPanel: React.ComponentType = React.memo( - function ConnectedLogInPanel(props: BaseProps) { +const ConnectedLogInPanel: React.ComponentType = + React.memo(function ConnectedLogInPanel(props: BaseProps) { const loadingStatus = useSelector(loadingStatusSelector); const navContext = React.useContext(NavContext); @@ -378,10 +378,8 @@ const dispatchActionPromise = useDispatchActionPromise(); const callLogIn = useServerCall(logIn); - const [ - primaryIdentityPublicKey, - setPrimaryIdentityPublicKey, - ] = React.useState(null); + const [primaryIdentityPublicKey, setPrimaryIdentityPublicKey] = + React.useState(null); React.useEffect(() => { (async () => { await commCoreModule.initializeCryptoAccount('PLACEHOLDER'); @@ -400,7 +398,6 @@ primaryIdentityPublicKey={primaryIdentityPublicKey} /> ); - }, -); + }); export default ConnectedLogInPanel; diff --git a/native/account/register-panel.react.js b/native/account/register-panel.react.js --- a/native/account/register-panel.react.js +++ b/native/account/register-panel.react.js @@ -456,8 +456,8 @@ const loadingStatusSelector = createLoadingStatusSelector(registerActionTypes); -const ConnectedRegisterPanel: React.ComponentType = React.memo( - function ConnectedRegisterPanel(props: BaseProps) { +const ConnectedRegisterPanel: React.ComponentType = + React.memo(function ConnectedRegisterPanel(props: BaseProps) { const loadingStatus = useSelector(loadingStatusSelector); const navContext = React.useContext(NavContext); @@ -471,10 +471,8 @@ const dispatchActionPromise = useDispatchActionPromise(); const callRegister = useServerCall(register); - const [ - primaryIdentityPublicKey, - setPrimaryIdentityPublicKey, - ] = React.useState(null); + const [primaryIdentityPublicKey, setPrimaryIdentityPublicKey] = + React.useState(null); React.useEffect(() => { (async () => { await commCoreModule.initializeCryptoAccount('PLACEHOLDER'); @@ -493,7 +491,6 @@ primaryIdentityPublicKey={primaryIdentityPublicKey} /> ); - }, -); + }); export default ConnectedRegisterPanel; diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js --- a/native/account/siwe-panel.react.js +++ b/native/account/siwe-panel.react.js @@ -32,9 +32,8 @@ const getSIWENonceLoadingStatusSelector = createLoadingStatusSelector( getSIWENonceActionTypes, ); -const siweAuthLoadingStatusSelector = createLoadingStatusSelector( - siweAuthActionTypes, -); +const siweAuthLoadingStatusSelector = + createLoadingStatusSelector(siweAuthActionTypes); type Props = { +onClose: () => mixed, @@ -74,10 +73,8 @@ ); const [nonce, setNonce] = React.useState(null); - const [ - primaryIdentityPublicKey, - setPrimaryIdentityPublicKey, - ] = React.useState(null); + const [primaryIdentityPublicKey, setPrimaryIdentityPublicKey] = + React.useState(null); React.useEffect(() => { (async () => { @@ -95,9 +92,8 @@ }, [dispatchActionPromise, getSIWENonceCall]); const [isLoading, setLoading] = React.useState(true); - const [isWalletConnectModalOpen, setWalletConnectModalOpen] = React.useState( - false, - ); + const [isWalletConnectModalOpen, setWalletConnectModalOpen] = + React.useState(false); const insets = useSafeAreaInsets(); const bottomInset = insets.bottom; const snapPoints = React.useMemo(() => { diff --git a/native/calendar/calendar.react.js b/native/calendar/calendar.react.js --- a/native/calendar/calendar.react.js +++ b/native/calendar/calendar.react.js @@ -316,12 +316,8 @@ } } - const { - lastStartDate, - newStartDate, - lastEndDate, - newEndDate, - } = Calendar.datesFromListData(lastLDWH, newLDWH); + const { lastStartDate, newStartDate, lastEndDate, newEndDate } = + Calendar.datesFromListData(lastLDWH, newLDWH); if (newStartDate > lastStartDate || newEndDate < lastEndDate) { // If there are fewer items in our new data, which happens when the diff --git a/native/calendar/entry.react.js b/native/calendar/entry.react.js --- a/native/calendar/entry.react.js +++ b/native/calendar/entry.react.js @@ -438,14 +438,13 @@ ); } - textInputRef: ( - textInput: ?React.ElementRef, - ) => void = textInput => { - this.textInput = textInput; - if (textInput && this.state.editing) { - this.enterEditMode(); - } - }; + textInputRef: (textInput: ?React.ElementRef) => void = + textInput => { + this.textInput = textInput; + if (textInput && this.state.editing) { + this.enterEditMode(); + } + }; enterEditMode: () => Promise = async () => { this.setActive(); diff --git a/native/calendar/section-footer.react.js b/native/calendar/section-footer.react.js --- a/native/calendar/section-footer.react.js +++ b/native/calendar/section-footer.react.js @@ -71,13 +71,12 @@ }, }; -const ConnectedSectionFooter: React.ComponentType = React.memo( - function ConnectedSectionFooter(props: BaseProps) { +const ConnectedSectionFooter: React.ComponentType = + React.memo(function ConnectedSectionFooter(props: BaseProps) { const styles = useStyles(unboundStyles); const colors = useColors(); return ; - }, -); + }); export default ConnectedSectionFooter; diff --git a/native/chat/chat-context-provider.react.js b/native/chat/chat-context-provider.react.js --- a/native/chat/chat-context-provider.react.js +++ b/native/chat/chat-context-provider.react.js @@ -126,10 +126,8 @@ [], ); - const [ - sidebarAnimationType, - setSidebarAnimationType, - ] = React.useState('move_source_message'); + const [sidebarAnimationType, setSidebarAnimationType] = + React.useState('move_source_message'); const contextValue = React.useMemo( () => ({ diff --git a/native/chat/chat-header.react.js b/native/chat/chat-header.react.js --- a/native/chat/chat-header.react.js +++ b/native/chat/chat-header.react.js @@ -10,12 +10,11 @@ const activeTabSelector = createActiveTabSelector(ChatRouteName); -const ChatHeader: React.ComponentType = React.memo( - function ChatHeader(props: StackHeaderProps) { +const ChatHeader: React.ComponentType = + React.memo(function ChatHeader(props: StackHeaderProps) { const navContext = React.useContext(NavContext); const activeTab = activeTabSelector(navContext); return
; - }, -); + }); export default ChatHeader; diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js --- a/native/chat/chat-input-bar.react.js +++ b/native/chat/chat-input-bar.react.js @@ -102,17 +102,8 @@ import { nativeTypeaheadRegex } from '../utils/typeahead-utils.js'; /* eslint-disable import/no-named-as-default-member */ -const { - Value, - Clock, - block, - set, - cond, - neq, - sub, - interpolateNode, - stopClock, -} = Animated; +const { Value, Clock, block, set, cond, neq, sub, interpolateNode, stopClock } = + Animated; /* eslint-enable import/no-named-as-default-member */ const expandoButtonsAnimationConfig = { @@ -364,9 +355,8 @@ const systemKeyboardIsShowing = ChatInputBar.systemKeyboardShowing( this.props, ); - const systemKeyboardWasShowing = ChatInputBar.systemKeyboardShowing( - prevProps, - ); + const systemKeyboardWasShowing = + ChatInputBar.systemKeyboardShowing(prevProps); if (systemKeyboardIsShowing && !systemKeyboardWasShowing) { this.hideButtons(); } else if (!systemKeyboardIsShowing && systemKeyboardWasShowing) { @@ -905,9 +895,8 @@ const joinThreadLoadingStatusSelector = createLoadingStatusSelector( joinThreadActionTypes, ); -const createThreadLoadingStatusSelector = createLoadingStatusSelector( - newThreadActionTypes, -); +const createThreadLoadingStatusSelector = + createLoadingStatusSelector(newThreadActionTypes); type ConnectedChatInputBarBaseProps = { ...BaseProps, @@ -1011,8 +1000,10 @@ +navigation: ChatNavigationProp<'MessageList'>, +route: NavigationRoute<'MessageList'>, }; -const ConnectedChatInputBar: React.ComponentType = React.memo( - function ConnectedChatInputBar(props: ChatInputBarProps) { +const ConnectedChatInputBar: React.ComponentType = + React.memo(function ConnectedChatInputBar( + props: ChatInputBarProps, + ) { const { navigation, route, ...restProps } = props; const keyboardState = React.useContext(KeyboardContext); @@ -1088,7 +1079,6 @@ openCamera={openCamera} /> ); - }, -); + }); export { ConnectedChatInputBar as ChatInputBar, DummyChatInputBar }; diff --git a/native/chat/chat-item-height-measurer.react.js b/native/chat/chat-item-height-measurer.react.js --- a/native/chat/chat-item-height-measurer.react.js +++ b/native/chat/chat-item-height-measurer.react.js @@ -173,8 +173,7 @@ ); } -const MemoizedChatItemHeightMeasurer: React.ComponentType = React.memo( - ChatItemHeightMeasurer, -); +const MemoizedChatItemHeightMeasurer: React.ComponentType = + React.memo(ChatItemHeightMeasurer); export default MemoizedChatItemHeightMeasurer; diff --git a/native/chat/chat-list.react.js b/native/chat/chat-list.react.js --- a/native/chat/chat-list.react.js +++ b/native/chat/chat-list.react.js @@ -77,17 +77,15 @@ } componentDidMount() { - const tabNavigation: ?TabNavigationProp< - 'Chat', - > = this.props.navigation.getParent(); + const tabNavigation: ?TabNavigationProp<'Chat'> = + this.props.navigation.getParent(); invariant(tabNavigation, 'ChatNavigator should be within TabNavigator'); tabNavigation.addListener('tabPress', this.onTabPress); } componentWillUnmount() { - const tabNavigation: ?TabNavigationProp< - 'Chat', - > = this.props.navigation.getParent(); + const tabNavigation: ?TabNavigationProp<'Chat'> = + this.props.navigation.getParent(); invariant(tabNavigation, 'ChatNavigator should be within TabNavigator'); tabNavigation.removeListener('tabPress', this.onTabPress); } diff --git a/native/chat/chat-thread-list-see-more-sidebars.react.js b/native/chat/chat-thread-list-see-more-sidebars.react.js --- a/native/chat/chat-thread-list-see-more-sidebars.react.js +++ b/native/chat/chat-thread-list-see-more-sidebars.react.js @@ -17,10 +17,10 @@ }; function ChatThreadListSeeMoreSidebars(props: Props): React.Node { const { onPress, threadInfo, unread } = props; - const onPressButton = React.useCallback(() => onPress(threadInfo), [ - onPress, - threadInfo, - ]); + const onPressButton = React.useCallback( + () => onPress(threadInfo), + [onPress, threadInfo], + ); const colors = useColors(); const styles = useStyles(unboundStyles); diff --git a/native/chat/chat-thread-list-sidebar.react.js b/native/chat/chat-thread-list-sidebar.react.js --- a/native/chat/chat-thread-list-sidebar.react.js +++ b/native/chat/chat-thread-list-sidebar.react.js @@ -49,10 +49,10 @@ const { threadInfo } = sidebarInfo; - const onPress = React.useCallback(() => onPressItem(threadInfo), [ - threadInfo, - onPressItem, - ]); + const onPress = React.useCallback( + () => onPressItem(threadInfo), + [threadInfo, onPressItem], + ); return ( ); - }, -); + }); const unboundStyles = { button: { diff --git a/native/chat/settings/thread-settings-home-notifs.react.js b/native/chat/settings/thread-settings-home-notifs.react.js --- a/native/chat/settings/thread-settings-home-notifs.react.js +++ b/native/chat/settings/thread-settings-home-notifs.react.js @@ -99,8 +99,10 @@ }, }; -const ConnectedThreadSettingsHomeNotifs: React.ComponentType = React.memo( - function ConnectedThreadSettingsHomeNotifs(props: BaseProps) { +const ConnectedThreadSettingsHomeNotifs: React.ComponentType = + React.memo(function ConnectedThreadSettingsHomeNotifs( + props: BaseProps, + ) { const styles = useStyles(unboundStyles); const dispatchActionPromise = useDispatchActionPromise(); const callUpdateSubscription = useServerCall(updateSubscription); @@ -112,7 +114,6 @@ updateSubscription={callUpdateSubscription} /> ); - }, -); + }); export default ConnectedThreadSettingsHomeNotifs; diff --git a/native/chat/settings/thread-settings-leave-thread.react.js b/native/chat/settings/thread-settings-leave-thread.react.js --- a/native/chat/settings/thread-settings-leave-thread.react.js +++ b/native/chat/settings/thread-settings-leave-thread.react.js @@ -49,10 +49,8 @@ }; class ThreadSettingsLeaveThread extends React.PureComponent { render() { - const { - panelIosHighlightUnderlay, - panelForegroundSecondaryLabel, - } = this.props.colors; + const { panelIosHighlightUnderlay, panelForegroundSecondaryLabel } = + this.props.colors; const loadingIndicator = this.props.loadingStatus === 'loading' ? ( @@ -149,8 +147,10 @@ leaveThreadActionTypes, ); -const ConnectedThreadSettingsLeaveThread: React.ComponentType = React.memo( - function ConnectedThreadSettingsLeaveThread(props: BaseProps) { +const ConnectedThreadSettingsLeaveThread: React.ComponentType = + React.memo(function ConnectedThreadSettingsLeaveThread( + props: BaseProps, + ) { const loadingStatus = useSelector(loadingStatusSelector); const otherUsersButNoOtherAdminsValue = useSelector( otherUsersButNoOtherAdmins(props.threadInfo.id), @@ -172,7 +172,6 @@ navContext={navContext} /> ); - }, -); + }); export default ConnectedThreadSettingsLeaveThread; diff --git a/native/chat/settings/thread-settings-member.react.js b/native/chat/settings/thread-settings-member.react.js --- a/native/chat/settings/thread-settings-member.react.js +++ b/native/chat/settings/thread-settings-member.react.js @@ -249,8 +249,10 @@ }, }; -const ConnectedThreadSettingsMember: React.ComponentType = React.memo( - function ConnectedThreadSettingsMember(props: BaseProps) { +const ConnectedThreadSettingsMember: React.ComponentType = + React.memo(function ConnectedThreadSettingsMember( + props: BaseProps, + ) { const memberID = props.memberInfo.id; const removeUserLoadingStatus = useSelector(state => createLoadingStatusSelector( @@ -283,7 +285,6 @@ overlayContext={overlayContext} /> ); - }, -); + }); export default ConnectedThreadSettingsMember; diff --git a/native/chat/settings/thread-settings-name.react.js b/native/chat/settings/thread-settings-name.react.js --- a/native/chat/settings/thread-settings-name.react.js +++ b/native/chat/settings/thread-settings-name.react.js @@ -209,8 +209,8 @@ `${changeThreadSettingsActionTypes.started}:name`, ); -const ConnectedThreadSettingsName: React.ComponentType = React.memo( - function ConnectedThreadSettingsName(props: BaseProps) { +const ConnectedThreadSettingsName: React.ComponentType = + React.memo(function ConnectedThreadSettingsName(props: BaseProps) { const styles = useStyles(unboundStyles); const colors = useColors(); const loadingStatus = useSelector(loadingStatusSelector); @@ -228,7 +228,6 @@ changeThreadSettings={callChangeThreadSettings} /> ); - }, -); + }); export default ConnectedThreadSettingsName; diff --git a/native/chat/settings/thread-settings-parent.react.js b/native/chat/settings/thread-settings-parent.react.js --- a/native/chat/settings/thread-settings-parent.react.js +++ b/native/chat/settings/thread-settings-parent.react.js @@ -91,8 +91,7 @@ }, }; -const ConnectedThreadSettingsParent: React.ComponentType = React.memo( - ThreadSettingsParent, -); +const ConnectedThreadSettingsParent: React.ComponentType = + React.memo(ThreadSettingsParent); export default ConnectedThreadSettingsParent; diff --git a/native/chat/settings/thread-settings-promote-sidebar.react.js b/native/chat/settings/thread-settings-promote-sidebar.react.js --- a/native/chat/settings/thread-settings-promote-sidebar.react.js +++ b/native/chat/settings/thread-settings-promote-sidebar.react.js @@ -41,10 +41,8 @@ }; render() { - const { - panelIosHighlightUnderlay, - panelForegroundSecondaryLabel, - } = this.props.colors; + const { panelIosHighlightUnderlay, panelForegroundSecondaryLabel } = + this.props.colors; const loadingIndicator = this.props.loadingStatus === 'loading' ? ( @@ -89,8 +87,10 @@ }); }; -const ConnectedThreadSettingsPromoteSidebar: React.ComponentType = React.memo( - function ConnectedThreadSettingsPromoteSidebar(props: BaseProps) { +const ConnectedThreadSettingsPromoteSidebar: React.ComponentType = + React.memo(function ConnectedThreadSettingsPromoteSidebar( + props: BaseProps, + ) { const { threadInfo } = props; const colors = useColors(); const styles = useStyles(unboundStyles); @@ -108,7 +108,6 @@ loadingStatus={loading} /> ); - }, -); + }); export default ConnectedThreadSettingsPromoteSidebar; diff --git a/native/chat/settings/thread-settings-push-notifs.react.js b/native/chat/settings/thread-settings-push-notifs.react.js --- a/native/chat/settings/thread-settings-push-notifs.react.js +++ b/native/chat/settings/thread-settings-push-notifs.react.js @@ -155,8 +155,10 @@ }, }; -const ConnectedThreadSettingsPushNotifs: React.ComponentType = React.memo( - function ConnectedThreadSettingsPushNotifs(props: BaseProps) { +const ConnectedThreadSettingsPushNotifs: React.ComponentType = + React.memo(function ConnectedThreadSettingsPushNotifs( + props: BaseProps, + ) { const styles = useStyles(unboundStyles); const dispatchActionPromise = useDispatchActionPromise(); const callUpdateSubscription = useServerCall(updateSubscription); @@ -172,7 +174,6 @@ hasPushPermissions={hasPushPermissions} /> ); - }, -); + }); export default ConnectedThreadSettingsPushNotifs; diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js --- a/native/chat/settings/thread-settings.react.js +++ b/native/chat/settings/thread-settings.react.js @@ -675,9 +675,8 @@ const otherMemberID = getSingleOtherUser(threadInfo, viewerID); if (otherMemberID) { const otherUserInfo = userInfos[otherMemberID]; - const availableRelationshipActions = getAvailableRelationshipButtons( - otherUserInfo, - ); + const availableRelationshipActions = + getAvailableRelationshipButtons(otherUserInfo); for (const action of availableRelationshipActions) { buttons.push({ @@ -1039,8 +1038,8 @@ return false; }; -const ConnectedThreadSettings: React.ComponentType = React.memo( - function ConnectedThreadSettings(props: BaseProps) { +const ConnectedThreadSettings: React.ComponentType = + React.memo(function ConnectedThreadSettings(props: BaseProps) { const userInfos = useSelector(state => state.userStore.userInfos); const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, @@ -1082,9 +1081,8 @@ const parentThreadInfo: ?ThreadInfo = useSelector(state => parentThreadID ? threadInfoSelector(state)[parentThreadID] : null, ); - const resolvedParentThreadInfo = useResolvedOptionalThreadInfo( - parentThreadInfo, - ); + const resolvedParentThreadInfo = + useResolvedOptionalThreadInfo(parentThreadInfo); const threadMembers = threadInfo.members; const boundChildThreadInfos = useSelector( state => childThreadInfos(state)[threadID], @@ -1132,7 +1130,6 @@ canPromoteSidebar={canPromoteSidebar} /> ); - }, -); + }); export default ConnectedThreadSettings; diff --git a/native/chat/sidebar-list-modal.react.js b/native/chat/sidebar-list-modal.react.js --- a/native/chat/sidebar-list-modal.react.js +++ b/native/chat/sidebar-list-modal.react.js @@ -24,32 +24,27 @@ +route: NavigationRoute<'SidebarListModal'>, }; function SidebarListModal(props: Props): React.Node { - const { - listData, - searchState, - setSearchState, - onChangeSearchInputText, - } = useSearchSidebars(props.route.params.threadInfo); + const { listData, searchState, setSearchState, onChangeSearchInputText } = + useSearchSidebars(props.route.params.threadInfo); const numOfSidebarsWithExtendedArrow = listData.length - 1; const createRenderItem = React.useCallback( - ( - onPressItem: (threadInfo: ThreadInfo) => void, + (onPressItem: (threadInfo: ThreadInfo) => void) => // eslint-disable-next-line react/display-name - ) => (row: { +item: SidebarInfo, +index: number, ... }) => { - let extendArrow: boolean = false; - if (row.index < numOfSidebarsWithExtendedArrow) { - extendArrow = true; - } - return ( - - ); - }, + (row: { +item: SidebarInfo, +index: number, ... }) => { + let extendArrow: boolean = false; + if (row.index < numOfSidebarsWithExtendedArrow) { + extendArrow = true; + } + return ( + + ); + }, [numOfSidebarsWithExtendedArrow], ); @@ -75,10 +70,10 @@ const { item, onPressItem, extendArrow } = props; const { threadInfo } = item; - const onPressButton = React.useCallback(() => onPressItem(threadInfo), [ - onPressItem, - threadInfo, - ]); + const onPressButton = React.useCallback( + () => onPressItem(threadInfo), + [onPressItem, threadInfo], + ); const colors = useColors(); const styles = useStyles(unboundStyles); diff --git a/native/chat/subchannel-item.react.js b/native/chat/subchannel-item.react.js --- a/native/chat/subchannel-item.react.js +++ b/native/chat/subchannel-item.react.js @@ -16,11 +16,8 @@ +subchannelInfo: ChatThreadItem, }; function SubchannelItem(props: Props): React.Node { - const { - lastUpdatedTime, - threadInfo, - mostRecentMessageInfo, - } = props.subchannelInfo; + const { lastUpdatedTime, threadInfo, mostRecentMessageInfo } = + props.subchannelInfo; const { uiName } = useResolvedThreadInfo(threadInfo); const lastActivity = shortAbsoluteDate(lastUpdatedTime); diff --git a/native/chat/subchannels-list-modal.react.js b/native/chat/subchannels-list-modal.react.js --- a/native/chat/subchannels-list-modal.react.js +++ b/native/chat/subchannels-list-modal.react.js @@ -23,12 +23,8 @@ +route: NavigationRoute<'SubchannelsListModal'>, }; function SubchannelListModal(props: Props): React.Node { - const { - listData, - searchState, - setSearchState, - onChangeSearchInputText, - } = useSearchSubchannels(props.route.params.threadInfo); + const { listData, searchState, setSearchState, onChangeSearchInputText } = + useSearchSubchannels(props.route.params.threadInfo); return ( void, +const createRenderItem = + (onPressItem: (threadInfo: ThreadInfo) => void) => // eslint-disable-next-line react/display-name -) => (row: { +item: ChatThreadItem, +index: number, ... }) => { - return ; -}; + (row: { +item: ChatThreadItem, +index: number, ... }) => { + return ; + }; function Item(props: { onPressItem: (threadInfo: ThreadInfo) => void, @@ -58,10 +54,10 @@ const { onPressItem, subchannelInfo } = props; const { threadInfo } = subchannelInfo; - const onPressButton = React.useCallback(() => onPressItem(threadInfo), [ - onPressItem, - threadInfo, - ]); + const onPressButton = React.useCallback( + () => onPressItem(threadInfo), + [onPressItem, threadInfo], + ); const colors = useColors(); const styles = useStyles(unboundStyles); diff --git a/native/chat/swipeable-message.react.js b/native/chat/swipeable-message.react.js --- a/native/chat/swipeable-message.react.js +++ b/native/chat/swipeable-message.react.js @@ -77,12 +77,8 @@ function SwipeSnake( props: SwipeSnakeProps, ): React.Node { - const { - translateX, - isViewer, - opacityInterpolator, - translateXInterpolator, - } = props; + const { translateX, isViewer, opacityInterpolator, translateXInterpolator } = + props; const transformStyle = useAnimatedStyle(() => { const opacity = opacityInterpolator ? opacityInterpolator(translateX.value) diff --git a/native/chat/text-message-markdown-context.js b/native/chat/text-message-markdown-context.js --- a/native/chat/text-message-markdown-context.js +++ b/native/chat/text-message-markdown-context.js @@ -15,9 +15,8 @@ +markdownHasPressable: boolean, }; -const TextMessageMarkdownContext: React.Context = React.createContext( - null, -); +const TextMessageMarkdownContext: React.Context = + React.createContext(null); const pressableMarkdownTypes = new Set(['link', 'spoiler']); const markdownASTHasPressable = (node: ASTNode): boolean => { if (Array.isArray(node)) { diff --git a/native/chat/text-message-tooltip-button.react.js b/native/chat/text-message-tooltip-button.react.js --- a/native/chat/text-message-tooltip-button.react.js +++ b/native/chat/text-message-tooltip-button.react.js @@ -39,10 +39,8 @@ const windowWidth = useSelector(state => state.dimensions.width); - const [ - sidebarInputBarHeight, - setSidebarInputBarHeight, - ] = React.useState(null); + const [sidebarInputBarHeight, setSidebarInputBarHeight] = + React.useState(null); const onInputBarMeasured = React.useCallback((height: number) => { setSidebarInputBarHeight(height); }, []); diff --git a/native/chat/text-message.react.js b/native/chat/text-message.react.js --- a/native/chat/text-message.react.js +++ b/native/chat/text-message.react.js @@ -218,8 +218,8 @@ }; } -const ConnectedTextMessage: React.ComponentType = React.memo( - function ConnectedTextMessage(props: BaseProps) { +const ConnectedTextMessage: React.ComponentType = + React.memo(function ConnectedTextMessage(props: BaseProps) { const overlayContext = React.useContext(OverlayContext); const chatContext = React.useContext(ChatContext); const markdownContext = React.useContext(MarkdownContext); @@ -250,7 +250,6 @@ isLinkModalActive={isLinkModalActive} /> ); - }, -); + }); export { ConnectedTextMessage as TextMessage }; diff --git a/native/chat/thread-list-modal.react.js b/native/chat/thread-list-modal.react.js --- a/native/chat/thread-list-modal.react.js +++ b/native/chat/thread-list-modal.react.js @@ -35,9 +35,7 @@ type Props = { +threadInfo: ThreadInfo, - +createRenderItem: ( - onPressItem: (threadInfo: ThreadInfo) => void, - ) => (row: { + +createRenderItem: (onPressItem: (threadInfo: ThreadInfo) => void) => (row: { +item: U, +index: number, ... @@ -93,10 +91,10 @@ [navigateToThread, setSearchState], ); - const renderItem = React.useMemo(() => createRenderItem(onPressItem), [ - createRenderItem, - onPressItem, - ]); + const renderItem = React.useMemo( + () => createRenderItem(onPressItem), + [createRenderItem, onPressItem], + ); const styles = useStyles(unboundStyles); const indicatorStyle = useIndicatorStyle(); diff --git a/native/chat/thread-settings-button.react.js b/native/chat/thread-settings-button.react.js --- a/native/chat/thread-settings-button.react.js +++ b/native/chat/thread-settings-button.react.js @@ -45,12 +45,13 @@ }, }; -const ConnectedThreadSettingsButton: React.ComponentType = React.memo( - function ConnectedThreadSettingsButton(props: BaseProps) { +const ConnectedThreadSettingsButton: React.ComponentType = + React.memo(function ConnectedThreadSettingsButton( + props: BaseProps, + ) { const styles = useStyles(unboundStyles); return ; - }, -); + }); export default ConnectedThreadSettingsButton; diff --git a/native/chat/thread-settings-header-title.react.js b/native/chat/thread-settings-header-title.react.js --- a/native/chat/thread-settings-header-title.react.js +++ b/native/chat/thread-settings-header-title.react.js @@ -20,8 +20,7 @@ return {firstLine(uiName)}; } -const MemoizedThreadSettingsHeaderTitle: React.ComponentType = React.memo( - ThreadSettingsHeaderTitle, -); +const MemoizedThreadSettingsHeaderTitle: React.ComponentType = + React.memo(ThreadSettingsHeaderTitle); export default MemoizedThreadSettingsHeaderTitle; diff --git a/native/chat/utils.js b/native/chat/utils.js --- a/native/chat/utils.js +++ b/native/chat/utils.js @@ -124,10 +124,8 @@ threadInfo: sidebarThreadInfo, }); - const [ - messagesWithHeight, - setMessagesWithHeight, - ] = React.useState>(null); + const [messagesWithHeight, setMessagesWithHeight] = + React.useState>(null); const measureMessages = useHeightMeasurer(); React.useEffect(() => { @@ -242,17 +240,15 @@ setSidebarAnimationType(newSidebarAnimationType); }, [setSidebarAnimationType, newSidebarAnimationType]); - const { - position: targetPosition, - color: targetColor, - } = useMessageTargetParameters( - sourceMessage, - initialCoordinates, - messageListVerticalBounds, - currentInputBarHeight, - targetInputBarHeight ?? currentInputBarHeight, - sidebarThreadInfo, - ); + const { position: targetPosition, color: targetColor } = + useMessageTargetParameters( + sourceMessage, + initialCoordinates, + messageListVerticalBounds, + currentInputBarHeight, + targetInputBarHeight ?? currentInputBarHeight, + sidebarThreadInfo, + ); React.useEffect(() => { return () => setCurrentTransitionSidebarSourceID(null); @@ -268,10 +264,8 @@ [progress, targetPosition], ); - const [ - isThreadColorDarkOverride, - setThreadColorDarkOverride, - ] = React.useState(null); + const [isThreadColorDarkOverride, setThreadColorDarkOverride] = + React.useState(null); const setThreadColorBrightness = React.useCallback(() => { const isSourceThreadDark = colorIsDark(sourceMessage.threadInfo.color); const isTargetThreadDark = colorIsDark(targetColor); diff --git a/native/components/clearable-text-input.react.ios.js b/native/components/clearable-text-input.react.ios.js --- a/native/components/clearable-text-input.react.ios.js +++ b/native/components/clearable-text-input.react.ios.js @@ -104,15 +104,14 @@ } }; - textInputRef: ( - textInput: ?React.ElementRef, - ) => void = textInput => { - if (this.focused && textInput) { - textInput.focus(); - } - this.currentTextInput = textInput; - this.props.textInputRef(textInput); - }; + textInputRef: (textInput: ?React.ElementRef) => void = + textInput => { + if (this.focused && textInput) { + textInput.focus(); + } + this.currentTextInput = textInput; + this.props.textInputRef(textInput); + }; async getValueAndReset(): Promise { const { value } = this.props; diff --git a/native/components/clearable-text-input.react.js b/native/components/clearable-text-input.react.js --- a/native/components/clearable-text-input.react.js +++ b/native/components/clearable-text-input.react.js @@ -67,12 +67,11 @@ ); } - textInputRef: ( - textInput: ?React.ElementRef, - ) => void = textInput => { - this.textInput = textInput; - this.props.textInputRef(textInput); - }; + textInputRef: (textInput: ?React.ElementRef) => void = + textInput => { + this.textInput = textInput; + this.props.textInputRef(textInput); + }; } const styles = StyleSheet.create({ diff --git a/native/components/keyboard-avoiding-view.react.js b/native/components/keyboard-avoiding-view.react.js --- a/native/components/keyboard-avoiding-view.react.js +++ b/native/components/keyboard-avoiding-view.react.js @@ -29,14 +29,13 @@ +behavior: 'height' | 'position' | 'padding', +contentContainerStyle?: ?ViewStyle, }; -const KeyboardAvoidingView: React.ComponentType = React.memo( - function KeyboardAvoidingView(props: BaseProps) { +const KeyboardAvoidingView: React.ComponentType = + React.memo(function KeyboardAvoidingView(props: BaseProps) { const keyboardState = React.useContext(KeyboardContext); return ( ); - }, -); + }); type Props = { ...BaseProps, diff --git a/native/components/link-button.react.js b/native/components/link-button.react.js --- a/native/components/link-button.react.js +++ b/native/components/link-button.react.js @@ -49,12 +49,11 @@ }, }; -const ConnectedLinkButton: React.ComponentType = React.memo( - function ConnectedLinkButton(props: BaseProps) { +const ConnectedLinkButton: React.ComponentType = + React.memo(function ConnectedLinkButton(props: BaseProps) { const styles = useStyles(unboundStyles); return ; - }, -); + }); export default ConnectedLinkButton; diff --git a/native/components/node-height-measurer.react.js b/native/components/node-height-measurer.react.js --- a/native/components/node-height-measurer.react.js +++ b/native/components/node-height-measurer.react.js @@ -241,12 +241,8 @@ measuredHeights: Map, mustTrigger: boolean, ) { - const { - listData, - itemToID, - itemToMeasureKey, - allHeightsMeasured, - } = this.props; + const { listData, itemToID, itemToMeasureKey, allHeightsMeasured } = + this.props; if (!listData) { return; diff --git a/native/components/selectable-text-input.react.ios.js b/native/components/selectable-text-input.react.ios.js --- a/native/components/selectable-text-input.react.ios.js +++ b/native/components/selectable-text-input.react.ios.js @@ -28,9 +28,8 @@ // React Native doesn't handle controlled selection well, so we only set the // selection prop when we need to mutate the selection // https://github.com/facebook/react-native/issues/29063 - const [controlSelection, setControlSelection] = React.useState( - false, - ); + const [controlSelection, setControlSelection] = + React.useState(false); const clearableTextInputRefCallback = React.useCallback( (clearableTextInput: ?React.ElementRef) => { diff --git a/native/components/selectable-text-input.react.js b/native/components/selectable-text-input.react.js --- a/native/components/selectable-text-input.react.js +++ b/native/components/selectable-text-input.react.js @@ -25,9 +25,8 @@ // React Native doesn't handle controlled selection well, so we only set the // selection prop when we need to mutate the selection // https://github.com/facebook/react-native/issues/29063 - const [controlSelection, setControlSelection] = React.useState( - false, - ); + const [controlSelection, setControlSelection] = + React.useState(false); const clearableTextInputRefCallback = React.useCallback( (clearableTextInput: ?React.ElementRef) => { diff --git a/native/components/swipeable.js b/native/components/swipeable.js --- a/native/components/swipeable.js +++ b/native/components/swipeable.js @@ -98,8 +98,8 @@ }, }; -const ConnectedSwipeable: React.ComponentType = React.memo( - function ConnectedSwipeable(props: BaseProps) { +const ConnectedSwipeable: React.ComponentType = + React.memo(function ConnectedSwipeable(props: BaseProps) { const styles = useStyles(unboundStyles); const windowWidth = useSelector(state => state.dimensions.width); const colors = useColors(); @@ -112,7 +112,6 @@ colors={colors} /> ); - }, -); + }); export default ConnectedSwipeable; diff --git a/native/components/tag-input.react.js b/native/components/tag-input.react.js --- a/native/components/tag-input.react.js +++ b/native/components/tag-input.react.js @@ -303,17 +303,15 @@ ); } - tagInputRef: ( - tagInput: ?React.ElementRef, - ) => void = tagInput => { - this.tagInput = tagInput; - }; + tagInputRef: (tagInput: ?React.ElementRef) => void = + tagInput => { + this.tagInput = tagInput; + }; - scrollViewRef: ( - scrollView: ?React.ElementRef, - ) => void = scrollView => { - this.scrollView = scrollView; - }; + scrollViewRef: (scrollView: ?React.ElementRef) => void = + scrollView => { + this.scrollView = scrollView; + }; onScrollViewContentSizeChange: (w: number, h: number) => void = (w, h) => { const oldContentHeight = this.state.contentHeight; diff --git a/native/components/thread-list-thread.react.js b/native/components/thread-list-thread.react.js --- a/native/components/thread-list-thread.react.js +++ b/native/components/thread-list-thread.react.js @@ -65,8 +65,8 @@ }, }; -const ConnectedThreadListThread: React.ComponentType = React.memo( - function ConnectedThreadListThread(props: BaseProps) { +const ConnectedThreadListThread: React.ComponentType = + React.memo(function ConnectedThreadListThread(props: BaseProps) { const { threadInfo, ...rest } = props; const styles = useStyles(unboundStyles); const colors = useColors(); @@ -80,7 +80,6 @@ colors={colors} /> ); - }, -); + }); export default ConnectedThreadListThread; diff --git a/native/components/thread-list.react.js b/native/components/thread-list.react.js --- a/native/components/thread-list.react.js +++ b/native/components/thread-list.react.js @@ -137,15 +137,14 @@ }, }; -const ConnectedThreadList: React.ComponentType = React.memo( - function ConnectedThreadList(props: BaseProps) { +const ConnectedThreadList: React.ComponentType = + React.memo(function ConnectedThreadList(props: BaseProps) { const styles = useStyles(unboundStyles); const indicatorStyle = useIndicatorStyle(); return ( ); - }, -); + }); export default ConnectedThreadList; diff --git a/native/components/user-list-user.react.js b/native/components/user-list-user.react.js --- a/native/components/user-list-user.react.js +++ b/native/components/user-list-user.react.js @@ -83,12 +83,11 @@ }, }; -const ConnectedUserListUser: React.ComponentType = React.memo( - function ConnectedUserListUser(props: BaseProps) { +const ConnectedUserListUser: React.ComponentType = + React.memo(function ConnectedUserListUser(props: BaseProps) { const colors = useColors(); const styles = useStyles(unboundStyles); return ; - }, -); + }); export { ConnectedUserListUser as UserListUser, getUserListItemHeight }; diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js --- a/native/data/sqlite-data-handler.js +++ b/native/data/sqlite-data-handler.js @@ -145,14 +145,10 @@ (async () => { await sensitiveDataHandled; try { - const { - threads, - messages, - drafts, - } = await commCoreModule.getClientDBStore(); - const threadInfosFromDB = convertClientDBThreadInfosToRawThreadInfos( - threads, - ); + const { threads, messages, drafts } = + await commCoreModule.getClientDBStore(); + const threadInfosFromDB = + convertClientDBThreadInfosToRawThreadInfos(threads); dispatch({ type: setClientDBStoreActionType, payload: { diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js --- a/native/input/input-state-container.react.js +++ b/native/input/input-state-container.react.js @@ -800,10 +800,8 @@ const { uploadThumbnailURI } = processedMedia; cleanupPromises.push( (async () => { - const { - steps: clearSteps, - result: thumbnailPath, - } = await this.waitForCaptureURIUnload(uploadThumbnailURI); + const { steps: clearSteps, result: thumbnailPath } = + await this.waitForCaptureURIUnload(uploadThumbnailURI); steps.push(...clearSteps); if (!thumbnailPath) { return; @@ -825,10 +823,8 @@ const captureURI = selection.uri; cleanupPromises.push( (async () => { - const { - steps: clearSteps, - result: capturePath, - } = await this.waitForCaptureURIUnload(captureURI); + const { steps: clearSteps, result: capturePath } = + await this.waitForCaptureURIUnload(captureURI); steps.push(...clearSteps); if (!capturePath) { return; @@ -1379,8 +1375,10 @@ sendTextMessageActionTypes, ); -const ConnectedInputStateContainer: React.ComponentType = React.memo( - function ConnectedInputStateContainer(props: BaseProps) { +const ConnectedInputStateContainer: React.ComponentType = + React.memo(function ConnectedInputStateContainer( + props: BaseProps, + ) { const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, ); @@ -1425,7 +1423,6 @@ staffCanSee={staffCanSee} /> ); - }, -); + }); export default ConnectedInputStateContainer; diff --git a/native/input/input-state.js b/native/input/input-state.js --- a/native/input/input-state.js +++ b/native/input/input-state.js @@ -46,8 +46,7 @@ +reportURIDisplayed: (uri: string, loaded: boolean) => void, }; -const InputStateContext: React.Context = React.createContext( - null, -); +const InputStateContext: React.Context = + React.createContext(null); export { InputStateContext }; diff --git a/native/keyboard/keyboard-input-host.react.js b/native/keyboard/keyboard-input-host.react.js --- a/native/keyboard/keyboard-input-host.react.js +++ b/native/keyboard/keyboard-input-host.react.js @@ -98,8 +98,8 @@ }, }; -const ConnectedKeyboardInputHost: React.ComponentType = React.memo( - function ConnectedKeyboardInputHost(props: BaseProps) { +const ConnectedKeyboardInputHost: React.ComponentType = + React.memo(function ConnectedKeyboardInputHost(props: BaseProps) { const inputState = React.useContext(InputStateContext); const keyboardState = React.useContext(KeyboardContext); invariant(keyboardState, 'keyboardState should be initialized'); @@ -116,7 +116,6 @@ inputState={inputState} /> ); - }, -); + }); export default ConnectedKeyboardInputHost; diff --git a/native/keyboard/keyboard-state-container.react.js b/native/keyboard/keyboard-state-container.react.js --- a/native/keyboard/keyboard-state-container.react.js +++ b/native/keyboard/keyboard-state-container.react.js @@ -112,11 +112,8 @@ this.state.mediaGalleryThread; render(): React.Node { - const { - systemKeyboardShowing, - mediaGalleryOpen, - renderKeyboardInputHost, - } = this.state; + const { systemKeyboardShowing, mediaGalleryOpen, renderKeyboardInputHost } = + this.state; const { keyboardShowing, dismissKeyboard, diff --git a/native/keyboard/keyboard-state.js b/native/keyboard/keyboard-state.js --- a/native/keyboard/keyboard-state.js +++ b/native/keyboard/keyboard-state.js @@ -15,8 +15,7 @@ +getMediaGalleryThread: () => ?ThreadInfo, }; -const KeyboardContext: React.Context = React.createContext( - null, -); +const KeyboardContext: React.Context = + React.createContext(null); export { KeyboardContext }; diff --git a/native/markdown/markdown-context.js b/native/markdown/markdown-context.js --- a/native/markdown/markdown-context.js +++ b/native/markdown/markdown-context.js @@ -12,8 +12,7 @@ +clearMarkdownContextData: () => void, }; -const MarkdownContext: React.Context = React.createContext( - null, -); +const MarkdownContext: React.Context = + React.createContext(null); export { MarkdownContext }; diff --git a/native/markdown/markdown-spoiler-context.js b/native/markdown/markdown-spoiler-context.js --- a/native/markdown/markdown-spoiler-context.js +++ b/native/markdown/markdown-spoiler-context.js @@ -6,8 +6,7 @@ +isRevealed: boolean, }; -const MarkdownSpoilerContext: React.Context = React.createContext( - null, -); +const MarkdownSpoilerContext: React.Context = + React.createContext(null); export { MarkdownSpoilerContext }; diff --git a/native/media/blob-utils.js b/native/media/blob-utils.js --- a/native/media/blob-utils.js +++ b/native/media/blob-utils.js @@ -67,9 +67,7 @@ base64: string, mime: string, }; -async function fetchBlob( - inputURI: string, -): Promise<{ +async function fetchBlob(inputURI: string): Promise<{ steps: $ReadOnlyArray, result: MediaMissionFailure | FetchBlobResult, }> { diff --git a/native/media/camera-modal.react.js b/native/media/camera-modal.react.js --- a/native/media/camera-modal.react.js +++ b/native/media/camera-modal.react.js @@ -869,10 +869,8 @@ // actually have a back camera since it causes a bit of lag, but this // means there are cases where it is false but we are actually using the // front camera - const { - hasCamerasOnBothSides, - defaultUseFrontCamera, - } = this.props.deviceCameraInfo; + const { hasCamerasOnBothSides, defaultUseFrontCamera } = + this.props.deviceCameraInfo; const usingFrontCamera = this.state.useFrontCamera || (!hasCamerasOnBothSides && defaultUseFrontCamera); @@ -1181,8 +1179,8 @@ }, }); -const ConnectedCameraModal: React.ComponentType = React.memo( - function ConnectedCameraModal(props: BaseProps) { +const ConnectedCameraModal: React.ComponentType = + React.memo(function ConnectedCameraModal(props: BaseProps) { const dimensions = useSelector(state => state.dimensions); const deviceCameraInfo = useSelector(state => state.deviceCameraInfo); const deviceOrientation = useSelector(state => state.deviceOrientation); @@ -1203,7 +1201,6 @@ inputState={inputState} /> ); - }, -); + }); export default ConnectedCameraModal; diff --git a/native/media/file-utils.js b/native/media/file-utils.js --- a/native/media/file-utils.js +++ b/native/media/file-utils.js @@ -61,10 +61,8 @@ const inputPath = pathFromURI(inputURI); if (mediaNativeID && (!inputPath || optionalFields.orientation)) { assetInfoPromise = (async () => { - const { - steps: assetInfoSteps, - result: assetInfoResult, - } = await fetchAssetInfo(mediaNativeID); + const { steps: assetInfoSteps, result: assetInfoResult } = + await fetchAssetInfo(mediaNativeID); steps.push(...assetInfoSteps); newLocalURI = assetInfoResult.localURI; return assetInfoResult; @@ -128,10 +126,8 @@ if (!optionalFields.mediaType || !mime || !baseMediaType) { return { mime, mediaType: null }; } - const { - steps: getMediaTypeSteps, - result: mediaType, - } = await getMediaTypeInfo(path, mime, baseMediaType); + const { steps: getMediaTypeSteps, result: mediaType } = + await getMediaTypeInfo(path, mime, baseMediaType); steps.push(...getMediaTypeSteps); return { mime, mediaType }; })(); @@ -175,9 +171,7 @@ }; } -async function fetchAssetInfo( - mediaNativeID: string, -): Promise<{ +async function fetchAssetInfo(mediaNativeID: string): Promise<{ steps: $ReadOnlyArray, result: { localURI: ?string, orientation: ?number }, }> { @@ -216,9 +210,7 @@ }; } -async function fetchFileSize( - uri: string, -): Promise<{ +async function fetchFileSize(uri: string): Promise<{ steps: $ReadOnlyArray, result: ?number, }> { diff --git a/native/media/image-modal.react.js b/native/media/image-modal.react.js --- a/native/media/image-modal.react.js +++ b/native/media/image-modal.react.js @@ -1278,8 +1278,8 @@ }, }); -const ConnectedImageModal: React.ComponentType = React.memo( - function ConnectedImageModal(props: BaseProps) { +const ConnectedImageModal: React.ComponentType = + React.memo(function ConnectedImageModal(props: BaseProps) { const dimensions = useSelector(derivedDimensionsInfoSelector); const overlayContext = React.useContext(OverlayContext); const intentionalSaveMedia = useIntentionalSaveMedia(); @@ -1291,7 +1291,6 @@ intentionalSaveMedia={intentionalSaveMedia} /> ); - }, -); + }); export default ConnectedImageModal; diff --git a/native/media/image-utils.js b/native/media/image-utils.js --- a/native/media/image-utils.js +++ b/native/media/image-utils.js @@ -23,9 +23,7 @@ mime: string, dimensions: Dimensions, }; -async function processImage( - input: ProcessImageInfo, -): Promise<{ +async function processImage(input: ProcessImageInfo): Promise<{ steps: $ReadOnlyArray, result: MediaMissionFailure | ProcessImageResponse, }> { diff --git a/native/media/media-gallery-keyboard.react.js b/native/media/media-gallery-keyboard.react.js --- a/native/media/media-gallery-keyboard.react.js +++ b/native/media/media-gallery-keyboard.react.js @@ -194,16 +194,16 @@ if (!hasPermission) { return; } - const { - assets, - endCursor, - hasNextPage, - } = await MediaLibrary.getAssetsAsync({ - first: 20, - after, - mediaType: [MediaLibrary.MediaType.photo, MediaLibrary.MediaType.video], - sortBy: [MediaLibrary.SortBy.modificationTime], - }); + const { assets, endCursor, hasNextPage } = + await MediaLibrary.getAssetsAsync({ + first: 20, + after, + mediaType: [ + MediaLibrary.MediaType.photo, + MediaLibrary.MediaType.video, + ], + sortBy: [MediaLibrary.SortBy.modificationTime], + }); let firstRemoved = false, lastRemoved = false; diff --git a/native/media/media-utils.js b/native/media/media-utils.js --- a/native/media/media-utils.js +++ b/native/media/media-utils.js @@ -218,10 +218,8 @@ returnResult(); } - const { - steps: finalFileInfoSteps, - result: finalFileInfoResult, - } = await fetchFileInfo(uploadURI, undefined, { mime: true }); + const { steps: finalFileInfoSteps, result: finalFileInfoResult } = + await fetchFileInfo(uploadURI, undefined, { mime: true }); steps.push(...finalFileInfoSteps); if (!finalFileInfoResult.success) { return await finish(finalFileInfoResult); diff --git a/native/media/multimedia.react.js b/native/media/multimedia.react.js --- a/native/media/multimedia.react.js +++ b/native/media/multimedia.react.js @@ -142,11 +142,10 @@ }, }); -const ConnectedMultimedia: React.ComponentType = React.memo( - function ConnectedMultimedia(props: BaseProps) { +const ConnectedMultimedia: React.ComponentType = + React.memo(function ConnectedMultimedia(props: BaseProps) { const inputState = React.useContext(InputStateContext); return ; - }, -); + }); export default ConnectedMultimedia; diff --git a/native/media/remote-image.react.js b/native/media/remote-image.react.js --- a/native/media/remote-image.react.js +++ b/native/media/remote-image.react.js @@ -107,12 +107,11 @@ }, }); -const ConnectedRemoteImage: React.ComponentType = React.memo( - function ConnectedRemoteImage(props: BaseProps) { +const ConnectedRemoteImage: React.ComponentType = + React.memo(function ConnectedRemoteImage(props: BaseProps) { const connectionStatus = useSelector(state => state.connection.status); return ; - }, -); + }); export default ConnectedRemoteImage; diff --git a/native/media/save-media.js b/native/media/save-media.js --- a/native/media/save-media.js +++ b/native/media/save-media.js @@ -214,10 +214,8 @@ if (uri.startsWith('http')) { promises.push( (async () => { - const { - result: tempSaveResult, - steps: tempSaveSteps, - } = await saveRemoteMediaToDisk(uri, temporaryDirectoryPath); + const { result: tempSaveResult, steps: tempSaveSteps } = + await saveRemoteMediaToDisk(uri, temporaryDirectoryPath); steps.push(...tempSaveSteps); if (!tempSaveResult.success) { success = false; @@ -280,10 +278,8 @@ let uri = inputURI; let tempFile; if (uri.startsWith('http')) { - const { - result: tempSaveResult, - steps: tempSaveSteps, - } = await saveRemoteMediaToDisk(uri, temporaryDirectoryPath); + const { result: tempSaveResult, steps: tempSaveSteps } = + await saveRemoteMediaToDisk(uri, temporaryDirectoryPath); steps.push(...tempSaveSteps); if (!tempSaveResult.success) { sendResult(tempSaveResult); @@ -294,10 +290,8 @@ } else if (!uri.startsWith('file://')) { const mediaNativeID = getMediaLibraryIdentifier(uri); if (mediaNativeID) { - const { - result: fetchAssetInfoResult, - steps: fetchAssetInfoSteps, - } = await fetchAssetInfo(mediaNativeID); + const { result: fetchAssetInfoResult, steps: fetchAssetInfoSteps } = + await fetchAssetInfo(mediaNativeID); steps.push(...fetchAssetInfoSteps); const { localURI } = fetchAssetInfoResult; if (localURI) { diff --git a/native/media/send-media-button.react.js b/native/media/send-media-button.react.js --- a/native/media/send-media-button.react.js +++ b/native/media/send-media-button.react.js @@ -21,13 +21,8 @@ +style?: ViewStyle, }; function SendMediaButton(props: Props): React.Node { - const { - onPress, - queueCount, - containerStyle, - style, - ...containerProps - } = props; + const { onPress, queueCount, containerStyle, style, ...containerProps } = + props; let queueCountText = null; if (queueCount !== undefined && queueCount !== null) { diff --git a/native/media/video-playback-modal.react.js b/native/media/video-playback-modal.react.js --- a/native/media/video-playback-modal.react.js +++ b/native/media/video-playback-modal.react.js @@ -80,7 +80,8 @@ const closeButtonY = useValue(-1); const closeButtonWidth = useValue(-1); const closeButtonHeight = useValue(-1); - const closeButtonRef = React.useRef>(); + const closeButtonRef = + React.useRef>(); const closeButton = closeButtonRef.current; const onCloseButtonLayoutCalledRef = React.useRef(false); const onCloseButtonLayout = React.useCallback(() => { @@ -227,9 +228,10 @@ ); const previousOpacityCeiling = useValue(-1); - const opacityCeiling = React.useMemo(() => ceil(activeControlsOpacity), [ - activeControlsOpacity, - ]); + const opacityCeiling = React.useMemo( + () => ceil(activeControlsOpacity), + [activeControlsOpacity], + ); const opacityJustChanged = React.useMemo( () => @@ -329,14 +331,14 @@ imageHeight, ]); - const left = React.useMemo(() => sub(centerX, divide(imageWidth, 2)), [ - centerX, - imageWidth, - ]); - const top = React.useMemo(() => sub(centerY, divide(imageHeight, 2)), [ - centerY, - imageHeight, - ]); + const left = React.useMemo( + () => sub(centerX, divide(imageWidth, 2)), + [centerX, imageWidth], + ); + const top = React.useMemo( + () => sub(centerY, divide(imageHeight, 2)), + [centerY, imageHeight], + ); const { initialCoordinates } = props.route.params; @@ -385,10 +387,10 @@ () => [toggleControls, set(curBackdropOpacity, progressiveOpacity)], [curBackdropOpacity, progressiveOpacity, toggleControls], ); - const updatedScale = React.useMemo(() => [updates, curScale], [ - updates, - curScale, - ]); + const updatedScale = React.useMemo( + () => [updates, curScale], + [updates, curScale], + ); const updatedCurX = React.useMemo(() => [updates, curX], [updates, curX]); const updatedCurY = React.useMemo(() => [updates, curY], [updates, curY]); const updatedBackdropOpacity = React.useMemo( @@ -549,9 +551,10 @@