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<string, $ReadOnlyArray<number>>, messageInfos: $ReadOnlyArray<RawMessageInfo>, ) { - 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<FetchMessageInfosResult> { - 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<MediaMessageServerDBContent>, ): Promise<$ReadOnlyArray<Object>> { - 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<LogInResponse> { 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<string, RecalculatePermissionsMemberInfo> = + 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<MediaMessageServerDBContent>, containerID: string, ): Promise<void> { - 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<Investors> = _shuffle( - investorsData, -); +const shuffledInvestorsData: $ReadOnlyArray<Investors> = + _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<SubscriptionFormStatus>({ status: 'pending' }); + const [subscriptionFormStatus, setSubscriptionFormStatus] = + React.useState<SubscriptionFormStatus>({ 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<ActivityUpdate>, -) => Promise<ActivityUpdateSuccessPayload>) => async activityUpdates => { - const response = await callServerEndpoint('update_activity', { - updates: activityUpdates, - }); - return { - activityUpdates, - result: { - unfocusedToUnread: response.unfocusedToUnread, - }, +const updateActivity = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + activityUpdates: $ReadOnlyArray<ActivityUpdate>, + ) => Promise<ActivityUpdateSuccessPayload>) => + 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<SetThreadUnreadStatusPayload>) => 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<SetThreadUnreadStatusPayload>) => + 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<?string>) => async deviceToken => { - await callServerEndpoint('update_device_token', { - deviceToken, - platformDetails: getConfig().platformDetails, - }); - return deviceToken; -}; +const setDeviceToken = + ( + callServerEndpoint: CallServerEndpoint, + ): ((deviceToken: ?string) => Promise<?string>) => + 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<FetchEntryInfosResult>) => async calendarQuery => { - const response = await callServerEndpoint('fetch_entries', calendarQuery); - return { - rawEntryInfos: response.rawEntryInfos, +const fetchEntries = + ( + callServerEndpoint: CallServerEndpoint, + ): ((calendarQuery: CalendarQuery) => Promise<FetchEntryInfosResult>) => + 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<CalendarQueryUpdateResult>) => 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<CalendarQueryUpdateResult>) => + 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<CreateEntryPayload>) => 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<CreateEntryPayload>) => + 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<SaveEntryResult>) => 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<SaveEntryResult>) => + 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<DeleteEntryResult>) => 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<DeleteEntryResult>) => + 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<HistoryRevisionInfo>>) => async entryID => { - const response = await callServerEndpoint('fetch_entry_revisions', { - id: entryID, - }); - return response.result; -}; +const fetchRevisionsForEntry = + ( + callServerEndpoint: CallServerEndpoint, + ): ((entryID: string) => Promise<$ReadOnlyArray<HistoryRevisionInfo>>) => + 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<RestoreEntryResult>) => 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<RestoreEntryResult>) => + 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<FetchMessageInfosPayload>) => 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<FetchMessageInfosPayload>) => + 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<FetchMessageInfosPayload>) => 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<FetchMessageInfosPayload>) => + 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<string>, -) => Promise<SimpleMessagesPayload>) => 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<string>) => Promise<SimpleMessagesPayload>) => + 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<SendMessageResult>) => 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<SendMessageResult>) => + 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<MediaMessageServerDBContent>, -) => Promise<SendMessageResult>) => async ( - threadID, - localID, - mediaMessageContents, -) => { - let resultInfo; - const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { - resultInfo = passedResultInfo; +const sendMultimediaMessage = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + threadID: string, + localID: string, + mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent>, + ) => Promise<SendMessageResult>) => + 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<string>, -) => Promise<SendMessageResult>) => 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<string>, + ) => Promise<SendMessageResult>) => + 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<SendMessageResult>) => async request => { - let resultInfo; - const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { - resultInfo = passedResultInfo; - }; +const sendReactionMessage = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: SendReactionMessageRequest) => Promise<SendMessageResult>) => + 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<MessageReportCreationResult>) => async request => { - return await callServerEndpoint('create_message_report', request); -}; +const sendMessageReport = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + request: MessageReportCreationRequest, + ) => Promise<MessageReportCreationResult>) => + 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<RelationshipErrors>) => async request => { - const errors = await callServerEndpoint('update_relationships', request); +const updateRelationships = + ( + callServerEndpoint: CallServerEndpoint, + ): ((request: RelationshipRequest) => Promise<RelationshipErrors>) => + 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<ReportCreationResponse>) => async request => { - const response = await callServerEndpoint( - 'create_report', - request, - callServerEndpointOptions, - ); - return { id: response.id }; -}; +const sendReport = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + request: ClientReportCreationRequest, + ) => Promise<ReportCreationResponse>) => + 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<ClientReportCreationRequest>, -) => Promise<void>) => async reports => { - await callServerEndpoint( - 'create_reports', - { reports }, - callServerEndpointOptions, - ); -}; +const sendReports = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + reports: $ReadOnlyArray<ClientReportCreationRequest>, + ) => Promise<void>) => + 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<string>) => async () => { - const response = await callServerEndpoint('siwe_nonce'); - return response.nonce; -}; +const getSIWENonce = + (callServerEndpoint: CallServerEndpoint): (() => Promise<string>) => + 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<LogInResult>) => 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<LogInResult>) => + 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<LeaveThreadPayload>) => 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<LeaveThreadPayload>) => + 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<ChangeThreadSettingsPayload>) => 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<ChangeThreadSettingsPayload>) => + 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<string>, -) => Promise<ChangeThreadSettingsPayload>) => 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<string>, + ) => Promise<ChangeThreadSettingsPayload>) => + 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<string>, - newRole: string, -) => Promise<ChangeThreadSettingsPayload>) => 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<string>, + newRole: string, + ) => Promise<ChangeThreadSettingsPayload>) => + 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<NewThreadResult>) => 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<NewThreadResult>) => + 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<ThreadJoinPayload>) => 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<ThreadJoinPayload>) => + 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<LeaveThreadPayload>) => async threadID => { - const response = await callServerEndpoint('leave_thread', { threadID }); - return { - updatesResult: response.updatesResult, +const leaveThread = + ( + callServerEndpoint: CallServerEndpoint, + ): ((threadID: string) => Promise<LeaveThreadPayload>) => + 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<UploadMultimediaResult>) => 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<UploadMultimediaResult>) => + 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<void>) => async id => { - await callServerEndpoint('delete_upload', { id }); -}; +const deleteUpload = + (callServerEndpoint: CallServerEndpoint): ((id: string) => Promise<void>) => + 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<LogOutResult>) => 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<LogOutResult>) => + 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<LogOutResult>) => async (password, preRequestUserState) => { - const response = await callServerEndpoint('delete_account', { password }); - return { currentUserInfo: response.currentUserInfo, preRequestUserState }; -}; +const deleteAccount = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + password: ?string, + preRequestUserState: PreRequestUserState, + ) => Promise<LogOutResult>) => + 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<RegisterResult>) => 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<RegisterResult>) => + 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<LogInResult>) => 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<LogInResult>) => + 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<void>) => async passwordUpdate => { - await callServerEndpoint('update_account', passwordUpdate); -}; +const changeUserPassword = + ( + callServerEndpoint: CallServerEndpoint, + ): ((passwordUpdate: PasswordUpdate) => Promise<void>) => + 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<UserSearchResult>) => async usernamePrefix => { - const response = await callServerEndpoint('search_users', { - prefix: usernamePrefix, - }); - return { - userInfos: response.userInfos, +const searchUsers = + ( + callServerEndpoint: CallServerEndpoint, + ): ((usernamePrefix: string) => Promise<UserSearchResult>) => + 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<SubscriptionUpdateResult>) => async subscriptionUpdate => { - const response = await callServerEndpoint( - 'update_user_subscription', - subscriptionUpdate, - ); - return { - threadID: subscriptionUpdate.threadID, - subscription: response.threadSubscription, +const updateSubscription = + ( + callServerEndpoint: CallServerEndpoint, + ): (( + subscriptionUpdate: SubscriptionUpdateRequest, + ) => Promise<SubscriptionUpdateResult>) => + 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<void>) => async userSettingsRequest => { - await callServerEndpoint('update_user_settings', userSettingsRequest); -}; +const setUserSettings = + ( + callServerEndpoint: CallServerEndpoint, + ): ((userSettingsRequest: UpdateUserSettingsRequest) => Promise<void>) => + async userSettingsRequest => { + await callServerEndpoint('update_user_settings', userSettingsRequest); + }; -const getSessionPublicKeys = ( - callServerEndpoint: CallServerEndpoint, -): (( - data: GetSessionPublicKeysArgs, -) => Promise<SessionPublicKeys | null>) => async data => { - return await callServerEndpoint('get_session_public_keys', data); -}; +const getSessionPublicKeys = + ( + callServerEndpoint: CallServerEndpoint, + ): ((data: GetSessionPublicKeysArgs) => Promise<SessionPublicKeys | null>) => + 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<void>) => async policyRequest => { - await callServerEndpoint('policy_acknowledgment', policyRequest); -}; +const policyAcknowledgment = + ( + callServerEndpoint: CallServerEndpoint, + ): ((policyRequest: PolicyAcknowledgmentRequest) => Promise<void>) => + 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(() => <p>{emojiAvatar.emoji}</p>, [ - emojiAvatar.emoji, - ]); + const emojiAvatarView = React.useMemo( + () => <p>{emojiAvatar.emoji}</p>, + [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<ENSCacheContextType> = React.createContext<ENSCacheContextType>( - defaultContext, -); +const ENSCacheContext: React.Context<ENSCacheContextType> = + React.createContext<ENSCacheContextType>(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<?ModalContextType> = React.createContext<?ModalContextType>( - { +const ModalContext: React.Context<?ModalContextType> = + React.createContext<?ModalContextType>({ 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<DisconnectedBarCause>( - 'connecting', - ); + const [barCause, setBarCause] = + React.useState<DisconnectedBarCause>('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<CalendarFilter>) => - !filterExists(calendarFilters, calendarThreadFilterTypes.NOT_DELETED), -); +const includeDeletedSelector: (state: BaseAppState<*>) => boolean = + createSelector( + (state: BaseAppState<*>) => state.calendarFilters, + (calendarFilters: $ReadOnlyArray<CalendarFilter>) => + !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<ChatThreadItem> = createSelector( - threadInfoSelector, - (state: BaseAppState<*>) => state.messageStore, - messageInfoSelector, - sidebarInfoSelector, - ( - threadInfos: { +[id: string]: ThreadInfo }, - messageStore: MessageStore, - messageInfos: { +[id: string]: ?MessageInfo }, - sidebarInfos: { +[id: string]: $ReadOnlyArray<SidebarInfo> }, - ): $ReadOnlyArray<ChatThreadItem> => - getChatThreadItems( - threadInfos, - messageStore, - messageInfos, - sidebarInfos, - threadIsTopLevel, - ), -); +const chatListData: (state: BaseAppState<*>) => $ReadOnlyArray<ChatThreadItem> = + createSelector( + threadInfoSelector, + (state: BaseAppState<*>) => state.messageStore, + messageInfoSelector, + sidebarInfoSelector, + ( + threadInfos: { +[id: string]: ThreadInfo }, + messageStore: MessageStore, + messageInfos: { +[id: string]: ?MessageInfo }, + sidebarInfos: { +[id: string]: $ReadOnlyArray<SidebarInfo> }, + ): $ReadOnlyArray<ChatThreadItem> => + getChatThreadItems( + threadInfos, + messageStore, + messageInfos, + sidebarInfos, + threadIsTopLevel, + ), + ); function useFlattenedChatListData(): $ReadOnlyArray<ChatThreadItem> { return useFilteredChatListData(threadInChatList); @@ -409,43 +408,41 @@ ? threadInfoFromSourceMessageID[messageInfo.id] : undefined; - const renderedReactions: $ReadOnlyMap< - string, - MessageReactionInfo, - > = (() => { - const result = new Map<string, MessageReactionInfo>(); - - let messageReactsMap; - if (originalMessageInfo.id) { - messageReactsMap = targetMessageReactionsMap.get( - originalMessageInfo.id, - ); - } - - if (!messageReactsMap) { - return result; - } + const renderedReactions: $ReadOnlyMap<string, MessageReactionInfo> = + (() => { + const result = new Map<string, MessageReactionInfo>(); - 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<MessageInfo>, -) => (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<ClientServerRequest>, - ): $ReadOnlyArray<ClientClientResponse> => { - 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<ClientServerRequest>, + ): $ReadOnlyArray<ClientClientResponse> => { + 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<ThreadInfo> } = createSelector( +const childThreadInfos: (state: BaseAppState<*>) => { + +[id: string]: $ReadOnlyArray<ThreadInfo>, +} = createSelector( threadInfoSelector, (threadInfos: { +[id: string]: ThreadInfo }) => { const result = {}; @@ -207,9 +207,9 @@ return null; } -const sidebarInfoSelector: ( - state: BaseAppState<*>, -) => { +[id: string]: $ReadOnlyArray<SidebarInfo> } = createObjectSelector( +const sidebarInfoSelector: (state: BaseAppState<*>) => { + +[id: string]: $ReadOnlyArray<SidebarInfo>, +} = createObjectSelector( childThreadInfos, (state: BaseAppState<*>) => state.messageStore, (childThreads: $ReadOnlyArray<ThreadInfo>, 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<RawEntryInfo>, -): { +[id: string]: RawEntryInfo } { +function serverEntryInfosObject(array: $ReadOnlyArray<RawEntryInfo>): { + +[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<BaseProps> = React.memo<BaseProps>( - function ConnectedAPIRequestHandler(props) { +const ConnectedAPIRequestHandler: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedAPIRequestHandler(props) { const connection = useSelector(state => state.connection); return <APIRequestHandler {...props} connection={connection} />; - }, -); + }); 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<BaseProps> = React.memo<BaseProps>( - function ConnectedCalendarQueryHandler(props) { +const ConnectedCalendarQueryHandler: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedReportHandler(props) { +const ConnectedReportHandler: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedRequestResponseHandler(props) { +const ConnectedRequestResponseHandler: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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 @@ -186,6 +186,5 @@ export type NotificationTypes = $Values<typeof notificationTypes>; -export const notificationTypeValues: $ReadOnlyArray<NotificationTypes> = values( - notificationTypes, -); +export const notificationTypeValues: $ReadOnlyArray<NotificationTypes> = + 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<typeof relationshipActions>; -export const relationshipActionsList: $ReadOnlyArray<RelationshipAction> = values( - relationshipActions, -); +export const relationshipActionsList: $ReadOnlyArray<RelationshipAction> = + 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<Object, Object> = + 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 = <F>( ActionFunc<F>, ) => BindServerCallsParams => F; -const createBoundServerCallsSelector: CreateBoundServerCallsSelectorType = (_memoize( - baseCreateBoundServerCallsSelector, -): any); +const createBoundServerCallsSelector: CreateBoundServerCallsSelectorType = + (_memoize(baseCreateBoundServerCallsSelector): any); function useServerCall<F>(serverCall: ActionFunc<F>): 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<CallServerEndpointResponse> => { - 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<CallServerEndpointResponse> => { + 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<MediaMessageServerDBContent> = JSON.parse( - clientDBMessageInfo.content, - ); + const messageContent: $ReadOnlyArray<MediaMessageServerDBContent> = + 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 @@ -350,8 +350,8 @@ const loadingStatusSelector = createLoadingStatusSelector(logInActionTypes); -const ConnectedLogInPanel: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedLogInPanel(props: BaseProps) { +const ConnectedLogInPanel: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedLogInPanel(props: BaseProps) { const loadingStatus = useSelector(loadingStatusSelector); const navContext = React.useContext(NavContext); @@ -374,7 +374,6 @@ logIn={callLogIn} /> ); - }, -); + }); 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 @@ -443,8 +443,8 @@ const loadingStatusSelector = createLoadingStatusSelector(registerActionTypes); -const ConnectedRegisterPanel: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedRegisterPanel(props: BaseProps) { +const ConnectedRegisterPanel: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedRegisterPanel(props: BaseProps) { const loadingStatus = useSelector(loadingStatusSelector); const navContext = React.useContext(NavContext); @@ -467,7 +467,6 @@ register={callRegister} /> ); - }, -); + }); 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<?string>(null); - const [ - primaryIdentityPublicKey, - setPrimaryIdentityPublicKey, - ] = React.useState<?string>(null); + const [primaryIdentityPublicKey, setPrimaryIdentityPublicKey] = + React.useState<?string>(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<typeof BaseTextInput>, - ) => void = textInput => { - this.textInput = textInput; - if (textInput && this.state.editing) { - this.enterEditMode(); - } - }; + textInputRef: (textInput: ?React.ElementRef<typeof BaseTextInput>) => void = + textInput => { + this.textInput = textInput; + if (textInput && this.state.editing) { + this.enterEditMode(); + } + }; enterEditMode: () => Promise<void> = 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<BaseProps> = React.memo<BaseProps>( - function ConnectedSectionFooter(props: BaseProps) { +const ConnectedSectionFooter: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedSectionFooter(props: BaseProps) { const styles = useStyles(unboundStyles); const colors = useColors(); return <SectionFooter {...props} styles={styles} colors={colors} />; - }, -); + }); 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<SidebarAnimationType>('move_source_message'); + const [sidebarAnimationType, setSidebarAnimationType] = + React.useState<SidebarAnimationType>('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<StackHeaderProps> = React.memo<StackHeaderProps>( - function ChatHeader(props: StackHeaderProps) { +const ChatHeader: React.ComponentType<StackHeaderProps> = + React.memo<StackHeaderProps>(function ChatHeader(props: StackHeaderProps) { const navContext = React.useContext(NavContext); const activeTab = activeTabSelector(navContext); return <Header {...props} activeTab={activeTab} />; - }, -); + }); 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<ChatInputBarProps> = React.memo<ChatInputBarProps>( - function ConnectedChatInputBar(props: ChatInputBarProps) { +const ConnectedChatInputBar: React.ComponentType<ChatInputBarProps> = + React.memo<ChatInputBarProps>(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<Props> = React.memo<Props>( - ChatItemHeightMeasurer, -); +const MemoizedChatItemHeightMeasurer: React.ComponentType<Props> = + React.memo<Props>(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 ( <Button diff --git a/native/chat/chat-thread-list.react.js b/native/chat/chat-thread-list.react.js --- a/native/chat/chat-thread-list.react.js +++ b/native/chat/chat-thread-list.react.js @@ -155,13 +155,11 @@ }, ); - const chatNavigation: ?ChatNavigationProp< - 'ChatThreadList', - > = this.props.navigation.getParent(); + const chatNavigation: ?ChatNavigationProp<'ChatThreadList'> = + this.props.navigation.getParent(); invariant(chatNavigation, 'ChatNavigator should be within TabNavigator'); - const tabNavigation: ?TabNavigationProp< - 'Chat', - > = chatNavigation.getParent(); + const tabNavigation: ?TabNavigationProp<'Chat'> = + chatNavigation.getParent(); invariant(tabNavigation, 'ChatNavigator should be within TabNavigator'); tabNavigation.addListener('tabPress', this.onTabPress); @@ -171,13 +169,11 @@ componentWillUnmount() { this.clearNavigationBlurListener && this.clearNavigationBlurListener(); - const chatNavigation: ?ChatNavigationProp< - 'ChatThreadList', - > = this.props.navigation.getParent(); + const chatNavigation: ?ChatNavigationProp<'ChatThreadList'> = + this.props.navigation.getParent(); invariant(chatNavigation, 'ChatNavigator should be within TabNavigator'); - const tabNavigation: ?TabNavigationProp< - 'Chat', - > = chatNavigation.getParent(); + const tabNavigation: ?TabNavigationProp<'Chat'> = + chatNavigation.getParent(); invariant(tabNavigation, 'ChatNavigator should be within TabNavigator'); tabNavigation.removeListener('tabPress', this.onTabPress); @@ -612,8 +608,8 @@ }, }; -const ConnectedChatThreadList: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedChatThreadList(props: BaseProps) { +const ConnectedChatThreadList: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedChatThreadList(props: BaseProps) { const boundChatListData = useFlattenedChatListData(); const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, @@ -641,7 +637,6 @@ navigateToThread={navigateToThread} /> ); - }, -); + }); export default ConnectedChatThreadList; diff --git a/native/chat/compose-subchannel.react.js b/native/chat/compose-subchannel.react.js --- a/native/chat/compose-subchannel.react.js +++ b/native/chat/compose-subchannel.react.js @@ -63,9 +63,8 @@ const [userInfoInputArray, setUserInfoInputArray] = React.useState< $ReadOnlyArray<AccountUserInfo>, >([]); - const [createButtonEnabled, setCreateButtonEnabled] = React.useState<boolean>( - true, - ); + const [createButtonEnabled, setCreateButtonEnabled] = + React.useState<boolean>(true); const tagInputRef = React.useRef(); const onUnknownErrorAlertAcknowledged = React.useCallback(() => { @@ -381,8 +380,7 @@ }, }; -const MemoizedComposeSubchannel: React.ComponentType<Props> = React.memo<Props>( - ComposeSubchannel, -); +const MemoizedComposeSubchannel: React.ComponentType<Props> = + React.memo<Props>(ComposeSubchannel); export default MemoizedComposeSubchannel; diff --git a/native/chat/compose-thread-button.react.js b/native/chat/compose-thread-button.react.js --- a/native/chat/compose-thread-button.react.js +++ b/native/chat/compose-thread-button.react.js @@ -58,8 +58,8 @@ }, }); -const ConnectedComposeThreadButton: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedComposeThreadButton(props) { +const ConnectedComposeThreadButton: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedComposeThreadButton(props) { const colors = useColors(); const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, @@ -68,7 +68,6 @@ return ( <ComposeThreadButton {...props} colors={colors} viewerID={viewerID} /> ); - }, -); + }); export default ConnectedComposeThreadButton; diff --git a/native/chat/composed-message.react.js b/native/chat/composed-message.react.js --- a/native/chat/composed-message.react.js +++ b/native/chat/composed-message.react.js @@ -222,8 +222,8 @@ }, }); -const ConnectedComposedMessage: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedComposedMessage(props: BaseProps) { +const ConnectedComposedMessage: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedComposedMessage(props: BaseProps) { const composedMessageMaxWidth = useComposedMessageMaxWidth(); const colors = useColors(); const inputState = React.useContext(InputStateContext); @@ -241,7 +241,6 @@ deliveryIconOpacity={deliveryIconOpacity} /> ); - }, -); + }); export default ConnectedComposedMessage; diff --git a/native/chat/failed-send.react.js b/native/chat/failed-send.react.js --- a/native/chat/failed-send.react.js +++ b/native/chat/failed-send.react.js @@ -147,8 +147,8 @@ }, }; -const ConnectedFailedSend: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedFailedSend(props: BaseProps) { +const ConnectedFailedSend: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedFailedSend(props: BaseProps) { const id = messageID(props.item.messageInfo); const rawMessageInfo = useSelector(state => { const message = state.messageStore.messages[id]; @@ -164,7 +164,6 @@ inputState={inputState} /> ); - }, -); + }); export { ConnectedFailedSend as FailedSend, failedSendHeight }; diff --git a/native/chat/inline-engagement.react.js b/native/chat/inline-engagement.react.js --- a/native/chat/inline-engagement.react.js +++ b/native/chat/inline-engagement.react.js @@ -41,10 +41,10 @@ const styles = useStyles(unboundStyles); const unreadStyle = threadInfo?.currentUser.unread ? styles.unread : null; - const repliesStyles = React.useMemo(() => [styles.repliesText, unreadStyle], [ - styles.repliesText, - unreadStyle, - ]); + const repliesStyles = React.useMemo( + () => [styles.repliesText, unreadStyle], + [styles.repliesText, unreadStyle], + ); const onPressThread = React.useCallback(() => { if (threadInfo && !disabled) { diff --git a/native/chat/inner-robotext-message.react.js b/native/chat/inner-robotext-message.react.js --- a/native/chat/inner-robotext-message.react.js +++ b/native/chat/inner-robotext-message.react.js @@ -137,9 +137,8 @@ }, }; -const MemoizedInnerRobotextMessage: React.ComponentType<InnerRobotextMessageProps> = React.memo<InnerRobotextMessageProps>( - InnerRobotextMessage, -); +const MemoizedInnerRobotextMessage: React.ComponentType<InnerRobotextMessageProps> = + React.memo<InnerRobotextMessageProps>(InnerRobotextMessage); export { dummyNodeForRobotextMessageHeightMeasurement, diff --git a/native/chat/message-list-container.react.js b/native/chat/message-list-container.react.js --- a/native/chat/message-list-container.react.js +++ b/native/chat/message-list-container.react.js @@ -222,8 +222,10 @@ }, }; -const ConnectedMessageListContainer: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedMessageListContainer(props: BaseProps) { +const ConnectedMessageListContainer: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedMessageListContainer( + props: BaseProps, + ) { const [usernameInputText, setUsernameInputText] = React.useState(''); const [userInfoInputArray, setUserInfoInputArray] = React.useState< $ReadOnlyArray<AccountUserInfo>, @@ -246,9 +248,8 @@ props.route.params.threadInfo, ); - const existingThreadInfoFinder = useExistingThreadInfoFinder( - baseThreadInfo, - ); + const existingThreadInfoFinder = + useExistingThreadInfoFinder(baseThreadInfo); const isSearching = !!props.route.params.searching; const threadInfo = React.useMemo( @@ -357,7 +358,6 @@ /> </MessageListContextProvider> ); - }, -); + }); export default ConnectedMessageListContainer; diff --git a/native/chat/message-list-header-title.react.js b/native/chat/message-list-header-title.react.js --- a/native/chat/message-list-header-title.react.js +++ b/native/chat/message-list-header-title.react.js @@ -103,8 +103,10 @@ }, }; -const ConnectedMessageListHeaderTitle: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedMessageListHeaderTitle(props: BaseProps) { +const ConnectedMessageListHeaderTitle: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedMessageListHeaderTitle( + props: BaseProps, + ) { const styles = useStyles(unboundStyles); const { uiName } = useResolvedThreadInfo(props.threadInfo); @@ -112,7 +114,6 @@ const title = isSearchEmpty ? 'New Message' : uiName; return <MessageListHeaderTitle {...props} styles={styles} title={title} />; - }, -); + }); export default ConnectedMessageListHeaderTitle; diff --git a/native/chat/message-list-types.js b/native/chat/message-list-types.js --- a/native/chat/message-list-types.js +++ b/native/chat/message-list-types.js @@ -21,7 +21,8 @@ +getTextMessageMarkdownRules: (useDarkStyle: boolean) => MarkdownRules, }; -const MessageListContext: React.Context<?MessageListContextType> = React.createContext<?MessageListContextType>(); +const MessageListContext: React.Context<?MessageListContextType> = + React.createContext<?MessageListContextType>(); function useMessageListContext(threadID: ?string) { const getTextMessageMarkdownRules = useTextMessageRulesFunc(threadID); diff --git a/native/chat/message-list.react.js b/native/chat/message-list.react.js --- a/native/chat/message-list.react.js +++ b/native/chat/message-list.react.js @@ -182,12 +182,8 @@ ); } const messageInfoItem: ChatMessageInfoItemWithHeight = row.item; - const { - messageListVerticalBounds, - focusedMessageKey, - navigation, - route, - } = this.flatListExtraData; + const { messageListVerticalBounds, focusedMessageKey, navigation, route } = + this.flatListExtraData; const focused = messageKey(messageInfoItem.messageInfo) === focusedMessageKey; return ( @@ -340,8 +336,8 @@ registerFetchKey(fetchMessagesBeforeCursorActionTypes); registerFetchKey(fetchMostRecentMessagesActionTypes); -const ConnectedMessageList: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedMessageList(props: BaseProps) { +const ConnectedMessageList: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedMessageList(props: BaseProps) { const keyboardState = React.useContext(KeyboardContext); const overlayContext = React.useContext(OverlayContext); @@ -378,7 +374,6 @@ keyboardState={keyboardState} /> ); - }, -); + }); export default ConnectedMessageList; diff --git a/native/chat/message-press-responder-context.js b/native/chat/message-press-responder-context.js --- a/native/chat/message-press-responder-context.js +++ b/native/chat/message-press-responder-context.js @@ -6,8 +6,7 @@ +onPressMessage: () => void, }; -const MessagePressResponderContext: React.Context<?MessagePressResponderContextType> = React.createContext<?MessagePressResponderContextType>( - null, -); +const MessagePressResponderContext: React.Context<?MessagePressResponderContextType> = + React.createContext<?MessagePressResponderContextType>(null); export { MessagePressResponderContext }; diff --git a/native/chat/multimedia-message-multimedia.react.js b/native/chat/multimedia-message-multimedia.react.js --- a/native/chat/multimedia-message-multimedia.react.js +++ b/native/chat/multimedia-message-multimedia.react.js @@ -118,9 +118,8 @@ const overlayPosition = MultimediaMessageMultimedia.getModalOverlayPosition( this.props, ); - const prevOverlayPosition = MultimediaMessageMultimedia.getModalOverlayPosition( - prevProps, - ); + const prevOverlayPosition = + MultimediaMessageMultimedia.getModalOverlayPosition(prevProps); if (overlayPosition !== prevOverlayPosition) { this.setState({ opacity: this.getOpacity() }); } @@ -218,8 +217,10 @@ }, }); -const ConnectedMultimediaMessageMultimedia: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedMultimediaMessageMultimedia(props: BaseProps) { +const ConnectedMultimediaMessageMultimedia: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedMultimediaMessageMultimedia( + props: BaseProps, + ) { const colors = useColors(); const keyboardState = React.useContext(KeyboardContext); const overlayContext = React.useContext(OverlayContext); @@ -233,7 +234,6 @@ overlayContext={overlayContext} /> ); - }, -); + }); export default ConnectedMultimediaMessageMultimedia; diff --git a/native/chat/multimedia-message-tooltip-button.react.js b/native/chat/multimedia-message-tooltip-button.react.js --- a/native/chat/multimedia-message-tooltip-button.react.js +++ b/native/chat/multimedia-message-tooltip-button.react.js @@ -39,10 +39,8 @@ const windowWidth = useSelector(state => state.dimensions.width); - const [ - sidebarInputBarHeight, - setSidebarInputBarHeight, - ] = React.useState<?number>(null); + const [sidebarInputBarHeight, setSidebarInputBarHeight] = + React.useState<?number>(null); const onInputBarMeasured = React.useCallback((height: number) => { setSidebarInputBarHeight(height); }, []); diff --git a/native/chat/multimedia-message.react.js b/native/chat/multimedia-message.react.js --- a/native/chat/multimedia-message.react.js +++ b/native/chat/multimedia-message.react.js @@ -225,8 +225,8 @@ }, }); -const ConnectedMultimediaMessage: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedMultimediaMessage(props: BaseProps) { +const ConnectedMultimediaMessage: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedMultimediaMessage(props: BaseProps) { const navigation = useNavigation(); const route = useRoute(); const overlayContext = React.useContext(OverlayContext); @@ -246,7 +246,6 @@ canCreateSidebarFromMessage={canCreateSidebarFromMessage} /> ); - }, -); + }); export default ConnectedMultimediaMessage; diff --git a/native/chat/new-messages-pill.react.js b/native/chat/new-messages-pill.react.js --- a/native/chat/new-messages-pill.react.js +++ b/native/chat/new-messages-pill.react.js @@ -15,13 +15,8 @@ ...React.ElementConfig<typeof View>, }; function NewMessagesPill(props: Props): React.Node { - const { - onPress, - newMessageCount, - containerStyle, - style, - ...containerProps - } = props; + const { onPress, newMessageCount, containerStyle, style, ...containerProps } = + props; const styles = useStyles(unboundStyles); return ( <View {...containerProps} style={containerStyle}> diff --git a/native/chat/robotext-message-tooltip-button.react.js b/native/chat/robotext-message-tooltip-button.react.js --- a/native/chat/robotext-message-tooltip-button.react.js +++ b/native/chat/robotext-message-tooltip-button.react.js @@ -37,10 +37,8 @@ const windowWidth = useSelector(state => state.dimensions.width); - const [ - sidebarInputBarHeight, - setSidebarInputBarHeight, - ] = React.useState<?number>(null); + const [sidebarInputBarHeight, setSidebarInputBarHeight] = + React.useState<?number>(null); const onInputBarMeasured = React.useCallback((height: number) => { setSidebarInputBarHeight(height); }, []); diff --git a/native/chat/settings/add-users-modal.react.js b/native/chat/settings/add-users-modal.react.js --- a/native/chat/settings/add-users-modal.react.js +++ b/native/chat/settings/add-users-modal.react.js @@ -294,8 +294,7 @@ }, }; -const MemoizedAddUsersModal: React.ComponentType<Props> = React.memo<Props>( - AddUsersModal, -); +const MemoizedAddUsersModal: React.ComponentType<Props> = + React.memo<Props>(AddUsersModal); export default MemoizedAddUsersModal; diff --git a/native/chat/settings/color-selector-modal.react.js b/native/chat/settings/color-selector-modal.react.js --- a/native/chat/settings/color-selector-modal.react.js +++ b/native/chat/settings/color-selector-modal.react.js @@ -158,8 +158,8 @@ }, }; -const ConnectedColorSelectorModal: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedColorSelectorModal(props: BaseProps) { +const ConnectedColorSelectorModal: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedColorSelectorModal(props: BaseProps) { const styles = useStyles(unboundStyles); const colors = useColors(); const windowWidth = useSelector(state => state.dimensions.width); @@ -177,7 +177,6 @@ changeThreadSettings={callChangeThreadSettings} /> ); - }, -); + }); export default ConnectedColorSelectorModal; diff --git a/native/chat/settings/compose-subchannel-modal.react.js b/native/chat/settings/compose-subchannel-modal.react.js --- a/native/chat/settings/compose-subchannel-modal.react.js +++ b/native/chat/settings/compose-subchannel-modal.react.js @@ -136,15 +136,16 @@ }, }; -const ConnectedComposeSubchannelModal: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedComposeSubchannelModal(props: BaseProps) { +const ConnectedComposeSubchannelModal: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedComposeSubchannelModal( + props: BaseProps, + ) { const styles = useStyles(unboundStyles); const colors = useColors(); return ( <ComposeSubchannelModal {...props} styles={styles} colors={colors} /> ); - }, -); + }); export default ConnectedComposeSubchannelModal; diff --git a/native/chat/settings/delete-thread.react.js b/native/chat/settings/delete-thread.react.js --- a/native/chat/settings/delete-thread.react.js +++ b/native/chat/settings/delete-thread.react.js @@ -223,8 +223,8 @@ deleteThreadActionTypes, ); -const ConnectedDeleteThread: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedDeleteThread(props: BaseProps) { +const ConnectedDeleteThread: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedDeleteThread(props: BaseProps) { const threadID = props.route.params.threadInfo.id; const reduxThreadInfo = useSelector( state => threadInfoSelector(state)[threadID], @@ -265,7 +265,6 @@ navDispatch={navDispatch} /> ); - }, -); + }); export default ConnectedDeleteThread; diff --git a/native/chat/settings/thread-settings-color.react.js b/native/chat/settings/thread-settings-color.react.js --- a/native/chat/settings/thread-settings-color.react.js +++ b/native/chat/settings/thread-settings-color.react.js @@ -104,8 +104,10 @@ `${changeThreadSettingsActionTypes.started}:color`, ); -const ConnectedThreadSettingsColor: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsColor(props: BaseProps) { +const ConnectedThreadSettingsColor: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedThreadSettingsColor( + props: BaseProps, + ) { const loadingStatus = useSelector(loadingStatusSelector); const colors = useColors(); const styles = useStyles(unboundStyles); @@ -117,7 +119,6 @@ styles={styles} /> ); - }, -); + }); export default ConnectedThreadSettingsColor; diff --git a/native/chat/settings/thread-settings-description.react.js b/native/chat/settings/thread-settings-description.react.js --- a/native/chat/settings/thread-settings-description.react.js +++ b/native/chat/settings/thread-settings-description.react.js @@ -287,8 +287,10 @@ `${changeThreadSettingsActionTypes.started}:description`, ); -const ConnectedThreadSettingsDescription: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsDescription(props: BaseProps) { +const ConnectedThreadSettingsDescription: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedThreadSettingsDescription( + props: BaseProps, + ) { const loadingStatus = useSelector(loadingStatusSelector); const colors = useColors(); const styles = useStyles(unboundStyles); @@ -305,7 +307,6 @@ changeThreadSettings={callChangeThreadSettings} /> ); - }, -); + }); export default ConnectedThreadSettingsDescription; diff --git a/native/chat/settings/thread-settings-edit-relationship.react.js b/native/chat/settings/thread-settings-edit-relationship.react.js --- a/native/chat/settings/thread-settings-edit-relationship.react.js +++ b/native/chat/settings/thread-settings-edit-relationship.react.js @@ -35,8 +35,8 @@ +relationshipButton: RelationshipButton, }; -const ThreadSettingsEditRelationship: React.ComponentType<Props> = React.memo<Props>( - function ThreadSettingsEditRelationship(props: Props) { +const ThreadSettingsEditRelationship: React.ComponentType<Props> = + React.memo<Props>(function ThreadSettingsEditRelationship(props: Props) { const otherUserInfoFromRedux = useSelector(state => { const currentUserID = state.currentUserInfo?.id; const otherUserID = getSingleOtherUser(props.threadInfo, currentUserID); @@ -106,8 +106,7 @@ </Button> </View> ); - }, -); + }); 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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsHomeNotifs(props: BaseProps) { +const ConnectedThreadSettingsHomeNotifs: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<Props> { render() { - const { - panelIosHighlightUnderlay, - panelForegroundSecondaryLabel, - } = this.props.colors; + const { panelIosHighlightUnderlay, panelForegroundSecondaryLabel } = + this.props.colors; const loadingIndicator = this.props.loadingStatus === 'loading' ? ( <ActivityIndicator size="small" color={panelForegroundSecondaryLabel} /> @@ -149,8 +147,10 @@ leaveThreadActionTypes, ); -const ConnectedThreadSettingsLeaveThread: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsLeaveThread(props: BaseProps) { +const ConnectedThreadSettingsLeaveThread: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsMember(props: BaseProps) { +const ConnectedThreadSettingsMember: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsName(props: BaseProps) { +const ConnectedThreadSettingsName: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<Props> = React.memo<Props>( - ThreadSettingsParent, -); +const ConnectedThreadSettingsParent: React.ComponentType<Props> = + React.memo<Props>(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' ? ( <ActivityIndicator size="small" color={panelForegroundSecondaryLabel} /> @@ -89,8 +87,10 @@ }); }; -const ConnectedThreadSettingsPromoteSidebar: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsPromoteSidebar(props: BaseProps) { +const ConnectedThreadSettingsPromoteSidebar: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsPushNotifs(props: BaseProps) { +const ConnectedThreadSettingsPushNotifs: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettings(props: BaseProps) { +const ConnectedThreadSettings: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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 ( - <Item - item={row.item} - onPressItem={onPressItem} - extendArrow={extendArrow} - /> - ); - }, + (row: { +item: SidebarInfo, +index: number, ... }) => { + let extendArrow: boolean = false; + if (row.index < numOfSidebarsWithExtendedArrow) { + extendArrow = true; + } + return ( + <Item + item={row.item} + onPressItem={onPressItem} + extendArrow={extendArrow} + /> + ); + }, [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 ( <ThreadListModal @@ -44,12 +40,12 @@ ); } -const createRenderItem = ( - onPressItem: (threadInfo: ThreadInfo) => void, +const createRenderItem = + (onPressItem: (threadInfo: ThreadInfo) => void) => // eslint-disable-next-line react/display-name -) => (row: { +item: ChatThreadItem, +index: number, ... }) => { - return <Item subchannelInfo={row.item} onPressItem={onPressItem} />; -}; + (row: { +item: ChatThreadItem, +index: number, ... }) => { + return <Item subchannelInfo={row.item} onPressItem={onPressItem} />; + }; 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<IconGlyphs: string>( props: SwipeSnakeProps<IconGlyphs>, ): 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<?TextMessageMarkdownContextType> = React.createContext<?TextMessageMarkdownContextType>( - null, -); +const TextMessageMarkdownContext: React.Context<?TextMessageMarkdownContextType> = + React.createContext<?TextMessageMarkdownContextType>(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<?number>(null); + const [sidebarInputBarHeight, setSidebarInputBarHeight] = + React.useState<?number>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedTextMessage(props: BaseProps) { +const ConnectedTextMessage: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<U> = { +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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsButton(props: BaseProps) { +const ConnectedThreadSettingsButton: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedThreadSettingsButton( + props: BaseProps, + ) { const styles = useStyles(unboundStyles); return <ThreadSettingsButton {...props} styles={styles} />; - }, -); + }); 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 <HeaderTitle {...rest}>{firstLine(uiName)}</HeaderTitle>; } -const MemoizedThreadSettingsHeaderTitle: React.ComponentType<Props> = React.memo<Props>( - ThreadSettingsHeaderTitle, -); +const MemoizedThreadSettingsHeaderTitle: React.ComponentType<Props> = + React.memo<Props>(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<?$ReadOnlyArray<ChatMessageItemWithHeight>>(null); + const [messagesWithHeight, setMessagesWithHeight] = + React.useState<?$ReadOnlyArray<ChatMessageItemWithHeight>>(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<?boolean>(null); + const [isThreadColorDarkOverride, setThreadColorDarkOverride] = + React.useState<?boolean>(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<typeof BaseTextInput>, - ) => void = textInput => { - if (this.focused && textInput) { - textInput.focus(); - } - this.currentTextInput = textInput; - this.props.textInputRef(textInput); - }; + textInputRef: (textInput: ?React.ElementRef<typeof BaseTextInput>) => void = + textInput => { + if (this.focused && textInput) { + textInput.focus(); + } + this.currentTextInput = textInput; + this.props.textInputRef(textInput); + }; async getValueAndReset(): Promise<string> { 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<typeof BaseTextInput>, - ) => void = textInput => { - this.textInput = textInput; - this.props.textInputRef(textInput); - }; + textInputRef: (textInput: ?React.ElementRef<typeof BaseTextInput>) => 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<BaseProps> = React.memo<BaseProps>( - function KeyboardAvoidingView(props: BaseProps) { +const KeyboardAvoidingView: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function KeyboardAvoidingView(props: BaseProps) { const keyboardState = React.useContext(KeyboardContext); return ( <InnerKeyboardAvoidingView {...props} keyboardState={keyboardState} /> ); - }, -); + }); 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<BaseProps> = React.memo<BaseProps>( - function ConnectedLinkButton(props: BaseProps) { +const ConnectedLinkButton: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedLinkButton(props: BaseProps) { const styles = useStyles(unboundStyles); return <LinkButton {...props} styles={styles} />; - }, -); + }); 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<string, number>, 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<boolean>( - false, - ); + const [controlSelection, setControlSelection] = + React.useState<boolean>(false); const clearableTextInputRefCallback = React.useCallback( (clearableTextInput: ?React.ElementRef<typeof ClearableTextInput>) => { 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<boolean>( - false, - ); + const [controlSelection, setControlSelection] = + React.useState<boolean>(false); const clearableTextInputRefCallback = React.useCallback( (clearableTextInput: ?React.ElementRef<typeof ClearableTextInput>) => { 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<BaseProps> = React.memo<BaseProps>( - function ConnectedSwipeable(props: BaseProps) { +const ConnectedSwipeable: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<typeof BaseTextInput>, - ) => void = tagInput => { - this.tagInput = tagInput; - }; + tagInputRef: (tagInput: ?React.ElementRef<typeof BaseTextInput>) => void = + tagInput => { + this.tagInput = tagInput; + }; - scrollViewRef: ( - scrollView: ?React.ElementRef<typeof ScrollView>, - ) => void = scrollView => { - this.scrollView = scrollView; - }; + scrollViewRef: (scrollView: ?React.ElementRef<typeof ScrollView>) => 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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadListThread(props: BaseProps) { +const ConnectedThreadListThread: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadList(props: BaseProps) { +const ConnectedThreadList: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedThreadList(props: BaseProps) { const styles = useStyles(unboundStyles); const indicatorStyle = useIndicatorStyle(); return ( <ThreadList {...props} styles={styles} indicatorStyle={indicatorStyle} /> ); - }, -); + }); 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<BaseProps> = React.memo<BaseProps>( - function ConnectedUserListUser(props: BaseProps) { +const ConnectedUserListUser: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedUserListUser(props: BaseProps) { const colors = useColors(); const styles = useStyles(unboundStyles); return <UserListUser {...props} colors={colors} styles={styles} />; - }, -); + }); 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<BaseProps> = React.memo<BaseProps>( - function ConnectedInputStateContainer(props: BaseProps) { +const ConnectedInputStateContainer: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<?InputState> = React.createContext<?InputState>( - null, -); +const InputStateContext: React.Context<?InputState> = + React.createContext<?InputState>(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<BaseProps> = React.memo<BaseProps>( - function ConnectedKeyboardInputHost(props: BaseProps) { +const ConnectedKeyboardInputHost: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<?KeyboardState> = React.createContext<?KeyboardState>( - null, -); +const KeyboardContext: React.Context<?KeyboardState> = + React.createContext<?KeyboardState>(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<?MarkdownContextType> = React.createContext<?MarkdownContextType>( - null, -); +const MarkdownContext: React.Context<?MarkdownContextType> = + React.createContext<?MarkdownContextType>(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<?MarkdownSpoilerContextType> = React.createContext<?MarkdownSpoilerContextType>( - null, -); +const MarkdownSpoilerContext: React.Context<?MarkdownSpoilerContextType> = + React.createContext<?MarkdownSpoilerContextType>(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<MediaMissionStep>, 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<BaseProps> = React.memo<BaseProps>( - function ConnectedCameraModal(props: BaseProps) { +const ConnectedCameraModal: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<MediaMissionStep>, result: { localURI: ?string, orientation: ?number }, }> { @@ -216,9 +210,7 @@ }; } -async function fetchFileSize( - uri: string, -): Promise<{ +async function fetchFileSize(uri: string): Promise<{ steps: $ReadOnlyArray<MediaMissionStep>, 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<BaseProps> = React.memo<BaseProps>( - function ConnectedImageModal(props: BaseProps) { +const ConnectedImageModal: React.ComponentType<BaseProps> = + React.memo<BaseProps>(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<MediaMissionStep>, 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<BaseProps> = React.memo<BaseProps>( - function ConnectedMultimedia(props: BaseProps) { +const ConnectedMultimedia: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedMultimedia(props: BaseProps) { const inputState = React.useContext(InputStateContext); return <Multimedia {...props} inputState={inputState} />; - }, -); + }); 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<BaseProps> = React.memo<BaseProps>( - function ConnectedRemoteImage(props: BaseProps) { +const ConnectedRemoteImage: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedRemoteImage(props: BaseProps) { const connectionStatus = useSelector(state => state.connection.status); return <RemoteImage {...props} connectionStatus={connectionStatus} />; - }, -); + }); 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<?React.ElementRef<TouchableOpacityInstance>>(); + const closeButtonRef = + React.useRef<?React.ElementRef<TouchableOpacityInstance>>(); 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 @@ <ConnectedStatusBar hidden /> ); - const backdropStyle = React.useMemo(() => ({ opacity: backdropOpacity }), [ - backdropOpacity, - ]); + const backdropStyle = React.useMemo( + () => ({ opacity: backdropOpacity }), + [backdropOpacity], + ); const contentContainerStyle = React.useMemo(() => { const fullScreenHeight = screenDimensions.height; diff --git a/native/navigation/app-navigator.react.js b/native/navigation/app-navigator.react.js --- a/native/navigation/app-navigator.react.js +++ b/native/navigation/app-navigator.react.js @@ -70,10 +70,8 @@ setNavStateInitialized && setNavStateInitialized(); }, [setNavStateInitialized]); - const [ - localSplashScreenHasHidden, - setLocalSplashScreenHasHidden, - ] = React.useState(splashScreenHasHidden); + const [localSplashScreenHasHidden, setLocalSplashScreenHasHidden] = + React.useState(splashScreenHasHidden); React.useEffect(() => { if (localSplashScreenHasHidden || !fontsLoaded) { diff --git a/native/navigation/community-drawer-item-community.react.js b/native/navigation/community-drawer-item-community.react.js --- a/native/navigation/community-drawer-item-community.react.js +++ b/native/navigation/community-drawer-item-community.react.js @@ -39,7 +39,6 @@ }, }; -const MemoizedCommunityDrawerItemCommunity: React.ComponentType<DrawerItemProps> = React.memo( - CommunityDrawerItemCommunity, -); +const MemoizedCommunityDrawerItemCommunity: React.ComponentType<DrawerItemProps> = + React.memo(CommunityDrawerItemCommunity); export default MemoizedCommunityDrawerItemCommunity; diff --git a/native/navigation/community-drawer-item.react.js b/native/navigation/community-drawer-item.react.js --- a/native/navigation/community-drawer-item.react.js +++ b/native/navigation/community-drawer-item.react.js @@ -137,12 +137,10 @@ </View> ); } -const MemoizedCommunityDrawerItemChat: React.ComponentType<CommunityDrawerItemChatProps> = React.memo( - CommunityDrawerItemChat, -); +const MemoizedCommunityDrawerItemChat: React.ComponentType<CommunityDrawerItemChatProps> = + React.memo(CommunityDrawerItemChat); -const MemoizedCommunityDrawerItem: React.ComponentType<DrawerItemProps> = React.memo( - CommunityDrawerItem, -); +const MemoizedCommunityDrawerItem: React.ComponentType<DrawerItemProps> = + React.memo(CommunityDrawerItem); export default MemoizedCommunityDrawerItem; diff --git a/native/navigation/nav-selectors.js b/native/navigation/nav-selectors.js --- a/native/navigation/nav-selectors.js +++ b/native/navigation/nav-selectors.js @@ -179,22 +179,20 @@ return getThreadIDFromRoute(currentChatSubroute, validRouteNames); } -const activeThreadSelector: ( - context: ?NavContextType, -) => ?string = createSelector( - (context: ?NavContextType) => context && context.state, - (navigationState: ?PossiblyStaleNavigationState): ?string => - activeThread(navigationState, threadRoutes), -); +const activeThreadSelector: (context: ?NavContextType) => ?string = + createSelector( + (context: ?NavContextType) => context && context.state, + (navigationState: ?PossiblyStaleNavigationState): ?string => + activeThread(navigationState, threadRoutes), + ); const messageListRouteNames = [MessageListRouteName]; -const activeMessageListSelector: ( - context: ?NavContextType, -) => ?string = createSelector( - (context: ?NavContextType) => context && context.state, - (navigationState: ?PossiblyStaleNavigationState): ?string => - activeThread(navigationState, messageListRouteNames), -); +const activeMessageListSelector: (context: ?NavContextType) => ?string = + createSelector( + (context: ?NavContextType) => context && context.state, + (navigationState: ?PossiblyStaleNavigationState): ?string => + activeThread(navigationState, messageListRouteNames), + ); function useActiveThread(): ?string { const navContext = React.useContext(NavContext); @@ -222,45 +220,44 @@ const threadPickerActiveSelector = createIsForegroundSelector( ThreadPickerModalRouteName, ); -const calendarActiveSelector: ( - context: ?NavContextType, -) => boolean = createSelector( - calendarTabActiveSelector, - threadPickerActiveSelector, - (calendarTabActive: boolean, threadPickerActive: boolean) => - calendarTabActive || threadPickerActive, -); +const calendarActiveSelector: (context: ?NavContextType) => boolean = + createSelector( + calendarTabActiveSelector, + threadPickerActiveSelector, + (calendarTabActive: boolean, threadPickerActive: boolean) => + calendarTabActive || threadPickerActive, + ); -const nativeCalendarQuery: ( - input: NavPlusRedux, -) => () => CalendarQuery = createSelector( - (input: NavPlusRedux) => currentCalendarQuery(input.redux), - (input: NavPlusRedux) => calendarActiveSelector(input.navContext), - ( - calendarQuery: (calendarActive: boolean) => CalendarQuery, - calendarActive: boolean, - ) => () => calendarQuery(calendarActive), -); +const nativeCalendarQuery: (input: NavPlusRedux) => () => CalendarQuery = + createSelector( + (input: NavPlusRedux) => currentCalendarQuery(input.redux), + (input: NavPlusRedux) => calendarActiveSelector(input.navContext), + ( + calendarQuery: (calendarActive: boolean) => CalendarQuery, + calendarActive: boolean, + ) => + () => + calendarQuery(calendarActive), + ); -const nonThreadCalendarQuery: ( - input: NavPlusRedux, -) => () => CalendarQuery = createSelector( - nativeCalendarQuery, - (input: NavPlusRedux) => nonThreadCalendarFiltersSelector(input.redux), - ( - calendarQuery: () => CalendarQuery, - filters: $ReadOnlyArray<CalendarFilter>, - ) => { - return (): CalendarQuery => { - const query = calendarQuery(); - return { - startDate: query.startDate, - endDate: query.endDate, - filters, +const nonThreadCalendarQuery: (input: NavPlusRedux) => () => CalendarQuery = + createSelector( + nativeCalendarQuery, + (input: NavPlusRedux) => nonThreadCalendarFiltersSelector(input.redux), + ( + calendarQuery: () => CalendarQuery, + filters: $ReadOnlyArray<CalendarFilter>, + ) => { + return (): CalendarQuery => { + const query = calendarQuery(); + return { + startDate: query.startDate, + endDate: query.endDate, + filters, + }; }; - }; - }, -); + }, + ); function useCalendarQuery(): () => CalendarQuery { const navContext = React.useContext(NavContext); @@ -272,53 +269,51 @@ ); } -const drawerSwipeEnabledSelector: ( - context: ?NavContextType, -) => boolean = createSelector( - (context: ?NavContextType) => context && context.state, - (navigationState: ?PossiblyStaleNavigationState) => { - if (!navigationState) { - return true; - } +const drawerSwipeEnabledSelector: (context: ?NavContextType) => boolean = + createSelector( + (context: ?NavContextType) => context && context.state, + (navigationState: ?PossiblyStaleNavigationState) => { + if (!navigationState) { + return true; + } - // First, we recurse into the navigation state until we find the tab route - // The tab route should always be accessible by recursing through the first - // routes of each subsequent nested navigation state - const [firstRootSubroute] = navigationState.routes; - if (firstRootSubroute.name !== AppRouteName) { - return true; - } - const appState = getStateFromNavigatorRoute(firstRootSubroute); - const [firstAppSubroute] = appState.routes; - if (firstAppSubroute.name !== CommunityDrawerNavigatorRouteName) { - return true; - } - const communityDrawerState = getStateFromNavigatorRoute(firstAppSubroute); - const [firstCommunityDrawerSubroute] = communityDrawerState.routes; - if (firstCommunityDrawerSubroute.name !== TabNavigatorRouteName) { - return true; - } - const tabState = getStateFromNavigatorRoute(firstCommunityDrawerSubroute); + // First, we recurse into the navigation state until we find the tab route + // The tab route should always be accessible by recursing through the + // first routes of each subsequent nested navigation state + const [firstRootSubroute] = navigationState.routes; + if (firstRootSubroute.name !== AppRouteName) { + return true; + } + const appState = getStateFromNavigatorRoute(firstRootSubroute); + const [firstAppSubroute] = appState.routes; + if (firstAppSubroute.name !== CommunityDrawerNavigatorRouteName) { + return true; + } + const communityDrawerState = getStateFromNavigatorRoute(firstAppSubroute); + const [firstCommunityDrawerSubroute] = communityDrawerState.routes; + if (firstCommunityDrawerSubroute.name !== TabNavigatorRouteName) { + return true; + } + const tabState = getStateFromNavigatorRoute(firstCommunityDrawerSubroute); - // Once we have the tab state, we want to figure out if we currently have - // an active StackNavigator - const currentTabSubroute = tabState.routes[tabState.index]; - if (!currentTabSubroute.state) { - return true; - } - const currentTabSubrouteState = getStateFromNavigatorRoute( - currentTabSubroute, - ); - if (currentTabSubrouteState.type !== 'stack') { - return true; - } + // Once we have the tab state, we want to figure out if we currently have + // an active StackNavigator + const currentTabSubroute = tabState.routes[tabState.index]; + if (!currentTabSubroute.state) { + return true; + } + const currentTabSubrouteState = + getStateFromNavigatorRoute(currentTabSubroute); + if (currentTabSubrouteState.type !== 'stack') { + return true; + } - // Finally, we want to disable the swipe gesture if there is a stack with - // more than one subroute, since then the stack will have its own swipe - // gesture that will conflict with the drawer's - return currentTabSubrouteState.routes.length < 2; - }, -); + // Finally, we want to disable the swipe gesture if there is a stack with + // more than one subroute, since then the stack will have its own swipe + // gesture that will conflict with the drawer's + return currentTabSubrouteState.routes.length < 2; + }, + ); export { createIsForegroundSelector, diff --git a/native/navigation/navigation-context.js b/native/navigation/navigation-context.js --- a/native/navigation/navigation-context.js +++ b/native/navigation/navigation-context.js @@ -20,8 +20,7 @@ +dispatch: (action: NavAction) => void, }; -const NavContext: React.Context<?NavContextType> = React.createContext<?NavContextType>( - null, -); +const NavContext: React.Context<?NavContextType> = + React.createContext<?NavContextType>(null); export { NavContext }; diff --git a/native/navigation/overlay-context.js b/native/navigation/overlay-context.js --- a/native/navigation/overlay-context.js +++ b/native/navigation/overlay-context.js @@ -18,8 +18,7 @@ +scrollBlockingModalStatus: ScrollBlockingModalStatus, +setScrollBlockingModalStatus: ScrollBlockingModalStatus => void, }; -const OverlayContext: React.Context<?OverlayContextType> = React.createContext( - null, -); +const OverlayContext: React.Context<?OverlayContextType> = + React.createContext(null); export { OverlayContext }; diff --git a/native/navigation/overlay-navigator.react.js b/native/navigation/overlay-navigator.react.js --- a/native/navigation/overlay-navigator.react.js +++ b/native/navigation/overlay-navigator.react.js @@ -29,13 +29,12 @@ import { scrollBlockingModals, TabNavigatorRouteName } from './route-names.js'; import { isMessageTooltipKey } from '../chat/utils.js'; -export type OverlayNavigationHelpers< - ParamList: ParamListBase = ParamListBase, -> = { - ...$Exact<StackNavigationHelpers<ParamList, {}>>, - ...OverlayRouterExtraNavigationHelpers, - ... -}; +export type OverlayNavigationHelpers<ParamList: ParamListBase = ParamListBase> = + { + ...$Exact<StackNavigationHelpers<ParamList, {}>>, + ...OverlayRouterExtraNavigationHelpers, + ... + }; export type OverlayNavigationProp< ParamList: ParamListBase = ParamListBase, @@ -156,10 +155,8 @@ } return status; }; - const [ - scrollBlockingModalStatus, - setScrollBlockingModalStatus, - ] = React.useState(() => getScrollBlockingModalStatus(scenes)); + const [scrollBlockingModalStatus, setScrollBlockingModalStatus] = + React.useState(() => getScrollBlockingModalStatus(scenes)); const sceneDataForNewScene = scene => ({ ...scene, context: { @@ -403,7 +400,8 @@ ) { newScrollBlockingModalStatus = statusFromSceneData; } - prevScrollBlockingModalStatusFromSceneDataRef.current = statusFromSceneData; + prevScrollBlockingModalStatusFromSceneDataRef.current = + statusFromSceneData; } if ( !newScrollBlockingModalStatus && diff --git a/native/navigation/root-navigator-context.js b/native/navigation/root-navigator-context.js --- a/native/navigation/root-navigator-context.js +++ b/native/navigation/root-navigator-context.js @@ -6,8 +6,7 @@ setKeyboardHandlingEnabled: (enabled: boolean) => void, }; -const RootNavigatorContext: React.Context<?RootNavigatorContextType> = React.createContext<?RootNavigatorContextType>( - null, -); +const RootNavigatorContext: React.Context<?RootNavigatorContextType> = + React.createContext<?RootNavigatorContextType>(null); export { RootNavigatorContext }; diff --git a/native/navigation/root-navigator.react.js b/native/navigation/root-navigator.react.js --- a/native/navigation/root-navigator.react.js +++ b/native/navigation/root-navigator.react.js @@ -69,9 +69,8 @@ id, ...rest }: RootNavigatorProps) { - const [keyboardHandlingEnabled, setKeyboardHandlingEnabled] = React.useState( - true, - ); + const [keyboardHandlingEnabled, setKeyboardHandlingEnabled] = + React.useState(true); const mergedScreenOptions = React.useMemo(() => { if (typeof screenOptions === 'function') { return input => ({ @@ -126,9 +125,8 @@ const transitionPreset = { ...baseTransitionPreset, cardStyleInterpolator: interpolatorProps => { - const baseCardStyleInterpolator = baseTransitionPreset.cardStyleInterpolator( - interpolatorProps, - ); + const baseCardStyleInterpolator = + baseTransitionPreset.cardStyleInterpolator(interpolatorProps); const overlayOpacity = interpolatorProps.current.progress.interpolate({ inputRange: [0, 1], outputRange: ([0, 0.7]: number[]), // Flow... diff --git a/native/navigation/route-names.js b/native/navigation/route-names.js --- a/native/navigation/route-names.js +++ b/native/navigation/route-names.js @@ -157,9 +157,8 @@ ...CommunityDrawerParamList, }; -export type NavigationRoute< - RouteName: string = $Keys<ScreenParamList>, -> = RouteProp<ScreenParamList, RouteName>; +export type NavigationRoute<RouteName: string = $Keys<ScreenParamList>> = + RouteProp<ScreenParamList, RouteName>; export const accountModals = [LoggedOutModalRouteName]; diff --git a/native/profile/appearance-preferences.react.js b/native/profile/appearance-preferences.react.js --- a/native/profile/appearance-preferences.react.js +++ b/native/profile/appearance-preferences.react.js @@ -151,25 +151,22 @@ }, }; -const ConnectedAppearancePreferences: React.ComponentType<{ - ... -}> = React.memo<{ ... }>(function ConnectedAppearancePreferences(props: { - ... -}) { - const globalThemeInfo = useSelector(state => state.globalThemeInfo); - const styles = useStyles(unboundStyles); - const colors = useColors(); - const dispatch = useDispatch(); +const ConnectedAppearancePreferences: React.ComponentType<{ ... }> = + React.memo<{ ... }>(function ConnectedAppearancePreferences(props: { ... }) { + const globalThemeInfo = useSelector(state => state.globalThemeInfo); + const styles = useStyles(unboundStyles); + const colors = useColors(); + const dispatch = useDispatch(); - return ( - <AppearancePreferences - {...props} - globalThemeInfo={globalThemeInfo} - styles={styles} - colors={colors} - dispatch={dispatch} - /> - ); -}); + return ( + <AppearancePreferences + {...props} + globalThemeInfo={globalThemeInfo} + styles={styles} + colors={colors} + dispatch={dispatch} + /> + ); + }); export default ConnectedAppearancePreferences; diff --git a/native/profile/custom-server-modal.react.js b/native/profile/custom-server-modal.react.js --- a/native/profile/custom-server-modal.react.js +++ b/native/profile/custom-server-modal.react.js @@ -115,8 +115,8 @@ }, }; -const ConnectedCustomServerModal: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedCustomServerModal(props: BaseProps) { +const ConnectedCustomServerModal: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedCustomServerModal(props: BaseProps) { const urlPrefix = useSelector(state => state.urlPrefix); const customServer = useSelector(state => state.customServer); const styles = useStyles(unboundStyles); @@ -131,7 +131,6 @@ dispatch={dispatch} /> ); - }, -); + }); export default ConnectedCustomServerModal; diff --git a/native/profile/default-notifications-preferences.react.js b/native/profile/default-notifications-preferences.react.js --- a/native/profile/default-notifications-preferences.react.js +++ b/native/profile/default-notifications-preferences.react.js @@ -178,8 +178,10 @@ }; registerFetchKey(setUserSettingsActionTypes); -const ConnectedDefaultNotificationPreferences: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedDefaultNotificationPreferences(props: BaseProps) { +const ConnectedDefaultNotificationPreferences: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedDefaultNotificationPreferences( + props: BaseProps, + ) { const styles = useStyles(unboundStyles); const dispatchActionPromise = useDispatchActionPromise(); const changeNotificationSettings = useServerCall(setUserSettings); @@ -206,7 +208,6 @@ selectedDefaultNotification={selectedDefaultNotification} /> ); - }, -); + }); export default ConnectedDefaultNotificationPreferences; diff --git a/native/profile/edit-password.react.js b/native/profile/edit-password.react.js --- a/native/profile/edit-password.react.js +++ b/native/profile/edit-password.react.js @@ -342,8 +342,8 @@ changeUserPasswordActionTypes, ); -const ConnectedEditPassword: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedEditPassword(props: BaseProps) { +const ConnectedEditPassword: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedEditPassword(props: BaseProps) { const loadingStatus = useSelector(loadingStatusSelector); const username = useSelector(state => { if (state.currentUserInfo && !state.currentUserInfo.anonymous) { @@ -370,7 +370,6 @@ changeUserPassword={callChangeUserPassword} /> ); - }, -); + }); export default ConnectedEditPassword; diff --git a/native/profile/profile-header.react.js b/native/profile/profile-header.react.js --- a/native/profile/profile-header.react.js +++ b/native/profile/profile-header.react.js @@ -10,12 +10,11 @@ const activeTabSelector = createActiveTabSelector(ProfileRouteName); -const ProfileHeader: React.ComponentType<StackHeaderProps> = React.memo<StackHeaderProps>( - function ProfileHeader(props: StackHeaderProps) { +const ProfileHeader: React.ComponentType<StackHeaderProps> = + React.memo<StackHeaderProps>(function ProfileHeader(props: StackHeaderProps) { const navContext = React.useContext(NavContext); const activeTab = activeTabSelector(navContext); return <Header {...props} activeTab={activeTab} />; - }, -); + }); export default ProfileHeader; diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js --- a/native/profile/profile-screen.react.js +++ b/native/profile/profile-screen.react.js @@ -341,12 +341,11 @@ }, }; -const logOutLoadingStatusSelector = createLoadingStatusSelector( - logOutActionTypes, -); +const logOutLoadingStatusSelector = + createLoadingStatusSelector(logOutActionTypes); -const ConnectedProfileScreen: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedProfileScreen(props: BaseProps) { +const ConnectedProfileScreen: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedProfileScreen(props: BaseProps) { const currentUserInfo = useSelector(state => state.currentUserInfo); const preRequestUserState = useSelector(preRequestUserStateSelector); const logOutLoading = @@ -372,7 +371,6 @@ stringForUser={stringForUser} /> ); - }, -); + }); export default ConnectedProfileScreen; diff --git a/native/profile/relationship-list-item.react.js b/native/profile/relationship-list-item.react.js --- a/native/profile/relationship-list-item.react.js +++ b/native/profile/relationship-list-item.react.js @@ -312,8 +312,10 @@ }, }; -const ConnectedRelationshipListItem: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedRelationshipListItem(props: BaseProps) { +const ConnectedRelationshipListItem: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedRelationshipListItem( + props: BaseProps, + ) { const removeUserLoadingStatus = useSelector(state => createLoadingStatusSelector( updateRelationshipsActionTypes, @@ -338,7 +340,6 @@ keyboardState={keyboardState} /> ); - }, -); + }); export default ConnectedRelationshipListItem; diff --git a/native/profile/relationship-list.react.js b/native/profile/relationship-list.react.js --- a/native/profile/relationship-list.react.js +++ b/native/profile/relationship-list.react.js @@ -159,9 +159,8 @@ const keyboardNotShowing = !!( keyboardState && !keyboardState.keyboardShowing ); - const [verticalBounds, setVerticalBounds] = React.useState<?VerticalBounds>( - null, - ); + const [verticalBounds, setVerticalBounds] = + React.useState<?VerticalBounds>(null); const onFlatListContainerLayout = React.useCallback(() => { if (!flatListContainerRef.current) { return; @@ -489,9 +488,8 @@ registerFetchKey(searchUsersActionTypes); registerFetchKey(updateRelationshipsActionTypes); -const MemoizedRelationshipList: React.ComponentType<Props> = React.memo<Props>( - RelationshipList, -); +const MemoizedRelationshipList: React.ComponentType<Props> = + React.memo<Props>(RelationshipList); MemoizedRelationshipList.displayName = 'RelationshipList'; export default MemoizedRelationshipList; diff --git a/native/push/ios.js b/native/push/ios.js --- a/native/push/ios.js +++ b/native/push/ios.js @@ -40,7 +40,8 @@ firstRun = false; if (!permissionNeeded) { - const permissions: PushPermissions = await CommIOSNotifications.checkPermissions(); + const permissions: PushPermissions = + await CommIOSNotifications.checkPermissions(); permissionNeeded = permissionMissing(permissions); } diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js --- a/native/push/push-handler.react.js +++ b/native/push/push-handler.react.js @@ -124,7 +124,8 @@ ); this.onForeground(); if (Platform.OS === 'ios') { - const commIOSNotificationsEventEmitter = getCommIOSNotificationsEventEmitter(); + const commIOSNotificationsEventEmitter = + getCommIOSNotificationsEventEmitter(); this.iosNotificationEventSubscriptions.push( commIOSNotificationsEventEmitter.addListener( 'remoteNotificationsRegistered', @@ -151,7 +152,8 @@ CommAndroidNotifications.getConstants().NOTIFICATIONS_IMPORTANCE_HIGH, 'Comm notifications channel', ); - const commAndroidNotificationsEventEmitter = getCommAndroidNotificationsEventEmitter(); + const commAndroidNotificationsEventEmitter = + getCommAndroidNotificationsEventEmitter(); this.androidNotificationsEventSubscriptions.push( commAndroidNotificationsEventEmitter.addListener( 'commAndroidNotificationsToken', @@ -344,7 +346,8 @@ return; } this.initialAndroidNotifHandled = true; - const initialNotif = await CommAndroidNotifications.getInitialNotification(); + const initialNotif = + await CommAndroidNotifications.getInitialNotification(); if (initialNotif) { await this.androidNotificationOpened(initialNotif); } @@ -434,9 +437,8 @@ if (!messageInfosString) { return; } - const rawMessageInfos: $ReadOnlyArray<RawMessageInfo> = JSON.parse( - messageInfosString, - ); + const rawMessageInfos: $ReadOnlyArray<RawMessageInfo> = + JSON.parse(messageInfosString); const { updatesCurrentAsOf } = this.props; this.props.dispatch({ type: saveMessagesActionType, @@ -569,8 +571,8 @@ } } -const ConnectedPushHandler: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedPushHandler(props: BaseProps) { +const ConnectedPushHandler: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedPushHandler(props: BaseProps) { const navContext = React.useContext(NavContext); const activeThread = activeMessageListSelector(navContext); const boundUnreadCount = useSelector(unreadCount); @@ -607,7 +609,6 @@ rootContext={rootContext} /> ); - }, -); + }); export default ConnectedPushHandler; diff --git a/native/redux/connectivity-updater.react.js b/native/redux/connectivity-updater.react.js --- a/native/redux/connectivity-updater.react.js +++ b/native/redux/connectivity-updater.react.js @@ -35,8 +35,9 @@ NetInfo.fetch().then(onConnectionChange); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - React.useEffect(() => NetInfo.addEventListener(onConnectionChange), [ - onConnectionChange, - ]); + React.useEffect( + () => NetInfo.addEventListener(onConnectionChange), + [onConnectionChange], + ); return null; } diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -377,12 +377,12 @@ ...fixUnreadActiveThreadResult.threadStoreOperations, ]; - const convertedThreadStoreOperations = convertThreadStoreOperationsToClientDBOperations( - threadStoreOperationsWithUnreadFix, - ); - const convertedMessageStoreOperations = convertMessageStoreOperationsToClientDBOperations( - messageStoreOperations, - ); + const convertedThreadStoreOperations = + convertThreadStoreOperationsToClientDBOperations( + threadStoreOperationsWithUnreadFix, + ); + const convertedMessageStoreOperations = + convertMessageStoreOperationsToClientDBOperations(messageStoreOperations); (async () => { try { const promises = []; diff --git a/native/root-context.js b/native/root-context.js --- a/native/root-context.js +++ b/native/root-context.js @@ -7,8 +7,7 @@ +setNavStateInitialized: () => void, }; -const RootContext: React.Context<?RootContextType> = React.createContext<?RootContextType>( - null, -); +const RootContext: React.Context<?RootContextType> = + React.createContext<?RootContextType>(null); export { RootContext }; diff --git a/native/selectors/account-selectors.js b/native/selectors/account-selectors.js --- a/native/selectors/account-selectors.js +++ b/native/selectors/account-selectors.js @@ -34,21 +34,20 @@ }, ); -const noDataAfterPolicyAcknowledgmentSelector: ( - state: AppState, -) => boolean = createSelector( - (state: AppState) => state.connectivity, - (state: AppState) => state.messageStore.currentAsOf, - (state: AppState) => state.userPolicies, - ( - connectivity: ConnectivityInfo, - currentAsOf: number, - userPolicies: UserPolicies, - ) => - connectivity.connected && - currentAsOf === 0 && - values(userPolicies).every(policy => policy.isAcknowledged), -); +const noDataAfterPolicyAcknowledgmentSelector: (state: AppState) => boolean = + createSelector( + (state: AppState) => state.connectivity, + (state: AppState) => state.messageStore.currentAsOf, + (state: AppState) => state.userPolicies, + ( + connectivity: ConnectivityInfo, + currentAsOf: number, + userPolicies: UserPolicies, + ) => + connectivity.connected && + currentAsOf === 0 && + values(userPolicies).every(policy => policy.isAcknowledged), + ); export { nativeLogInExtraInfoSelector, diff --git a/native/selectors/message-selectors.js b/native/selectors/message-selectors.js --- a/native/selectors/message-selectors.js +++ b/native/selectors/message-selectors.js @@ -11,25 +11,24 @@ const msInHour = 60 * 60 * 1000; -const nextMessagePruneTimeSelector: ( - state: AppState, -) => ?number = createSelector( - (state: AppState) => state.messageStore.threads, - (threadMessageInfos: { +[id: string]: ThreadMessageInfo }): ?number => { - let nextTime; - for (const threadID in threadMessageInfos) { - const threadMessageInfo = threadMessageInfos[threadID]; - const threadPruneTime = Math.max( - threadMessageInfo.lastNavigatedTo + msInHour, - threadMessageInfo.lastPruned + msInHour * 6, - ); - if (nextTime === undefined || threadPruneTime < nextTime) { - nextTime = threadPruneTime; +const nextMessagePruneTimeSelector: (state: AppState) => ?number = + createSelector( + (state: AppState) => state.messageStore.threads, + (threadMessageInfos: { +[id: string]: ThreadMessageInfo }): ?number => { + let nextTime; + for (const threadID in threadMessageInfos) { + const threadMessageInfo = threadMessageInfos[threadID]; + const threadPruneTime = Math.max( + threadMessageInfo.lastNavigatedTo + msInHour, + threadMessageInfo.lastPruned + msInHour * 6, + ); + if (nextTime === undefined || threadPruneTime < nextTime) { + nextTime = threadPruneTime; + } } - } - return nextTime; - }, -); + return nextTime; + }, + ); const pruneThreadIDsSelector: ( input: NavPlusRedux, @@ -37,25 +36,26 @@ (input: NavPlusRedux) => input.redux.messageStore.threads, (input: NavPlusRedux) => activeThreadSelector(input.navContext), ( - threadMessageInfos: { +[id: string]: ThreadMessageInfo }, - activeThread: ?string, - ) => (): $ReadOnlyArray<string> => { - const now = Date.now(); - const threadIDsToPrune = []; - for (const threadID in threadMessageInfos) { - if (threadID === activeThread || threadIsPending(threadID)) { - continue; - } - const threadMessageInfo = threadMessageInfos[threadID]; - if ( - threadMessageInfo.lastNavigatedTo + msInHour < now && - threadMessageInfo.lastPruned + msInHour * 6 < now - ) { - threadIDsToPrune.push(threadID); + threadMessageInfos: { +[id: string]: ThreadMessageInfo }, + activeThread: ?string, + ) => + (): $ReadOnlyArray<string> => { + const now = Date.now(); + const threadIDsToPrune = []; + for (const threadID in threadMessageInfos) { + if (threadID === activeThread || threadIsPending(threadID)) { + continue; + } + const threadMessageInfo = threadMessageInfos[threadID]; + if ( + threadMessageInfo.lastNavigatedTo + msInHour < now && + threadMessageInfo.lastPruned + msInHour * 6 < now + ) { + threadIDsToPrune.push(threadID); + } } - } - return threadIDsToPrune; - }, + return threadIDsToPrune; + }, ); export { nextMessagePruneTimeSelector, pruneThreadIDsSelector }; diff --git a/native/selectors/socket-selectors.js b/native/selectors/socket-selectors.js --- a/native/selectors/socket-selectors.js +++ b/native/selectors/socket-selectors.js @@ -58,14 +58,19 @@ (input: NavPlusRedux) => getClientResponsesSelector(input.redux), (input: NavPlusRedux) => calendarActiveSelector(input.navContext), ( - getClientResponsesFunc: ( + getClientResponsesFunc: ( + calendarActive: boolean, + oneTimeKeyGenerator: ?OneTimeKeyGenerator, + serverRequests: $ReadOnlyArray<ClientServerRequest>, + ) => $ReadOnlyArray<ClientClientResponse>, calendarActive: boolean, - oneTimeKeyGenerator: ?OneTimeKeyGenerator, - serverRequests: $ReadOnlyArray<ClientServerRequest>, - ) => $ReadOnlyArray<ClientClientResponse>, - calendarActive: boolean, - ) => (serverRequests: $ReadOnlyArray<ClientServerRequest>) => - getClientResponsesFunc(calendarActive, oneTimeKeyGenerator, serverRequests), + ) => + (serverRequests: $ReadOnlyArray<ClientServerRequest>) => + getClientResponsesFunc( + calendarActive, + oneTimeKeyGenerator, + serverRequests, + ), ); const nativeSessionStateFuncSelector: ( @@ -74,9 +79,11 @@ (input: NavPlusRedux) => sessionStateFuncSelector(input.redux), (input: NavPlusRedux) => calendarActiveSelector(input.navContext), ( - sessionStateFunc: (calendarActive: boolean) => SessionState, - calendarActive: boolean, - ) => () => sessionStateFunc(calendarActive), + sessionStateFunc: (calendarActive: boolean) => SessionState, + calendarActive: boolean, + ) => + () => + sessionStateFunc(calendarActive), ); export { diff --git a/native/socket.react.js b/native/socket.react.js --- a/native/socket.react.js +++ b/native/socket.react.js @@ -31,8 +31,8 @@ nativeSessionStateFuncSelector, } from './selectors/socket-selectors.js'; -const NativeSocket: React.ComponentType<BaseSocketProps> = React.memo<BaseSocketProps>( - function NativeSocket(props: BaseSocketProps) { +const NativeSocket: React.ComponentType<BaseSocketProps> = + React.memo<BaseSocketProps>(function NativeSocket(props: BaseSocketProps) { const inputState = React.useContext(InputStateContext); const navContext = React.useContext(NavContext); @@ -142,7 +142,6 @@ socketCrashLoopRecovery={socketCrashLoopRecovery} /> ); - }, -); + }); export default NativeSocket; diff --git a/native/staff/staff-context.provider.react.js b/native/staff/staff-context.provider.react.js --- a/native/staff/staff-context.provider.react.js +++ b/native/staff/staff-context.provider.react.js @@ -9,10 +9,8 @@ +children: React.Node, }; function StaffContextProvider(props: Props): React.Node { - const [ - staffUserHasBeenLoggedIn, - setStaffUserHasBeenLoggedIn, - ] = React.useState(false); + const [staffUserHasBeenLoggedIn, setStaffUserHasBeenLoggedIn] = + React.useState(false); const isCurrentUserStaff = useIsCurrentUserStaff(); diff --git a/native/themes/colors.js b/native/themes/colors.js --- a/native/themes/colors.js +++ b/native/themes/colors.js @@ -236,10 +236,10 @@ function useStyles<IS: Styles>(obj: IS): StyleSheetOf<IS> { const ourColors = useColors(); - return React.useMemo(() => stylesFromColors(obj, ourColors), [ - obj, - ourColors, - ]); + return React.useMemo( + () => stylesFromColors(obj, ourColors), + [obj, ourColors], + ); } function useOverlayStyles<IS: Styles>(obj: IS): StyleSheetOf<IS> { @@ -256,10 +256,10 @@ ); const syntheticTheme = backgroundIsDark ? 'dark' : 'light'; - return React.useMemo(() => stylesFromColors(obj, colors[syntheticTheme]), [ - obj, - syntheticTheme, - ]); + return React.useMemo( + () => stylesFromColors(obj, colors[syntheticTheme]), + [obj, syntheticTheme], + ); } function useColors(): Colors { @@ -280,24 +280,22 @@ ); return theme && theme === 'dark' ? 'white' : 'black'; } -const indicatorStyleSelector: ( - state: AppState, -) => IndicatorStyle = createSelector( - (state: AppState) => state.globalThemeInfo.activeTheme, - (theme: ?GlobalTheme) => { - return theme && theme === 'dark' ? 'white' : 'black'; - }, -); +const indicatorStyleSelector: (state: AppState) => IndicatorStyle = + createSelector( + (state: AppState) => state.globalThemeInfo.activeTheme, + (theme: ?GlobalTheme) => { + return theme && theme === 'dark' ? 'white' : 'black'; + }, + ); export type KeyboardAppearance = 'default' | 'light' | 'dark'; -const keyboardAppearanceSelector: ( - state: AppState, -) => KeyboardAppearance = createSelector( - (state: AppState) => state.globalThemeInfo.activeTheme, - (theme: ?GlobalTheme) => { - return theme && theme === 'dark' ? 'dark' : 'light'; - }, -); +const keyboardAppearanceSelector: (state: AppState) => KeyboardAppearance = + createSelector( + (state: AppState) => state.globalThemeInfo.activeTheme, + (theme: ?GlobalTheme) => { + return theme && theme === 'dark' ? 'dark' : 'light'; + }, + ); function useKeyboardAppearance(): KeyboardAppearance { return useSelector(keyboardAppearanceSelector); diff --git a/native/tooltip/tooltip-context.react.js b/native/tooltip/tooltip-context.react.js --- a/native/tooltip/tooltip-context.react.js +++ b/native/tooltip/tooltip-context.react.js @@ -18,7 +18,8 @@ +shouldShowMore: () => boolean, +getNumVisibleEntries: () => number, }; -const TooltipContext: React.Context<?TooltipContextType> = React.createContext<?TooltipContextType>(); +const TooltipContext: React.Context<?TooltipContextType> = + React.createContext<?TooltipContextType>(); type ProviderProps = { +maxOptionsToDisplay: number, diff --git a/native/tooltip/tooltip.react.js b/native/tooltip/tooltip.react.js --- a/native/tooltip/tooltip.react.js +++ b/native/tooltip/tooltip.react.js @@ -223,11 +223,8 @@ get tooltipContainerStyle() { const { dimensions, route } = this.props; - const { - initialCoordinates, - verticalBounds, - chatInputBarHeight, - } = route.params; + const { initialCoordinates, verticalBounds, chatInputBarHeight } = + route.params; const { x, y, width, height } = initialCoordinates; const { margin, tooltipLocation } = this; diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "lint-staged": "^12.1.4", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.0.0", - "prettier": "^2.1.2" + "prettier": "^2.8.4" }, "resolutions": { "react-native-flipper": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz" diff --git a/services/docker-compose.yml b/services/docker-compose.yml --- a/services/docker-compose.yml +++ b/services/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.9" +version: '3.9' volumes: localstack: services: @@ -15,7 +15,7 @@ - COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} image: commapp/tunnelbroker-server:0.2 ports: - - "${COMM_SERVICES_PORT_TUNNELBROKER}:50051" + - '${COMM_SERVICES_PORT_TUNNELBROKER}:50051' volumes: - $HOME/.aws/config:/root/.aws/config:ro - $HOME/.aws/credentials:/root/.aws/credentials:ro @@ -36,7 +36,7 @@ - BLOB_SERVICE_URL=http://blob-server:50051 image: commapp/backup-server:0.1 ports: - - "${COMM_SERVICES_PORT_BACKUP}:50051" + - '${COMM_SERVICES_PORT_BACKUP}:50051' volumes: - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro # blob @@ -51,7 +51,7 @@ - COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} image: commapp/blob-server:0.1 ports: - - "${COMM_SERVICES_PORT_BLOB}:50051" + - '${COMM_SERVICES_PORT_BLOB}:50051' volumes: - $HOME/.aws/config:/home/comm/.aws/config:ro - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro @@ -64,13 +64,13 @@ context: ../ image: commapp/identity-server:0.1 ports: - - "${COMM_SERVICES_PORT_IDENTITY}:50051" + - '${COMM_SERVICES_PORT_IDENTITY}:50051' # localstack localstack: image: localstack/localstack hostname: localstack ports: - - "4566:4566" + - '4566:4566' environment: - SERVICES=s3,dynamodb - DATA_DIR=/tmp/localstack @@ -82,9 +82,9 @@ image: rabbitmq:3-management hostname: rabbitmq ports: - - "5672:5672" - - "5671:5671" - - "15672:15672" + - '5672:5672' + - '5671:5671' + - '15672:15672' environment: - RABBITMQ_DEFAULT_USER=comm - RABBITMQ_DEFAULT_PASS=comm diff --git a/services/electron-update-server/flow-typed/npm/express_v4.17.x.js b/services/electron-update-server/flow-typed/npm/express_v4.17.x.js --- a/services/electron-update-server/flow-typed/npm/express_v4.17.x.js +++ b/services/electron-update-server/flow-typed/npm/express_v4.17.x.js @@ -53,7 +53,8 @@ */ declare class express$Request extends http$IncomingMessage - mixins express$RequestResponseBase { + mixins express$RequestResponseBase +{ baseUrl: string; body: mixed; cookies: { [cookie: string]: string, ... }; @@ -119,7 +120,8 @@ declare class express$Response extends http$ServerResponse - mixins express$RequestResponseBase { + mixins express$RequestResponseBase +{ headersSent: boolean; locals: { [name: string]: mixed, ... }; append(field: string, value?: string): this; @@ -229,7 +231,8 @@ Req: express$Request = express$Request, Res: express$Response = express$Response, > - extends express$Route<Req, Res> { + extends express$Route<Req, Res> +{ constructor(options?: express$RouterOptions): void; route(path: string): express$Route<Req, Res>; static <Req2: express$Request, Res2: express$Response>( @@ -279,7 +282,8 @@ Res: express$Response = express$Response, > extends express$Router<Req, Res> - mixins events$EventEmitter { + mixins events$EventEmitter +{ constructor(): void; locals: { [name: string]: mixed, ... }; mountpath: string; diff --git a/shared/protos/_generated/.clang-format b/shared/protos/_generated/.clang-format --- a/shared/protos/_generated/.clang-format +++ b/shared/protos/_generated/.clang-format @@ -1,4 +1,3 @@ --- DisableFormat: true SortIncludes: false - diff --git a/web/account/log-in-form.react.js b/web/account/log-in-form.react.js --- a/web/account/log-in-form.react.js +++ b/web/account/log-in-form.react.js @@ -42,10 +42,8 @@ })(); }, [dispatch, primaryIdentityPublicKey]); - const [ - siweAuthFlowSelected, - setSIWEAuthFlowSelected, - ] = React.useState<boolean>(false); + const [siweAuthFlowSelected, setSIWEAuthFlowSelected] = + React.useState<boolean>(false); const onSIWEButtonClick = React.useCallback(() => { setSIWEAuthFlowSelected(true); diff --git a/web/calendar/entry.react.js b/web/calendar/entry.react.js --- a/web/calendar/entry.react.js +++ b/web/calendar/entry.react.js @@ -271,17 +271,16 @@ this.setState({ text: target.value }, this.updateHeight); }; - onKeyDown: ( - event: SyntheticKeyboardEvent<HTMLTextAreaElement>, - ) => void = event => { - if (event.key === 'Escape') { - invariant( - this.textarea instanceof HTMLTextAreaElement, - 'textarea ref not set', - ); - this.textarea.blur(); - } - }; + onKeyDown: (event: SyntheticKeyboardEvent<HTMLTextAreaElement>) => void = + event => { + if (event.key === 'Escape') { + invariant( + this.textarea instanceof HTMLTextAreaElement, + 'textarea ref not set', + ); + this.textarea.blur(); + } + }; dispatchSave(serverID: ?string, newText: string) { if (this.currentlySaving === newText) { diff --git a/web/chat/chat-input-bar.react.js b/web/chat/chat-input-bar.react.js --- a/web/chat/chat-input-bar.react.js +++ b/web/chat/chat-input-bar.react.js @@ -417,12 +417,8 @@ }; onKeyDown = (event: SyntheticKeyboardEvent<HTMLTextAreaElement>) => { - const { - accept, - close, - moveChoiceUp, - moveChoiceDown, - } = this.props.inputState.typeaheadState; + const { accept, close, moveChoiceUp, moveChoiceDown } = + this.props.inputState.typeaheadState; const actions = { Enter: accept, @@ -529,12 +525,11 @@ const joinThreadLoadingStatusSelector = createLoadingStatusSelector( joinThreadActionTypes, ); -const createThreadLoadingStatusSelector = createLoadingStatusSelector( - newThreadActionTypes, -); +const createThreadLoadingStatusSelector = + createLoadingStatusSelector(newThreadActionTypes); -const ConnectedChatInputBar: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedChatInputBar(props) { +const ConnectedChatInputBar: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedChatInputBar(props) { const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, ); @@ -596,22 +591,23 @@ props.inputState.typeaheadState.keepUpdatingThreadMembers, ]); - const suggestedUsers: $ReadOnlyArray<RelativeMemberInfo> = React.useMemo(() => { - if (!typeaheadMatchedStrings) { - return []; - } - return getTypeaheadUserSuggestions( + const suggestedUsers: $ReadOnlyArray<RelativeMemberInfo> = + React.useMemo(() => { + if (!typeaheadMatchedStrings) { + return []; + } + return getTypeaheadUserSuggestions( + userSearchIndex, + props.inputState.typeaheadState.frozenThreadMembers, + viewerID, + typeaheadMatchedStrings.usernamePrefix, + ); + }, [ userSearchIndex, props.inputState.typeaheadState.frozenThreadMembers, viewerID, - typeaheadMatchedStrings.usernamePrefix, - ); - }, [ - userSearchIndex, - props.inputState.typeaheadState.frozenThreadMembers, - viewerID, - typeaheadMatchedStrings, - ]); + typeaheadMatchedStrings, + ]); return ( <ChatInputBar @@ -629,7 +625,6 @@ suggestedUsers={suggestedUsers} /> ); - }, -); + }); export default ConnectedChatInputBar; diff --git a/web/chat/chat-message-list.react.js b/web/chat/chat-message-list.react.js --- a/web/chat/chat-message-list.react.js +++ b/web/chat/chat-message-list.react.js @@ -277,8 +277,10 @@ registerFetchKey(fetchMessagesBeforeCursorActionTypes); registerFetchKey(fetchMostRecentMessagesActionTypes); -const ConnectedChatMessageList: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedChatMessageList(props: BaseProps): React.Node { +const ConnectedChatMessageList: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedChatMessageList( + props: BaseProps, + ): React.Node { const { threadInfo } = props; const messageListData = useMessageListData({ threadInfo, @@ -336,7 +338,6 @@ /> </MessageListContext.Provider> ); - }, -); + }); export default ConnectedChatMessageList; diff --git a/web/chat/chat-thread-list.react.js b/web/chat/chat-thread-list.react.js --- a/web/chat/chat-thread-list.react.js +++ b/web/chat/chat-thread-list.react.js @@ -20,12 +20,8 @@ threadListContext, 'threadListContext should be set in ChatThreadList', ); - const { - activeTab, - threadList, - setSearchText, - searchText, - } = threadListContext; + const { activeTab, threadList, setSearchText, searchText } = + threadListContext; const onClickNewThread = useOnClickNewThread(); diff --git a/web/chat/composed-message.react.js b/web/chat/composed-message.react.js --- a/web/chat/composed-message.react.js +++ b/web/chat/composed-message.react.js @@ -163,8 +163,8 @@ BaseProps, typeof ComposedMessage.defaultProps, >; -const ConnectedComposedMessage: React.ComponentType<ConnectedConfig> = React.memo<BaseConfig>( - function ConnectedComposedMessage(props) { +const ConnectedComposedMessage: React.ComponentType<ConnectedConfig> = + React.memo<BaseConfig>(function ConnectedComposedMessage(props) { const { item, threadInfo } = props; const inputState = React.useContext(InputStateContext); const { creator } = props.item.messageInfo; @@ -193,7 +193,6 @@ stringForUser={stringForUser} /> ); - }, -); + }); export default ConnectedComposedMessage; diff --git a/web/chat/failed-send.react.js b/web/chat/failed-send.react.js --- a/web/chat/failed-send.react.js +++ b/web/chat/failed-send.react.js @@ -128,8 +128,8 @@ }; } -const ConnectedFailedSend: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedFailedSend(props) { +const ConnectedFailedSend: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedFailedSend(props) { const { messageInfo } = props.item; assertComposableMessageType(messageInfo.type); const id = messageID(messageInfo); @@ -151,7 +151,6 @@ inputState={inputState} /> ); - }, -); + }); export default ConnectedFailedSend; diff --git a/web/chat/message-list-types.js b/web/chat/message-list-types.js --- a/web/chat/message-list-types.js +++ b/web/chat/message-list-types.js @@ -8,4 +8,5 @@ +getTextMessageMarkdownRules: (useDarkStyle: boolean) => MarkdownRules, }; -export const MessageListContext: React.Context<?MessageListContextType> = React.createContext<?MessageListContextType>(); +export const MessageListContext: React.Context<?MessageListContextType> = + React.createContext<?MessageListContextType>(); diff --git a/web/chat/multimedia-message.react.js b/web/chat/multimedia-message.react.js --- a/web/chat/multimedia-message.react.js +++ b/web/chat/multimedia-message.react.js @@ -72,11 +72,10 @@ } } -const ConnectedMultimediaMessage: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedMultimediaMessage(props) { +const ConnectedMultimediaMessage: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedMultimediaMessage(props) { const inputState = React.useContext(InputStateContext); return <MultimediaMessage {...props} inputState={inputState} />; - }, -); + }); export default ConnectedMultimediaMessage; diff --git a/web/chat/relationship-prompt/relationship-prompt.js b/web/chat/relationship-prompt/relationship-prompt.js --- a/web/chat/relationship-prompt/relationship-prompt.js +++ b/web/chat/relationship-prompt/relationship-prompt.js @@ -104,8 +104,7 @@ } } -const MemoizedRelationshipPrompt: React.ComponentType<Props> = React.memo( - RelationshipPrompt, -); +const MemoizedRelationshipPrompt: React.ComponentType<Props> = + React.memo(RelationshipPrompt); export default MemoizedRelationshipPrompt; diff --git a/web/chat/robotext-message.react.js b/web/chat/robotext-message.react.js --- a/web/chat/robotext-message.react.js +++ b/web/chat/robotext-message.react.js @@ -137,8 +137,7 @@ return <span style={colorStyle}>{props.color}</span>; } -const MemoizedRobotextMessage: React.ComponentType<Props> = React.memo<Props>( - RobotextMessage, -); +const MemoizedRobotextMessage: React.ComponentType<Props> = + React.memo<Props>(RobotextMessage); export default MemoizedRobotextMessage; diff --git a/web/chat/thread-list-provider.js b/web/chat/thread-list-provider.js --- a/web/chat/thread-list-provider.js +++ b/web/chat/thread-list-provider.js @@ -33,7 +33,8 @@ +setSearchText: (searchText: string) => void, }; -const ThreadListContext: React.Context<?ThreadListContextType> = React.createContext<?ThreadListContextType>(); +const ThreadListContext: React.Context<?ThreadListContextType> = + React.createContext<?ThreadListContextType>(); type ThreadListProviderProps = { +children: React.Node, @@ -205,9 +206,8 @@ ...threadListWithTopLevelItem, ]; } - const threadListWithCurrentPendingThread = makeSureActivePendingThreadIsIncluded( - threadListWithTopLevelItem, - ); + const threadListWithCurrentPendingThread = + makeSureActivePendingThreadIsIncluded(threadListWithTopLevelItem); return makeSureActiveSidebarIsIncluded(threadListWithCurrentPendingThread); }, [ activeTab, diff --git a/web/chat/tooltip-provider.js b/web/chat/tooltip-provider.js --- a/web/chat/tooltip-provider.js +++ b/web/chat/tooltip-provider.js @@ -30,8 +30,8 @@ +setRenderEmojiKeyboard: SetState<boolean>, }; -const TooltipContext: React.Context<TooltipContextType> = React.createContext<TooltipContextType>( - { +const TooltipContext: React.Context<TooltipContextType> = + React.createContext<TooltipContextType>({ renderTooltip: () => ({ onMouseLeaveCallback: () => {}, clearTooltip: () => {}, @@ -40,8 +40,7 @@ clearTooltip: () => {}, renderEmojiKeyboard: false, setRenderEmojiKeyboard: () => {}, - }, -); + }); type Props = { +children: React.Node, @@ -52,13 +51,10 @@ const tooltipCancelTimer = React.useRef<?TimeoutID>(null); const [tooltipNode, setTooltipNode] = React.useState<React.Node>(null); - const [ - tooltipPosition, - setTooltipPosition, - ] = React.useState<?TooltipPositionStyle>(null); - const [renderEmojiKeyboard, setRenderEmojiKeyboard] = React.useState<boolean>( - false, - ); + const [tooltipPosition, setTooltipPosition] = + React.useState<?TooltipPositionStyle>(null); + const [renderEmojiKeyboard, setRenderEmojiKeyboard] = + React.useState<boolean>(false); const clearTooltip = React.useCallback((tooltipToClose: symbol) => { if (tooltipSymbol.current !== tooltipToClose) { diff --git a/web/chat/typeahead-tooltip.react.js b/web/chat/typeahead-tooltip.react.js --- a/web/chat/typeahead-tooltip.react.js +++ b/web/chat/typeahead-tooltip.react.js @@ -28,14 +28,11 @@ const { textBeforeAtSymbol, usernamePrefix } = matchedStrings; - const [isVisibleForAnimation, setIsVisibleForAnimation] = React.useState( - false, - ); + const [isVisibleForAnimation, setIsVisibleForAnimation] = + React.useState(false); - const [ - chosenPositionInOverlay, - setChosenPositionInOverlay, - ] = React.useState<number>(0); + const [chosenPositionInOverlay, setChosenPositionInOverlay] = + React.useState<number>(0); const overlayRef = React.useRef<?HTMLDivElement>(); diff --git a/web/components/enum-settings-option-info.react.js b/web/components/enum-settings-option-info.react.js --- a/web/components/enum-settings-option-info.react.js +++ b/web/components/enum-settings-option-info.react.js @@ -15,12 +15,8 @@ }; function EnumSettingsOptionInfo(props: Props): React.Node { - const { - optionSelected, - valid, - styleStatementBasedOnValidity, - children, - } = props; + const { optionSelected, valid, styleStatementBasedOnValidity, children } = + props; const optionInfoClasses = classnames({ [css.optionInfo]: true, diff --git a/web/components/menu-item.react.js b/web/components/menu-item.react.js --- a/web/components/menu-item.react.js +++ b/web/components/menu-item.react.js @@ -34,8 +34,7 @@ ); } -const MemoizedMenuItem: React.ComponentType<MenuItemProps> = React.memo( - MenuItem, -); +const MemoizedMenuItem: React.ComponentType<MenuItemProps> = + React.memo(MenuItem); export default MemoizedMenuItem; diff --git a/web/components/search.react.js b/web/components/search.react.js --- a/web/components/search.react.js +++ b/web/components/search.react.js @@ -48,9 +48,7 @@ ); } -const ForwardedSearch: React.AbstractComponent< - Props, - HTMLInputElement, -> = React.forwardRef<Props, HTMLInputElement>(Search); +const ForwardedSearch: React.AbstractComponent<Props, HTMLInputElement> = + React.forwardRef<Props, HTMLInputElement>(Search); export default ForwardedSearch; diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -302,9 +302,8 @@ const currentlyCompleted = InputStateContainer.completedMessageIDs( this.state, ); - const previouslyCompleted = InputStateContainer.completedMessageIDs( - prevState, - ); + const previouslyCompleted = + InputStateContainer.completedMessageIDs(prevState); for (const messageID of currentlyCompleted) { if (previouslyCompleted.has(messageID)) { continue; @@ -490,9 +489,8 @@ let threadPendingUploads = []; const assignedUploads = {}; if (pendingUploads) { - const [uploadsWithMessageIDs, uploadsWithoutMessageIDs] = _partition( - 'messageID', - )(pendingUploads); + const [uploadsWithMessageIDs, uploadsWithoutMessageIDs] = + _partition('messageID')(pendingUploads); threadPendingUploads = _sortBy('localID')(uploadsWithoutMessageIDs); const threadAssignedUploads = _groupBy('messageID')( uploadsWithMessageIDs, @@ -759,9 +757,8 @@ const result = uploadResult; const successThreadID = this.getRealizedOrPendingThreadID(threadID); - const uploadAfterSuccess = this.state.pendingUploads[successThreadID][ - localID - ]; + const uploadAfterSuccess = + this.state.pendingUploads[successThreadID][localID]; invariant( uploadAfterSuccess, `pendingUpload ${localID}/${result.id} for ${successThreadID} missing ` + @@ -809,9 +806,8 @@ sendReport({ success: true }); const preloadThreadID = this.getRealizedOrPendingThreadID(threadID); - const uploadAfterPreload = this.state.pendingUploads[preloadThreadID][ - localID - ]; + const uploadAfterPreload = + this.state.pendingUploads[preloadThreadID][localID]; invariant( uploadAfterPreload, `pendingUpload ${localID}/${result.id} for ${preloadThreadID} missing ` + @@ -1312,8 +1308,8 @@ } } -const ConnectedInputStateContainer: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedInputStateContainer(props) { +const ConnectedInputStateContainer: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedInputStateContainer(props) { const activeChatThreadID = useSelector( state => state.navInfo.activeChatThreadID, ); @@ -1376,7 +1372,6 @@ unregisterSendCallback={unregisterSendCallback} /> ); - }, -); + }); export default ConnectedInputStateContainer; diff --git a/web/input/input-state.js b/web/input/input-state.js --- a/web/input/input-state.js +++ b/web/input/input-state.js @@ -75,8 +75,7 @@ +unregisterSendCallback: (() => mixed) => void, }; -const InputStateContext: React.Context<?InputState> = React.createContext<?InputState>( - null, -); +const InputStateContext: React.Context<?InputState> = + React.createContext<?InputState>(null); export { InputStateContext }; diff --git a/web/markdown/markdown-spoiler.react.js b/web/markdown/markdown-spoiler.react.js --- a/web/markdown/markdown-spoiler.react.js +++ b/web/markdown/markdown-spoiler.react.js @@ -33,8 +33,7 @@ ); } -const MemoizedMarkdownSpoiler: React.ComponentType<MarkdownSpoilerProps> = React.memo<MarkdownSpoilerProps>( - MarkdownSpoiler, -); +const MemoizedMarkdownSpoiler: React.ComponentType<MarkdownSpoilerProps> = + React.memo<MarkdownSpoilerProps>(MarkdownSpoiler); export default MemoizedMarkdownSpoiler; diff --git a/web/media/blob-utils.js b/web/media/blob-utils.js --- a/web/media/blob-utils.js +++ b/web/media/blob-utils.js @@ -34,9 +34,7 @@ file: File, mediaType: MediaType, }; -async function probeFile( - file: File, -): Promise<{ +async function probeFile(file: File): Promise<{ steps: $ReadOnlyArray<MediaMissionStep>, result: MediaMissionFailure | ProbeFileSuccess, }> { diff --git a/web/media/media-utils.js b/web/media/media-utils.js --- a/web/media/media-utils.js +++ b/web/media/media-utils.js @@ -11,9 +11,7 @@ import { probeFile } from './blob-utils.js'; import { getOrientation } from './image-utils.js'; -async function preloadImage( - uri: string, -): Promise<{ +async function preloadImage(uri: string): Promise<{ steps: $ReadOnlyArray<MediaMissionStep>, result: ?Image, }> { diff --git a/web/media/multimedia-modal.react.js b/web/media/multimedia-modal.react.js --- a/web/media/multimedia-modal.react.js +++ b/web/media/multimedia-modal.react.js @@ -47,21 +47,19 @@ this.overlay = overlay; }; - onBackgroundClick: ( - event: SyntheticEvent<HTMLDivElement>, - ) => void = event => { - if (event.target === this.overlay) { - this.props.popModal(); - } - }; + onBackgroundClick: (event: SyntheticEvent<HTMLDivElement>) => void = + event => { + if (event.target === this.overlay) { + this.props.popModal(); + } + }; - onKeyDown: ( - event: SyntheticKeyboardEvent<HTMLDivElement>, - ) => void = event => { - if (event.key === 'Escape') { - this.props.popModal(); - } - }; + onKeyDown: (event: SyntheticKeyboardEvent<HTMLDivElement>) => void = + event => { + if (event.key === 'Escape') { + this.props.popModal(); + } + }; } function ConnectedMultiMediaModal(props: BaseProps): React.Node { diff --git a/web/menu-provider.react.js b/web/menu-provider.react.js --- a/web/menu-provider.react.js +++ b/web/menu-provider.react.js @@ -17,20 +17,19 @@ type MenuContextType = { +renderMenu: React.Node => void, +setMenuPosition: SetState<MenuPosition>, - +closeMenu: (symbol) => void, + +closeMenu: symbol => void, +currentOpenMenu: ?symbol, - +setCurrentOpenMenu: (symbol) => void, + +setCurrentOpenMenu: symbol => void, }; -const MenuContext: React.Context<MenuContextType> = React.createContext<MenuContextType>( - { +const MenuContext: React.Context<MenuContextType> = + React.createContext<MenuContextType>({ renderMenu: () => {}, setMenuPosition: () => {}, closeMenu: () => {}, currentOpenMenu: null, setCurrentOpenMenu: () => {}, - }, -); + }); type Menu = { +node: ?React.Node, diff --git a/web/modals/history/history-entry.react.js b/web/modals/history/history-entry.react.js --- a/web/modals/history/history-entry.react.js +++ b/web/modals/history/history-entry.react.js @@ -146,8 +146,8 @@ } } -const ConnectedHistoryEntry: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedHistoryEntry(props) { +const ConnectedHistoryEntry: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedHistoryEntry(props) { const entryID = props.entryInfo.id; invariant(entryID, 'entryInfo.id (serverID) should be set'); const unresolvedThreadInfo = useSelector( @@ -183,7 +183,6 @@ creator={creatorWithENSName} /> ); - }, -); + }); export default ConnectedHistoryEntry; diff --git a/web/modals/history/history-modal.react.js b/web/modals/history/history-modal.react.js --- a/web/modals/history/history-modal.react.js +++ b/web/modals/history/history-modal.react.js @@ -251,8 +251,8 @@ fetchRevisionsForEntryActionTypes, ); -const ConnectedHistoryModal: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedHistoryModal(props) { +const ConnectedHistoryModal: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedHistoryModal(props) { const entryInfos = useSelector( state => allDaysToEntries(state)[props.dayString], ); @@ -279,7 +279,6 @@ onClose={modalContext.popModal} /> ); - }, -); + }); export default ConnectedHistoryModal; diff --git a/web/modals/input.react.js b/web/modals/input.react.js --- a/web/modals/input.react.js +++ b/web/modals/input.react.js @@ -56,9 +56,7 @@ ); } -const ForwardedInput: React.AbstractComponent< - InputProps, - HTMLInputElement, -> = React.forwardRef<InputProps, HTMLInputElement>(Input); +const ForwardedInput: React.AbstractComponent<InputProps, HTMLInputElement> = + React.forwardRef<InputProps, HTMLInputElement>(Input); export default ForwardedInput; diff --git a/web/modals/search-modal.react.js b/web/modals/search-modal.react.js --- a/web/modals/search-modal.react.js +++ b/web/modals/search-modal.react.js @@ -15,10 +15,10 @@ function SearchModal(props: Props): React.Node { const [searchText, setSearchText] = React.useState(''); const { children, searchPlaceholder, ...modalProps } = props; - const child = React.useMemo(() => children(searchText), [ - children, - searchText, - ]); + const child = React.useMemo( + () => children(searchText), + [children, searchText], + ); return ( <Modal {...modalProps}> diff --git a/web/modals/threads/create/compose-subchannel-modal.react.js b/web/modals/threads/create/compose-subchannel-modal.react.js --- a/web/modals/threads/create/compose-subchannel-modal.react.js +++ b/web/modals/threads/create/compose-subchannel-modal.react.js @@ -57,9 +57,8 @@ ); } -const createSubchannelLoadingStatusSelector = createLoadingStatusSelector( - newThreadActionTypes, -); +const createSubchannelLoadingStatusSelector = + createLoadingStatusSelector(newThreadActionTypes); function ComposeSubchannelModal(props: Props): React.Node { const { parentThreadInfo, onClose } = props; @@ -68,9 +67,8 @@ const [activeStep, setActiveStep] = React.useState<Steps>('settings'); const [channelName, setChannelName] = React.useState<string>(''); - const [visibilityType, setVisibilityType] = React.useState<VisibilityType>( - 'open', - ); + const [visibilityType, setVisibilityType] = + React.useState<VisibilityType>('open'); const [announcement, setAnnouncement] = React.useState<boolean>(false); const [selectedUsers, setSelectedUsers] = React.useState< $ReadOnlySet<string>, diff --git a/web/modals/threads/create/steps/subchannel-members-list.react.js b/web/modals/threads/create/steps/subchannel-members-list.react.js --- a/web/modals/threads/create/steps/subchannel-members-list.react.js +++ b/web/modals/threads/create/steps/subchannel-members-list.react.js @@ -31,10 +31,8 @@ const { members: parentMembers } = parentThreadInfo; - const { - members: communityMembers, - name: communityName, - } = communityThreadInfo; + const { members: communityMembers, name: communityName } = + communityThreadInfo; const currentUserId = useSelector(state => state.currentUserInfo.id); diff --git a/web/modals/threads/members/add-members-list-content.react.js b/web/modals/threads/members/add-members-list-content.react.js --- a/web/modals/threads/members/add-members-list-content.react.js +++ b/web/modals/threads/members/add-members-list-content.react.js @@ -16,12 +16,8 @@ }; function AddMembersListContent(props: Props): React.Node { - const { - userListItems, - pendingUsersToAdd, - switchUser, - hasParentThread, - } = props; + const { userListItems, pendingUsersToAdd, switchUser, hasParentThread } = + props; const usersAvailableToAdd = React.useMemo( () => userListItems.filter(user => !user.alertText), diff --git a/web/modals/threads/notifications/notifications-modal.react.js b/web/modals/threads/notifications/notifications-modal.react.js --- a/web/modals/threads/notifications/notifications-modal.react.js +++ b/web/modals/threads/notifications/notifications-modal.react.js @@ -108,10 +108,8 @@ return 'focused'; }, [subscription.home, subscription.pushNotifs]); - const [ - notificationSettings, - setNotificationSettings, - ] = React.useState<NotificationSettings>(initialThreadSetting); + const [notificationSettings, setNotificationSettings] = + React.useState<NotificationSettings>(initialThreadSetting); const onFocusedSelected = React.useCallback( () => setNotificationSettings('focused'), diff --git a/web/modals/threads/settings/thread-settings-modal.react.js b/web/modals/threads/settings/thread-settings-modal.react.js --- a/web/modals/threads/settings/thread-settings-modal.react.js +++ b/web/modals/threads/settings/thread-settings-modal.react.js @@ -45,8 +45,8 @@ changeThreadSettingsActionTypes, ); -const ConnectedThreadSettingsModal: React.ComponentType<BaseProps> = React.memo<BaseProps>( - function ConnectedThreadSettingsModal(props) { +const ConnectedThreadSettingsModal: React.ComponentType<BaseProps> = + React.memo<BaseProps>(function ConnectedThreadSettingsModal(props) { const changeInProgress = useSelector( state => deleteThreadLoadingStatusSelector(state) === 'loading' || @@ -57,9 +57,8 @@ ); const modalContext = useModalContext(); const [errorMessage, setErrorMessage] = React.useState<?string>(''); - const [currentTabType, setCurrentTabType] = React.useState<TabType>( - 'general', - ); + const [currentTabType, setCurrentTabType] = + React.useState<TabType>('general'); const [queuedChanges, setQueuedChanges] = React.useState<ThreadChanges>( Object.freeze({}), ); @@ -232,7 +231,6 @@ </div> </Modal> ); - }, -); + }); export default ConnectedThreadSettingsModal; diff --git a/web/modals/threads/sidebars/sidebar.react.js b/web/modals/threads/sidebars/sidebar.react.js --- a/web/modals/threads/sidebars/sidebar.react.js +++ b/web/modals/threads/sidebars/sidebar.react.js @@ -41,9 +41,10 @@ [css.unread]: unread, }); - const lastActivity = React.useMemo(() => shortAbsoluteDate(lastUpdatedTime), [ - lastUpdatedTime, - ]); + const lastActivity = React.useMemo( + () => shortAbsoluteDate(lastUpdatedTime), + [lastUpdatedTime], + ); const messagePreviewResult = useMessagePreview( mostRecentMessageInfo, diff --git a/web/redux/nav-reducer.js b/web/redux/nav-reducer.js --- a/web/redux/nav-reducer.js +++ b/web/redux/nav-reducer.js @@ -23,9 +23,8 @@ const { activeChatThreadID } = state; if (activeChatThreadID) { - const pendingToRealizedThreadIDs = pendingToRealizedThreadIDsSelector( - newThreadInfos, - ); + const pendingToRealizedThreadIDs = + pendingToRealizedThreadIDsSelector(newThreadInfos); const realizedThreadID = pendingToRealizedThreadIDs.get(activeChatThreadID); if (realizedThreadID) { state = { diff --git a/web/selectors/account-selectors.js b/web/selectors/account-selectors.js --- a/web/selectors/account-selectors.js +++ b/web/selectors/account-selectors.js @@ -7,15 +7,16 @@ import type { AppState } from '../redux/redux-setup.js'; -const webLogInExtraInfoSelector: ( - state: AppState, -) => () => LogInExtraInfo = createSelector( - logInExtraInfoSelector, - (state: AppState) => state.navInfo.tab === 'calendar', - ( - logInExtraInfoFunc: (calendarActive: boolean) => LogInExtraInfo, - calendarActive: boolean, - ) => () => logInExtraInfoFunc(calendarActive), -); +const webLogInExtraInfoSelector: (state: AppState) => () => LogInExtraInfo = + createSelector( + logInExtraInfoSelector, + (state: AppState) => state.navInfo.tab === 'calendar', + ( + logInExtraInfoFunc: (calendarActive: boolean) => LogInExtraInfo, + calendarActive: boolean, + ) => + () => + logInExtraInfoFunc(calendarActive), + ); export { webLogInExtraInfoSelector }; diff --git a/web/selectors/chat-selectors.js b/web/selectors/chat-selectors.js --- a/web/selectors/chat-selectors.js +++ b/web/selectors/chat-selectors.js @@ -19,42 +19,41 @@ import type { AppState } from '../redux/redux-setup.js'; import { useSelector } from '../redux/redux-utils.js'; -const activeChatThreadItem: ( - state: AppState, -) => ?ChatThreadItem = createSelector( - threadInfoSelector, - (state: AppState) => state.messageStore, - messageInfoSelector, - (state: AppState) => state.navInfo.activeChatThreadID, - (state: AppState) => state.navInfo.pendingThread, - sidebarInfoSelector, - ( - threadInfos: { +[id: string]: ThreadInfo }, - messageStore: MessageStore, - messageInfos: { +[id: string]: ?MessageInfo }, - activeChatThreadID: ?string, - pendingThreadInfo: ?ThreadInfo, - sidebarInfos: { +[id: string]: $ReadOnlyArray<SidebarInfo> }, - ): ?ChatThreadItem => { - if (!activeChatThreadID) { - return null; - } - const isPending = threadIsPending(activeChatThreadID); - const threadInfo = isPending - ? pendingThreadInfo - : threadInfos[activeChatThreadID]; +const activeChatThreadItem: (state: AppState) => ?ChatThreadItem = + createSelector( + threadInfoSelector, + (state: AppState) => state.messageStore, + messageInfoSelector, + (state: AppState) => state.navInfo.activeChatThreadID, + (state: AppState) => state.navInfo.pendingThread, + sidebarInfoSelector, + ( + threadInfos: { +[id: string]: ThreadInfo }, + messageStore: MessageStore, + messageInfos: { +[id: string]: ?MessageInfo }, + activeChatThreadID: ?string, + pendingThreadInfo: ?ThreadInfo, + sidebarInfos: { +[id: string]: $ReadOnlyArray<SidebarInfo> }, + ): ?ChatThreadItem => { + if (!activeChatThreadID) { + return null; + } + const isPending = threadIsPending(activeChatThreadID); + const threadInfo = isPending + ? pendingThreadInfo + : threadInfos[activeChatThreadID]; - if (!threadInfo) { - return null; - } - return createChatThreadItem( - threadInfo, - messageStore, - messageInfos, - sidebarInfos[threadInfo.id], - ); - }, -); + if (!threadInfo) { + return null; + } + return createChatThreadItem( + threadInfo, + messageStore, + messageInfos, + sidebarInfos[threadInfo.id], + ); + }, + ); function useChatThreadItem(threadInfo: ?ThreadInfo): ?ChatThreadItem { const messageInfos = useSelector(messageInfoSelector); diff --git a/web/selectors/entry-selectors.js b/web/selectors/entry-selectors.js --- a/web/selectors/entry-selectors.js +++ b/web/selectors/entry-selectors.js @@ -11,9 +11,9 @@ import type { AppState } from '../redux/redux-setup.js'; -const allDaysToEntries: ( - state: AppState, -) => { +[dayString: string]: EntryInfo[] } = createSelector( +const allDaysToEntries: (state: AppState) => { + +[dayString: string]: EntryInfo[], +} = createSelector( entryInfoSelector, (state: AppState) => state.entryStore.daysToEntries, ( diff --git a/web/selectors/nav-selectors.js b/web/selectors/nav-selectors.js --- a/web/selectors/nav-selectors.js +++ b/web/selectors/nav-selectors.js @@ -86,36 +86,36 @@ return state.navInfo.tab === 'chat' ? state.navInfo.activeChatThreadID : null; } -const webCalendarQuery: ( - state: AppState, -) => () => CalendarQuery = createSelector( - currentCalendarQuery, - (state: AppState) => state.navInfo.tab === 'calendar', - ( - calendarQuery: (calendarActive: boolean) => CalendarQuery, - calendarActive: boolean, - ) => () => calendarQuery(calendarActive), -); +const webCalendarQuery: (state: AppState) => () => CalendarQuery = + createSelector( + currentCalendarQuery, + (state: AppState) => state.navInfo.tab === 'calendar', + ( + calendarQuery: (calendarActive: boolean) => CalendarQuery, + calendarActive: boolean, + ) => + () => + calendarQuery(calendarActive), + ); -const nonThreadCalendarQuery: ( - state: AppState, -) => () => CalendarQuery = createSelector( - webCalendarQuery, - nonThreadCalendarFiltersSelector, - ( - calendarQuery: () => CalendarQuery, - filters: $ReadOnlyArray<CalendarFilter>, - ) => { - return (): CalendarQuery => { - const query = calendarQuery(); - return { - startDate: query.startDate, - endDate: query.endDate, - filters, +const nonThreadCalendarQuery: (state: AppState) => () => CalendarQuery = + createSelector( + webCalendarQuery, + nonThreadCalendarFiltersSelector, + ( + calendarQuery: () => CalendarQuery, + filters: $ReadOnlyArray<CalendarFilter>, + ) => { + return (): CalendarQuery => { + const query = calendarQuery(); + return { + startDate: query.startDate, + endDate: query.endDate, + filters, + }; }; - }; - }, -); + }, + ); function navTabSelector(state: AppState): NavigationTab { return state.navInfo.tab; diff --git a/web/selectors/socket-selectors.js b/web/selectors/socket-selectors.js --- a/web/selectors/socket-selectors.js +++ b/web/selectors/socket-selectors.js @@ -39,26 +39,28 @@ getClientResponsesSelector, (state: AppState) => state.navInfo.tab === 'calendar', ( - getClientResponsesFunc: ( + getClientResponsesFunc: ( + calendarActive: boolean, + oneTimeKeyGenerator: ?OneTimeKeyGenerator, + serverRequests: $ReadOnlyArray<ClientServerRequest>, + ) => $ReadOnlyArray<ClientClientResponse>, calendarActive: boolean, - oneTimeKeyGenerator: ?OneTimeKeyGenerator, - serverRequests: $ReadOnlyArray<ClientServerRequest>, - ) => $ReadOnlyArray<ClientClientResponse>, - calendarActive: boolean, - ) => (serverRequests: $ReadOnlyArray<ClientServerRequest>) => - getClientResponsesFunc(calendarActive, null, serverRequests), + ) => + (serverRequests: $ReadOnlyArray<ClientServerRequest>) => + getClientResponsesFunc(calendarActive, null, serverRequests), ); -const webSessionStateFuncSelector: ( - state: AppState, -) => () => SessionState = createSelector( - sessionStateFuncSelector, - (state: AppState) => state.navInfo.tab === 'calendar', - ( - sessionStateFunc: (calendarActive: boolean) => SessionState, - calendarActive: boolean, - ) => () => sessionStateFunc(calendarActive), -); +const webSessionStateFuncSelector: (state: AppState) => () => SessionState = + createSelector( + sessionStateFuncSelector, + (state: AppState) => state.navInfo.tab === 'calendar', + ( + sessionStateFunc: (calendarActive: boolean) => SessionState, + calendarActive: boolean, + ) => + () => + sessionStateFunc(calendarActive), + ); export { openSocketSelector, diff --git a/web/settings/relationship/add-users-list-item.react.js b/web/settings/relationship/add-users-list-item.react.js --- a/web/settings/relationship/add-users-list-item.react.js +++ b/web/settings/relationship/add-users-list-item.react.js @@ -14,10 +14,10 @@ function AddUsersListItem(props: Props): React.Node { const { userInfo, selectUser } = props; - const addUser = React.useCallback(() => selectUser(userInfo.id), [ - selectUser, - userInfo.id, - ]); + const addUser = React.useCallback( + () => selectUser(userInfo.id), + [selectUser, userInfo.id], + ); return ( <Button className={css.addUserButton} onClick={addUser}> <div className={css.addUserButtonUsername}>{userInfo.username}</div> diff --git a/web/sidebar/community-drawer-item-community.react.js b/web/sidebar/community-drawer-item-community.react.js --- a/web/sidebar/community-drawer-item-community.react.js +++ b/web/sidebar/community-drawer-item-community.react.js @@ -19,7 +19,6 @@ ); } -const MemoizedCommunityDrawerItemCommunity: React.ComponentType<DrawerItemProps> = React.memo( - CommunityDrawerItemCommunity, -); +const MemoizedCommunityDrawerItemCommunity: React.ComponentType<DrawerItemProps> = + React.memo(CommunityDrawerItemCommunity); export default MemoizedCommunityDrawerItemCommunity; diff --git a/web/sidebar/community-drawer-item-handlers.react.js b/web/sidebar/community-drawer-item-handlers.react.js --- a/web/sidebar/community-drawer-item-handlers.react.js +++ b/web/sidebar/community-drawer-item-handlers.react.js @@ -24,10 +24,10 @@ const onClick = useOnClickThread(threadInfo); const isActive = useThreadIsActive(threadInfo.id); - const handler = React.useMemo(() => ({ onClick, isActive }), [ - isActive, - onClick, - ]); + const handler = React.useMemo( + () => ({ onClick, isActive }), + [isActive, onClick], + ); React.useEffect(() => { setHandler(handler); }, [handler, setHandler]); @@ -47,10 +47,10 @@ }, [dispatch, threadInfo.id]); const isActive = useCommunityIsPicked(threadInfo.id); - const handler = React.useMemo(() => ({ onClick, isActive }), [ - onClick, - isActive, - ]); + const handler = React.useMemo( + () => ({ onClick, isActive }), + [onClick, isActive], + ); React.useEffect(() => { setHandler(handler); }, [handler, setHandler]); diff --git a/web/sidebar/community-drawer-item.react.js b/web/sidebar/community-drawer-item.react.js --- a/web/sidebar/community-drawer-item.react.js +++ b/web/sidebar/community-drawer-item.react.js @@ -155,12 +155,10 @@ ); } -const MemoizedCommunityDrawerItemChat: React.ComponentType<CommunityDrawerItemChatProps> = React.memo( - CommunityDrawerItemChat, -); +const MemoizedCommunityDrawerItemChat: React.ComponentType<CommunityDrawerItemChatProps> = + React.memo(CommunityDrawerItemChat); -const MemoizedCommunityDrawerItem: React.ComponentType<DrawerItemProps> = React.memo( - CommunityDrawerItem, -); +const MemoizedCommunityDrawerItem: React.ComponentType<DrawerItemProps> = + React.memo(CommunityDrawerItem); export default MemoizedCommunityDrawerItem; diff --git a/web/socket.react.js b/web/socket.react.js --- a/web/socket.react.js +++ b/web/socket.react.js @@ -23,8 +23,8 @@ webSessionStateFuncSelector, } from './selectors/socket-selectors.js'; -const WebSocket: React.ComponentType<BaseSocketProps> = React.memo<BaseSocketProps>( - function WebSocket(props) { +const WebSocket: React.ComponentType<BaseSocketProps> = + React.memo<BaseSocketProps>(function WebSocket(props) { const cookie = useSelector(state => state.cookie); const urlPrefix = useSelector(state => state.urlPrefix); const connection = useSelector(state => state.connection); @@ -76,7 +76,6 @@ logOut={callLogOut} /> ); - }, -); + }); export default WebSocket; diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -18838,11 +18838,16 @@ resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== -prettier@^2.0.5, prettier@^2.1.2: +prettier@^2.0.5: version "2.1.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg== +prettier@^2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3" + integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw== + pretty-bytes@5.6.0: version "5.6.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb"