diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js index bfa0ea263..87e85f5c3 100644 --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -1,1390 +1,1394 @@ // @flow import type { LogOutResult, KeyserverLogOutResult, LogInStartingPayload, LogInResult, RegisterResult, DefaultNotificationPayload, ClaimUsernameResponse, KeyserverAuthResult, } from './account-types.js'; import type { ActivityUpdateSuccessPayload, QueueActivityUpdatesPayload, SetThreadUnreadStatusPayload, } from './activity-types.js'; import type { UpdateUserAvatarRequest, UpdateUserAvatarResponse, } from './avatar-types.js'; import type { CommunityStore, AddCommunityPayload } from './community-types.js'; -import type { DBOpsStore } from './db-ops-types.js'; +import type { MessageID, DBOpsStore } from './db-ops-types.js'; import type { GetVersionActionPayload, LastCommunicatedPlatformDetails, } from './device-types.js'; import type { DraftStore } from './draft-types.js'; import type { EnabledApps, SupportedApps } from './enabled-apps.js'; import type { RawEntryInfo, EntryStore, SaveEntryPayload, CreateEntryPayload, DeleteEntryResult, RestoreEntryPayload, FetchEntryInfosResult, CalendarQueryUpdateResult, CalendarQueryUpdateStartingPayload, FetchRevisionsForEntryPayload, } from './entry-types.js'; import type { CalendarFilter, CalendarThreadFilter, SetCalendarDeletedFilterPayload, } from './filter-types.js'; import type { IdentityAuthResult } from './identity-service-types.js'; import type { IntegrityStore } from './integrity-types.js'; import type { KeyserverStore, AddKeyserverPayload, RemoveKeyserverPayload, } from './keyserver-types.js'; import type { LifecycleState } from './lifecycle-state-types.js'; import type { FetchInviteLinksResponse, InviteLink, InviteLinksStore, InviteLinkVerificationResponse, DisableInviteLinkPayload, } from './link-types.js'; import type { LoadingStatus, LoadingInfo } from './loading-types.js'; import type { UpdateMultimediaMessageMediaPayload } from './media-types.js'; import type { MessageReportCreationResult } from './message-report-types.js'; import type { MessageStore, RawMultimediaMessageInfo, FetchMessageInfosPayload, SendMessagePayload, EditMessagePayload, SaveMessagesPayload, NewMessagesPayload, MessageStorePrunePayload, LocallyComposedMessageInfo, SimpleMessagesPayload, FetchPinnedMessagesResult, SearchMessagesResponse, } from './message-types.js'; import type { RawReactionMessageInfo } from './messages/reaction.js'; import type { RawTextMessageInfo } from './messages/text.js'; import type { BaseNavInfo, WebNavInfo } from './nav-types.js'; import { type ForcePolicyAcknowledgmentPayload, type PolicyAcknowledgmentPayload, type UserPolicies, } from './policy-types.js'; import type { RelationshipErrors } from './relationship-types.js'; import type { EnabledReports, ClearDeliveredReportsPayload, QueueReportsPayload, ReportStore, } from './report-types.js'; import type { ProcessServerRequestAction, GetOlmSessionInitializationDataResponse, } from './request-types.js'; import type { UserSearchResult, ExactUserSearchResult, } from './search-types.js'; import type { SetSessionPayload } from './session-types.js'; import type { ConnectionIssue, StateSyncFullActionPayload, StateSyncIncrementalActionPayload, SetActiveSessionRecoveryPayload, } from './socket-types.js'; import { type ClientStore } from './store-ops-types.js'; import type { SubscriptionUpdateResult } from './subscription-types.js'; import type { GlobalThemeInfo } from './theme-types.js'; import type { ThreadActivityStore } from './thread-activity-types.js'; import type { ThreadStore, ChangeThreadSettingsPayload, LeaveThreadPayload, NewThreadResult, ThreadJoinPayload, ToggleMessagePinResult, LegacyThreadStore, RoleModificationPayload, RoleDeletionPayload, } from './thread-types.js'; import type { ClientUpdatesResultWithUserInfos } from './update-types.js'; import type { CurrentUserInfo, UserInfos, UserStore } from './user-types.js'; import type { SetDeviceTokenActionPayload } from '../actions/device-actions.js'; import type { UpdateConnectionStatusPayload, SetLateResponsePayload, UpdateKeyserverReachabilityPayload, } from '../keyserver-conn/keyserver-conn-types.js'; import type { NotifPermissionAlertInfo } from '../utils/push-alerts.js'; export type BaseAppState = { +navInfo: NavInfo, +currentUserInfo: ?CurrentUserInfo, +draftStore: DraftStore, +entryStore: EntryStore, +threadStore: ThreadStore, +userStore: UserStore, +messageStore: MessageStore, +loadingStatuses: { [key: string]: { [idx: number]: LoadingStatus } }, +calendarFilters: $ReadOnlyArray, +notifPermissionAlertInfo: NotifPermissionAlertInfo, +watchedThreadIDs: $ReadOnlyArray, +lifecycleState: LifecycleState, +enabledApps: EnabledApps, +reportStore: ReportStore, +nextLocalID: number, +dataLoaded: boolean, +userPolicies: UserPolicies, +commServicesAccessToken: ?string, +inviteLinksStore: InviteLinksStore, +keyserverStore: KeyserverStore, +threadActivityStore: ThreadActivityStore, +integrityStore: IntegrityStore, +globalThemeInfo: GlobalThemeInfo, +customServer: ?string, +communityStore: CommunityStore, +dbOpsStore: DBOpsStore, ... }; export type NativeAppState = BaseAppState<>; export type WebAppState = BaseAppState<> & { +pushApiPublicKey: ?string, ... }; export type AppState = NativeAppState | WebAppState; export type ClientWebInitialReduxStateResponse = { +navInfo: WebNavInfo, +currentUserInfo: CurrentUserInfo, +entryStore: EntryStore, +threadStore: ThreadStore, +userInfos: UserInfos, +messageStore: MessageStore, +pushApiPublicKey: ?string, +inviteLinksStore: InviteLinksStore, +keyserverInfo: WebInitialKeyserverInfo, }; export type ServerWebInitialReduxStateResponse = { +navInfo: WebNavInfo, +currentUserInfo: CurrentUserInfo, +entryStore: EntryStore, +threadStore: LegacyThreadStore, +userInfos: UserInfos, +messageStore: MessageStore, +pushApiPublicKey: ?string, +inviteLinksStore: InviteLinksStore, +keyserverInfo: WebInitialKeyserverInfo, }; export type WebInitialKeyserverInfo = { +sessionID: ?string, +updatesCurrentAsOf: number, }; -export type BaseAction = - | { - +type: '@@redux/INIT', - +payload?: void, - } - | { - +type: 'FETCH_ENTRIES_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_ENTRIES_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_ENTRIES_SUCCESS', - +payload: FetchEntryInfosResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LOG_OUT_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LOG_OUT_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LOG_OUT_SUCCESS', - +payload: LogOutResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CLAIM_USERNAME_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CLAIM_USERNAME_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CLAIM_USERNAME_SUCCESS', - +payload: ClaimUsernameResponse, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_KEYSERVER_ACCOUNT_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_KEYSERVER_ACCOUNT_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_KEYSERVER_ACCOUNT_SUCCESS', - +payload: KeyserverLogOutResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_ACCOUNT_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_ACCOUNT_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_ACCOUNT_SUCCESS', - +payload: LogOutResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CREATE_LOCAL_ENTRY', - +payload: RawEntryInfo, - } - | { - +type: 'CREATE_ENTRY_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CREATE_ENTRY_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CREATE_ENTRY_SUCCESS', - +payload: CreateEntryPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SAVE_ENTRY_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SAVE_ENTRY_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SAVE_ENTRY_SUCCESS', - +payload: SaveEntryPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CONCURRENT_MODIFICATION_RESET', - +payload: { - +id: string, - +dbText: string, - }, - } - | { - +type: 'DELETE_ENTRY_STARTED', - +loadingInfo: LoadingInfo, - +payload: { - +localID: ?string, - +serverID: ?string, - }, - } - | { - +type: 'DELETE_ENTRY_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_ENTRY_SUCCESS', - +payload: ?DeleteEntryResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_LOG_IN_STARTED', - +loadingInfo: LoadingInfo, - +payload?: void, - } - | { - +type: 'IDENTITY_LOG_IN_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_LOG_IN_SUCCESS', - +payload: IdentityAuthResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'KEYSERVER_AUTH_STARTED', - +loadingInfo: LoadingInfo, - +payload: LogInStartingPayload, - } - | { - +type: 'KEYSERVER_AUTH_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'KEYSERVER_AUTH_SUCCESS', - +payload: KeyserverAuthResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LOG_IN_STARTED', - +loadingInfo: LoadingInfo, - +payload: LogInStartingPayload, - } - | { - +type: 'LOG_IN_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LOG_IN_SUCCESS', - +payload: LogInResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'KEYSERVER_REGISTER_STARTED', - +loadingInfo: LoadingInfo, - +payload: LogInStartingPayload, - } - | { - +type: 'KEYSERVER_REGISTER_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'KEYSERVER_REGISTER_SUCCESS', - +payload: RegisterResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_REGISTER_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_REGISTER_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_REGISTER_SUCCESS', - +payload: IdentityAuthResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_GENERATE_NONCE_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_GENERATE_NONCE_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'IDENTITY_GENERATE_NONCE_SUCCESS', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_KEYSERVER_USER_PASSWORD_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_KEYSERVER_USER_PASSWORD_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_KEYSERVER_USER_PASSWORD_SUCCESS', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_THREAD_SETTINGS_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_THREAD_SETTINGS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_THREAD_SETTINGS_SUCCESS', - +payload: ChangeThreadSettingsPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_THREAD_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_THREAD_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_THREAD_SUCCESS', - +payload: LeaveThreadPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'NEW_THREAD_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'NEW_THREAD_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'NEW_THREAD_SUCCESS', - +payload: NewThreadResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'REMOVE_USERS_FROM_THREAD_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'REMOVE_USERS_FROM_THREAD_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'REMOVE_USERS_FROM_THREAD_SUCCESS', - +payload: ChangeThreadSettingsPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_THREAD_MEMBER_ROLES_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_THREAD_MEMBER_ROLES_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CHANGE_THREAD_MEMBER_ROLES_SUCCESS', - +payload: ChangeThreadSettingsPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_REVISIONS_FOR_ENTRY_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_REVISIONS_FOR_ENTRY_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_REVISIONS_FOR_ENTRY_SUCCESS', - +payload: FetchRevisionsForEntryPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'RESTORE_ENTRY_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'RESTORE_ENTRY_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'RESTORE_ENTRY_SUCCESS', - +payload: RestoreEntryPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'JOIN_THREAD_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'JOIN_THREAD_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'JOIN_THREAD_SUCCESS', - +payload: ThreadJoinPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LEAVE_THREAD_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LEAVE_THREAD_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'LEAVE_THREAD_SUCCESS', - +payload: LeaveThreadPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_NEW_SESSION', - +payload: SetSessionPayload, - } - | { - +type: 'persist/REHYDRATE', - +payload: ?BaseAppState<>, - } - | { - +type: 'FETCH_MESSAGES_BEFORE_CURSOR_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_MESSAGES_BEFORE_CURSOR_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_MESSAGES_BEFORE_CURSOR_SUCCESS', - +payload: FetchMessageInfosPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_MOST_RECENT_MESSAGES_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_MOST_RECENT_MESSAGES_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_MOST_RECENT_MESSAGES_SUCCESS', - +payload: FetchMessageInfosPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_SUCCESS', - +payload: SimpleMessagesPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_TEXT_MESSAGE_STARTED', - +loadingInfo?: LoadingInfo, - +payload: RawTextMessageInfo, - } - | { - +type: 'SEND_TEXT_MESSAGE_FAILED', - +error: true, - +payload: Error & { - +localID: string, - +threadID: string, - }, - +loadingInfo?: LoadingInfo, - } - | { - +type: 'SEND_TEXT_MESSAGE_SUCCESS', - +payload: SendMessagePayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_MULTIMEDIA_MESSAGE_STARTED', - +loadingInfo?: LoadingInfo, - +payload: RawMultimediaMessageInfo, - } - | { - +type: 'SEND_MULTIMEDIA_MESSAGE_FAILED', - +error: true, - +payload: Error & { - +localID: string, - +threadID: string, - }, - +loadingInfo?: LoadingInfo, - } - | { - +type: 'SEND_MULTIMEDIA_MESSAGE_SUCCESS', - +payload: SendMessagePayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REACTION_MESSAGE_STARTED', - +loadingInfo?: LoadingInfo, - +payload: RawReactionMessageInfo, - } - | { - +type: 'SEND_REACTION_MESSAGE_FAILED', - +error: true, - +payload: Error & { - +localID: string, - +threadID: string, - +targetMessageID: string, - +reaction: string, - +action: string, - }, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REACTION_MESSAGE_SUCCESS', - +payload: SendMessagePayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEARCH_USERS_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEARCH_USERS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEARCH_USERS_SUCCESS', - +payload: UserSearchResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'EXACT_SEARCH_USER_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'EXACT_SEARCH_USER_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'EXACT_SEARCH_USER_SUCCESS', - +payload: ExactUserSearchResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_DRAFT', - +payload: { - +key: string, - +text: string, - }, - } - | { - +type: 'MOVE_DRAFT', - +payload: { - +oldKey: string, - +newKey: string, - }, - } - | { - +type: 'SET_CLIENT_DB_STORE', - +payload: ClientStore, - } - | { - +type: 'UPDATE_ACTIVITY_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_ACTIVITY_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_ACTIVITY_SUCCESS', - +payload: ActivityUpdateSuccessPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_DEVICE_TOKEN_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_DEVICE_TOKEN_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_DEVICE_TOKEN_SUCCESS', - +payload: SetDeviceTokenActionPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REPORT_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REPORT_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REPORT_SUCCESS', - +payload?: ClearDeliveredReportsPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REPORTS_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REPORTS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_REPORTS_SUCCESS', - +payload?: ClearDeliveredReportsPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'QUEUE_REPORTS', - +payload: QueueReportsPayload, - } - | { - +type: 'SET_URL_PREFIX', - +payload: string, - } - | { - +type: 'SAVE_MESSAGES', - +payload: SaveMessagesPayload, - } - | { - +type: 'UPDATE_CALENDAR_THREAD_FILTER', - +payload: CalendarThreadFilter, - } - | { - +type: 'CLEAR_CALENDAR_THREAD_FILTER', - +payload?: void, - } - | { - +type: 'SET_CALENDAR_DELETED_FILTER', - +payload: SetCalendarDeletedFilterPayload, - } - | { - +type: 'UPDATE_SUBSCRIPTION_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_SUBSCRIPTION_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_SUBSCRIPTION_SUCCESS', - +payload: SubscriptionUpdateResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_CALENDAR_QUERY_STARTED', - +loadingInfo: LoadingInfo, - +payload?: CalendarQueryUpdateStartingPayload, - } - | { - +type: 'UPDATE_CALENDAR_QUERY_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_CALENDAR_QUERY_SUCCESS', - +payload: CalendarQueryUpdateResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FULL_STATE_SYNC', - +payload: StateSyncFullActionPayload, - } - | { - +type: 'INCREMENTAL_STATE_SYNC', - +payload: StateSyncIncrementalActionPayload, - } - | ProcessServerRequestAction - | { - +type: 'UPDATE_CONNECTION_STATUS', - +payload: UpdateConnectionStatusPayload, - } - | { - +type: 'QUEUE_ACTIVITY_UPDATES', - +payload: QueueActivityUpdatesPayload, - } - | { - +type: 'UNSUPERVISED_BACKGROUND', - +payload: { +keyserverID: string }, - } - | { - +type: 'UPDATE_LIFECYCLE_STATE', - +payload: LifecycleState, - } - | { - +type: 'ENABLE_APP', - +payload: SupportedApps, - } - | { - +type: 'DISABLE_APP', - +payload: SupportedApps, - } - | { - +type: 'UPDATE_REPORTS_ENABLED', - +payload: Partial, - } - | { - +type: 'PROCESS_UPDATES', - +payload: ClientUpdatesResultWithUserInfos, - } - | { - +type: 'PROCESS_MESSAGES', - +payload: NewMessagesPayload, - } - | { - +type: 'MESSAGE_STORE_PRUNE', - +payload: MessageStorePrunePayload, - } - | { - +type: 'SET_LATE_RESPONSE', - +payload: SetLateResponsePayload, - } - | { - +type: 'UPDATE_KEYSERVER_REACHABILITY', - +payload: UpdateKeyserverReachabilityPayload, - } - | { - +type: 'REQUEST_ACCESS_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'REQUEST_ACCESS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'REQUEST_ACCESS_SUCCESS', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_MULTIMEDIA_MESSAGE_MEDIA', - +payload: UpdateMultimediaMessageMediaPayload, - } - | { - +type: 'CREATE_LOCAL_MESSAGE', - +payload: LocallyComposedMessageInfo, - } - | { - +type: 'UPDATE_RELATIONSHIPS_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_RELATIONSHIPS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_RELATIONSHIPS_SUCCESS', - +payload: RelationshipErrors, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_THREAD_UNREAD_STATUS_STARTED', - +payload: { - +threadID: string, - +unread: boolean, - }, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_THREAD_UNREAD_STATUS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_THREAD_UNREAD_STATUS_SUCCESS', - +payload: SetThreadUnreadStatusPayload, - } - | { - +type: 'SET_USER_SETTINGS_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_USER_SETTINGS_SUCCESS', - +payload: DefaultNotificationPayload, - } - | { - +type: 'SET_USER_SETTINGS_FAILED', - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_MESSAGE_REPORT_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_MESSAGE_REPORT_SUCCESS', - +payload: MessageReportCreationResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_MESSAGE_REPORT_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FORCE_POLICY_ACKNOWLEDGMENT', - +payload: ForcePolicyAcknowledgmentPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'POLICY_ACKNOWLEDGMENT_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'POLICY_ACKNOWLEDGMENT_SUCCESS', - +payload: PolicyAcknowledgmentPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'POLICY_ACKNOWLEDGMENT_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'GET_SIWE_NONCE_STARTED', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'GET_SIWE_NONCE_SUCCESS', - +payload?: void, - +loadingInfo: LoadingInfo, - } - | { - +type: 'GET_SIWE_NONCE_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SIWE_AUTH_STARTED', - +payload: LogInStartingPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SIWE_AUTH_SUCCESS', - +payload: LogInResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SIWE_AUTH_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'RECORD_NOTIF_PERMISSION_ALERT', - +payload: { +time: number }, - } - | { - +type: 'UPDATE_USER_AVATAR_STARTED', - +payload: UpdateUserAvatarRequest, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_USER_AVATAR_SUCCESS', - +payload: UpdateUserAvatarResponse, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_USER_AVATAR_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_EDIT_MESSAGE_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'SEND_EDIT_MESSAGE_SUCCESS', - +payload: EditMessagePayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEND_EDIT_MESSAGE_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'TOGGLE_MESSAGE_PIN_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'TOGGLE_MESSAGE_PIN_SUCCESS', - +payload: ToggleMessagePinResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'TOGGLE_MESSAGE_PIN_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_PINNED_MESSAGES_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'FETCH_PINNED_MESSAGES_SUCCESS', - +payload: FetchPinnedMessagesResult, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_PINNED_MESSAGES_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'VERIFY_INVITE_LINK_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'VERIFY_INVITE_LINK_SUCCESS', - +payload: InviteLinkVerificationResponse, - +loadingInfo: LoadingInfo, - } - | { - +type: 'VERIFY_INVITE_LINK_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_PRIMARY_INVITE_LINKS_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'FETCH_PRIMARY_INVITE_LINKS_SUCCESS', - +payload: FetchInviteLinksResponse, - +loadingInfo: LoadingInfo, - } - | { - +type: 'FETCH_PRIMARY_INVITE_LINKS_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_CALENDAR_COMMUNITY_FILTER', - +payload: string, - } - | { - +type: 'CLEAR_CALENDAR_COMMUNITY_FILTER', - +payload: void, - } - | { - +type: 'UPDATE_CHAT_COMMUNITY_FILTER', - +payload: string, - } - | { - +type: 'CLEAR_CHAT_COMMUNITY_FILTER', - +payload: void, - } - | { - +type: 'SEARCH_MESSAGES_STARTED', - +payload: void, - +loadingInfo?: LoadingInfo, - } - | { - +type: 'SEARCH_MESSAGES_SUCCESS', - +payload: SearchMessagesResponse, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SEARCH_MESSAGES_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CREATE_OR_UPDATE_PUBLIC_LINK_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'CREATE_OR_UPDATE_PUBLIC_LINK_SUCCESS', - +payload: InviteLink, - +loadingInfo: LoadingInfo, - } - | { - +type: 'CREATE_OR_UPDATE_PUBLIC_LINK_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DISABLE_INVITE_LINK_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'DISABLE_INVITE_LINK_SUCCESS', - +payload: DisableInviteLinkPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DISABLE_INVITE_LINK_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'GET_OLM_SESSION_INITIALIZATION_DATA_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'GET_OLM_SESSION_INITIALIZATION_DATA_SUCCESS', - +payload: GetOlmSessionInitializationDataResponse, - +loadingInfo: LoadingInfo, - } - | { - +type: 'GET_OLM_SESSION_INITIALIZATION_DATA_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_DATA_LOADED', - +payload: { - +dataLoaded: boolean, - }, - } - | { - +type: 'GET_VERSION_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'GET_VERSION_SUCCESS', - +payload: GetVersionActionPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'GET_VERSION_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'UPDATE_LAST_COMMUNICATED_PLATFORM_DETAILS', - +payload: LastCommunicatedPlatformDetails, - } - | { +type: 'RESET_USER_STATE', +payload?: void } - | { - +type: 'MODIFY_COMMUNITY_ROLE_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'MODIFY_COMMUNITY_ROLE_SUCCESS', - +payload: RoleModificationPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'MODIFY_COMMUNITY_ROLE_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_COMMUNITY_ROLE_STARTED', - +loadingInfo?: LoadingInfo, - +payload?: void, - } - | { - +type: 'DELETE_COMMUNITY_ROLE_SUCCESS', - +payload: RoleDeletionPayload, - +loadingInfo: LoadingInfo, - } - | { - +type: 'DELETE_COMMUNITY_ROLE_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'SET_ACCESS_TOKEN', - +payload: ?string, - } - | { - +type: 'UPDATE_THREAD_LAST_NAVIGATED', - +payload: { +threadID: string, +time: number }, - } - | { - +type: 'UPDATE_INTEGRITY_STORE', - +payload: { - +threadIDsToHash?: $ReadOnlyArray, - +threadHashingStatus?: 'starting' | 'running' | 'completed', +export type BaseAction = $ReadOnly<{ + +messageID?: MessageID, + ... + | { + +type: '@@redux/INIT', + +payload?: void, + } + | { + +type: 'FETCH_ENTRIES_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_ENTRIES_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_ENTRIES_SUCCESS', + +payload: FetchEntryInfosResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LOG_OUT_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LOG_OUT_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LOG_OUT_SUCCESS', + +payload: LogOutResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CLAIM_USERNAME_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CLAIM_USERNAME_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CLAIM_USERNAME_SUCCESS', + +payload: ClaimUsernameResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_KEYSERVER_ACCOUNT_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_KEYSERVER_ACCOUNT_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_KEYSERVER_ACCOUNT_SUCCESS', + +payload: KeyserverLogOutResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_ACCOUNT_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_ACCOUNT_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_ACCOUNT_SUCCESS', + +payload: LogOutResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CREATE_LOCAL_ENTRY', + +payload: RawEntryInfo, + } + | { + +type: 'CREATE_ENTRY_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CREATE_ENTRY_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CREATE_ENTRY_SUCCESS', + +payload: CreateEntryPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SAVE_ENTRY_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SAVE_ENTRY_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SAVE_ENTRY_SUCCESS', + +payload: SaveEntryPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CONCURRENT_MODIFICATION_RESET', + +payload: { + +id: string, + +dbText: string, + }, + } + | { + +type: 'DELETE_ENTRY_STARTED', + +loadingInfo: LoadingInfo, + +payload: { + +localID: ?string, + +serverID: ?string, + }, + } + | { + +type: 'DELETE_ENTRY_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_ENTRY_SUCCESS', + +payload: ?DeleteEntryResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_LOG_IN_STARTED', + +loadingInfo: LoadingInfo, + +payload?: void, + } + | { + +type: 'IDENTITY_LOG_IN_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_LOG_IN_SUCCESS', + +payload: IdentityAuthResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'KEYSERVER_AUTH_STARTED', + +loadingInfo: LoadingInfo, + +payload: LogInStartingPayload, + } + | { + +type: 'KEYSERVER_AUTH_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'KEYSERVER_AUTH_SUCCESS', + +payload: KeyserverAuthResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LOG_IN_STARTED', + +loadingInfo: LoadingInfo, + +payload: LogInStartingPayload, + } + | { + +type: 'LOG_IN_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LOG_IN_SUCCESS', + +payload: LogInResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'KEYSERVER_REGISTER_STARTED', + +loadingInfo: LoadingInfo, + +payload: LogInStartingPayload, + } + | { + +type: 'KEYSERVER_REGISTER_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'KEYSERVER_REGISTER_SUCCESS', + +payload: RegisterResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_REGISTER_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_REGISTER_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_REGISTER_SUCCESS', + +payload: IdentityAuthResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_GENERATE_NONCE_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_GENERATE_NONCE_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_GENERATE_NONCE_SUCCESS', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_KEYSERVER_USER_PASSWORD_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_KEYSERVER_USER_PASSWORD_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_KEYSERVER_USER_PASSWORD_SUCCESS', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_THREAD_SETTINGS_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_THREAD_SETTINGS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_THREAD_SETTINGS_SUCCESS', + +payload: ChangeThreadSettingsPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_THREAD_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_THREAD_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_THREAD_SUCCESS', + +payload: LeaveThreadPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'NEW_THREAD_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'NEW_THREAD_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'NEW_THREAD_SUCCESS', + +payload: NewThreadResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'REMOVE_USERS_FROM_THREAD_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'REMOVE_USERS_FROM_THREAD_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'REMOVE_USERS_FROM_THREAD_SUCCESS', + +payload: ChangeThreadSettingsPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_THREAD_MEMBER_ROLES_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_THREAD_MEMBER_ROLES_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CHANGE_THREAD_MEMBER_ROLES_SUCCESS', + +payload: ChangeThreadSettingsPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_REVISIONS_FOR_ENTRY_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_REVISIONS_FOR_ENTRY_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_REVISIONS_FOR_ENTRY_SUCCESS', + +payload: FetchRevisionsForEntryPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'RESTORE_ENTRY_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'RESTORE_ENTRY_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'RESTORE_ENTRY_SUCCESS', + +payload: RestoreEntryPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'JOIN_THREAD_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'JOIN_THREAD_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'JOIN_THREAD_SUCCESS', + +payload: ThreadJoinPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LEAVE_THREAD_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LEAVE_THREAD_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'LEAVE_THREAD_SUCCESS', + +payload: LeaveThreadPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_NEW_SESSION', + +payload: SetSessionPayload, + } + | { + +type: 'persist/REHYDRATE', + +payload: ?BaseAppState<>, + } + | { + +type: 'FETCH_MESSAGES_BEFORE_CURSOR_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_MESSAGES_BEFORE_CURSOR_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_MESSAGES_BEFORE_CURSOR_SUCCESS', + +payload: FetchMessageInfosPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_MOST_RECENT_MESSAGES_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_MOST_RECENT_MESSAGES_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_MOST_RECENT_MESSAGES_SUCCESS', + +payload: FetchMessageInfosPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_SINGLE_MOST_RECENT_MESSAGES_FROM_THREADS_SUCCESS', + +payload: SimpleMessagesPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_TEXT_MESSAGE_STARTED', + +loadingInfo?: LoadingInfo, + +payload: RawTextMessageInfo, + } + | { + +type: 'SEND_TEXT_MESSAGE_FAILED', + +error: true, + +payload: Error & { + +localID: string, + +threadID: string, + }, + +loadingInfo?: LoadingInfo, + } + | { + +type: 'SEND_TEXT_MESSAGE_SUCCESS', + +payload: SendMessagePayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_MULTIMEDIA_MESSAGE_STARTED', + +loadingInfo?: LoadingInfo, + +payload: RawMultimediaMessageInfo, + } + | { + +type: 'SEND_MULTIMEDIA_MESSAGE_FAILED', + +error: true, + +payload: Error & { + +localID: string, + +threadID: string, + }, + +loadingInfo?: LoadingInfo, + } + | { + +type: 'SEND_MULTIMEDIA_MESSAGE_SUCCESS', + +payload: SendMessagePayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REACTION_MESSAGE_STARTED', + +loadingInfo?: LoadingInfo, + +payload: RawReactionMessageInfo, + } + | { + +type: 'SEND_REACTION_MESSAGE_FAILED', + +error: true, + +payload: Error & { + +localID: string, + +threadID: string, + +targetMessageID: string, + +reaction: string, + +action: string, + }, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REACTION_MESSAGE_SUCCESS', + +payload: SendMessagePayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEARCH_USERS_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEARCH_USERS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEARCH_USERS_SUCCESS', + +payload: UserSearchResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'EXACT_SEARCH_USER_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'EXACT_SEARCH_USER_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'EXACT_SEARCH_USER_SUCCESS', + +payload: ExactUserSearchResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_DRAFT', + +payload: { + +key: string, + +text: string, + }, + } + | { + +type: 'MOVE_DRAFT', + +payload: { + +oldKey: string, + +newKey: string, + }, + } + | { + +type: 'SET_CLIENT_DB_STORE', + +payload: ClientStore, + } + | { + +type: 'UPDATE_ACTIVITY_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_ACTIVITY_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_ACTIVITY_SUCCESS', + +payload: ActivityUpdateSuccessPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_DEVICE_TOKEN_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_DEVICE_TOKEN_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_DEVICE_TOKEN_SUCCESS', + +payload: SetDeviceTokenActionPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REPORT_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REPORT_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REPORT_SUCCESS', + +payload?: ClearDeliveredReportsPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REPORTS_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REPORTS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_REPORTS_SUCCESS', + +payload?: ClearDeliveredReportsPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'QUEUE_REPORTS', + +payload: QueueReportsPayload, + } + | { + +type: 'SET_URL_PREFIX', + +payload: string, + } + | { + +type: 'SAVE_MESSAGES', + +payload: SaveMessagesPayload, + } + | { + +type: 'UPDATE_CALENDAR_THREAD_FILTER', + +payload: CalendarThreadFilter, + } + | { + +type: 'CLEAR_CALENDAR_THREAD_FILTER', + +payload?: void, + } + | { + +type: 'SET_CALENDAR_DELETED_FILTER', + +payload: SetCalendarDeletedFilterPayload, + } + | { + +type: 'UPDATE_SUBSCRIPTION_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_SUBSCRIPTION_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_SUBSCRIPTION_SUCCESS', + +payload: SubscriptionUpdateResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_CALENDAR_QUERY_STARTED', + +loadingInfo: LoadingInfo, + +payload?: CalendarQueryUpdateStartingPayload, + } + | { + +type: 'UPDATE_CALENDAR_QUERY_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_CALENDAR_QUERY_SUCCESS', + +payload: CalendarQueryUpdateResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FULL_STATE_SYNC', + +payload: StateSyncFullActionPayload, + } + | { + +type: 'INCREMENTAL_STATE_SYNC', + +payload: StateSyncIncrementalActionPayload, + } + | ProcessServerRequestAction + | { + +type: 'UPDATE_CONNECTION_STATUS', + +payload: UpdateConnectionStatusPayload, + } + | { + +type: 'QUEUE_ACTIVITY_UPDATES', + +payload: QueueActivityUpdatesPayload, + } + | { + +type: 'UNSUPERVISED_BACKGROUND', + +payload: { +keyserverID: string }, + } + | { + +type: 'UPDATE_LIFECYCLE_STATE', + +payload: LifecycleState, + } + | { + +type: 'ENABLE_APP', + +payload: SupportedApps, + } + | { + +type: 'DISABLE_APP', + +payload: SupportedApps, + } + | { + +type: 'UPDATE_REPORTS_ENABLED', + +payload: Partial, + } + | { + +type: 'PROCESS_UPDATES', + +payload: ClientUpdatesResultWithUserInfos, + } + | { + +type: 'PROCESS_MESSAGES', + +payload: NewMessagesPayload, + } + | { + +type: 'MESSAGE_STORE_PRUNE', + +payload: MessageStorePrunePayload, + } + | { + +type: 'SET_LATE_RESPONSE', + +payload: SetLateResponsePayload, + } + | { + +type: 'UPDATE_KEYSERVER_REACHABILITY', + +payload: UpdateKeyserverReachabilityPayload, + } + | { + +type: 'REQUEST_ACCESS_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'REQUEST_ACCESS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'REQUEST_ACCESS_SUCCESS', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_MULTIMEDIA_MESSAGE_MEDIA', + +payload: UpdateMultimediaMessageMediaPayload, + } + | { + +type: 'CREATE_LOCAL_MESSAGE', + +payload: LocallyComposedMessageInfo, + } + | { + +type: 'UPDATE_RELATIONSHIPS_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_RELATIONSHIPS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_RELATIONSHIPS_SUCCESS', + +payload: RelationshipErrors, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_THREAD_UNREAD_STATUS_STARTED', + +payload: { + +threadID: string, + +unread: boolean, + }, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_THREAD_UNREAD_STATUS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_THREAD_UNREAD_STATUS_SUCCESS', + +payload: SetThreadUnreadStatusPayload, + } + | { + +type: 'SET_USER_SETTINGS_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_USER_SETTINGS_SUCCESS', + +payload: DefaultNotificationPayload, + } + | { + +type: 'SET_USER_SETTINGS_FAILED', + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_MESSAGE_REPORT_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_MESSAGE_REPORT_SUCCESS', + +payload: MessageReportCreationResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_MESSAGE_REPORT_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FORCE_POLICY_ACKNOWLEDGMENT', + +payload: ForcePolicyAcknowledgmentPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'POLICY_ACKNOWLEDGMENT_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'POLICY_ACKNOWLEDGMENT_SUCCESS', + +payload: PolicyAcknowledgmentPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'POLICY_ACKNOWLEDGMENT_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'GET_SIWE_NONCE_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'GET_SIWE_NONCE_SUCCESS', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'GET_SIWE_NONCE_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SIWE_AUTH_STARTED', + +payload: LogInStartingPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SIWE_AUTH_SUCCESS', + +payload: LogInResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SIWE_AUTH_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'RECORD_NOTIF_PERMISSION_ALERT', + +payload: { +time: number }, + } + | { + +type: 'UPDATE_USER_AVATAR_STARTED', + +payload: UpdateUserAvatarRequest, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_USER_AVATAR_SUCCESS', + +payload: UpdateUserAvatarResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_USER_AVATAR_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_EDIT_MESSAGE_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'SEND_EDIT_MESSAGE_SUCCESS', + +payload: EditMessagePayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEND_EDIT_MESSAGE_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'TOGGLE_MESSAGE_PIN_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'TOGGLE_MESSAGE_PIN_SUCCESS', + +payload: ToggleMessagePinResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'TOGGLE_MESSAGE_PIN_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_PINNED_MESSAGES_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'FETCH_PINNED_MESSAGES_SUCCESS', + +payload: FetchPinnedMessagesResult, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_PINNED_MESSAGES_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'VERIFY_INVITE_LINK_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'VERIFY_INVITE_LINK_SUCCESS', + +payload: InviteLinkVerificationResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'VERIFY_INVITE_LINK_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_PRIMARY_INVITE_LINKS_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'FETCH_PRIMARY_INVITE_LINKS_SUCCESS', + +payload: FetchInviteLinksResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_PRIMARY_INVITE_LINKS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_CALENDAR_COMMUNITY_FILTER', + +payload: string, + } + | { + +type: 'CLEAR_CALENDAR_COMMUNITY_FILTER', + +payload: void, + } + | { + +type: 'UPDATE_CHAT_COMMUNITY_FILTER', + +payload: string, + } + | { + +type: 'CLEAR_CHAT_COMMUNITY_FILTER', + +payload: void, + } + | { + +type: 'SEARCH_MESSAGES_STARTED', + +payload: void, + +loadingInfo?: LoadingInfo, + } + | { + +type: 'SEARCH_MESSAGES_SUCCESS', + +payload: SearchMessagesResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SEARCH_MESSAGES_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CREATE_OR_UPDATE_PUBLIC_LINK_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'CREATE_OR_UPDATE_PUBLIC_LINK_SUCCESS', + +payload: InviteLink, + +loadingInfo: LoadingInfo, + } + | { + +type: 'CREATE_OR_UPDATE_PUBLIC_LINK_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DISABLE_INVITE_LINK_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'DISABLE_INVITE_LINK_SUCCESS', + +payload: DisableInviteLinkPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DISABLE_INVITE_LINK_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'GET_OLM_SESSION_INITIALIZATION_DATA_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'GET_OLM_SESSION_INITIALIZATION_DATA_SUCCESS', + +payload: GetOlmSessionInitializationDataResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'GET_OLM_SESSION_INITIALIZATION_DATA_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_DATA_LOADED', + +payload: { + +dataLoaded: boolean, + }, + } + | { + +type: 'GET_VERSION_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'GET_VERSION_SUCCESS', + +payload: GetVersionActionPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'GET_VERSION_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_LAST_COMMUNICATED_PLATFORM_DETAILS', + +payload: LastCommunicatedPlatformDetails, + } + | { +type: 'RESET_USER_STATE', +payload?: void } + | { + +type: 'MODIFY_COMMUNITY_ROLE_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'MODIFY_COMMUNITY_ROLE_SUCCESS', + +payload: RoleModificationPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'MODIFY_COMMUNITY_ROLE_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_COMMUNITY_ROLE_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'DELETE_COMMUNITY_ROLE_SUCCESS', + +payload: RoleDeletionPayload, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_COMMUNITY_ROLE_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_ACCESS_TOKEN', + +payload: ?string, + } + | { + +type: 'UPDATE_THREAD_LAST_NAVIGATED', + +payload: { +threadID: string, +time: number }, + } + | { + +type: 'UPDATE_INTEGRITY_STORE', + +payload: { + +threadIDsToHash?: $ReadOnlyArray, + +threadHashingStatus?: 'starting' | 'running' | 'completed', + }, + } + | { + +type: 'UPDATE_THEME_INFO', + +payload: Partial, + } + | { + +type: 'ADD_KEYSERVER', + +payload: AddKeyserverPayload, + } + | { + +type: 'REMOVE_KEYSERVER', + +payload: RemoveKeyserverPayload, + } + | { + +type: 'SET_CUSTOM_SERVER', + +payload: string, + } + | { + +type: 'SET_CONNECTION_ISSUE', + +payload: { +connectionIssue: ?ConnectionIssue, +keyserverID: string }, + } + | { + +type: 'ADD_COMMUNITY', + +payload: AddCommunityPayload, + } + | { + +type: 'SET_ACTIVE_SESSION_RECOVERY', + +payload: SetActiveSessionRecoveryPayload, + } + | { + +type: 'OPS_PROCESSING_FINISHED_ACTION_TYPE', + +payload?: void, }, - } - | { - +type: 'UPDATE_THEME_INFO', - +payload: Partial, - } - | { - +type: 'ADD_KEYSERVER', - +payload: AddKeyserverPayload, - } - | { - +type: 'REMOVE_KEYSERVER', - +payload: RemoveKeyserverPayload, - } - | { - +type: 'SET_CUSTOM_SERVER', - +payload: string, - } - | { - +type: 'SET_CONNECTION_ISSUE', - +payload: { +connectionIssue: ?ConnectionIssue, +keyserverID: string }, - } - | { - +type: 'ADD_COMMUNITY', - +payload: AddCommunityPayload, - } - | { - +type: 'SET_ACTIVE_SESSION_RECOVERY', - +payload: SetActiveSessionRecoveryPayload, - } - | { - +type: 'OPS_PROCESSING_FINISHED_ACTION_TYPE', - +payload?: void, - }; +}>; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string); export type DispatchSource = 'tunnelbroker' | 'tab-sync'; export type SuperAction = { - type: string, - payload?: ActionPayload, - loadingInfo?: LoadingInfo, - error?: boolean, - dispatchSource?: DispatchSource, + +type: string, + +payload?: ActionPayload, + +loadingInfo?: LoadingInfo, + +error?: boolean, + +dispatchSource?: DispatchSource, + +messageID?: MessageID, }; type ThunkedAction = (dispatch: Dispatch) => void; export type PromisedAction = (dispatch: Dispatch) => Promise; export type Dispatch = ((promisedAction: PromisedAction) => Promise) & ((thunkedAction: ThunkedAction) => void) & ((action: SuperAction) => boolean); // This is lifted from redux-persist/lib/constants.js // I don't want to add redux-persist to the web/server bundles... // import { REHYDRATE } from 'redux-persist'; export const rehydrateActionType = 'persist/REHYDRATE'; diff --git a/lib/types/request-types.js b/lib/types/request-types.js index 66f97ca3b..385c87c83 100644 --- a/lib/types/request-types.js +++ b/lib/types/request-types.js @@ -1,296 +1,298 @@ // @flow import invariant from 'invariant'; import t, { type TUnion, type TInterface } from 'tcomb'; import { type ActivityUpdate } from './activity-types.js'; import type { SignedIdentityKeysBlob } from './crypto-types.js'; import { signedIdentityKeysBlobValidator } from './crypto-types.js'; +import type { MessageID } from './db-ops-types.js'; import type { Platform, PlatformDetails } from './device-types.js'; import { type RawEntryInfo, type CalendarQuery, rawEntryInfoValidator, } from './entry-types.js'; import type { RawThreadInfo } from './minimally-encoded-thread-permissions-types'; import type { ThreadInconsistencyReportShape, EntryInconsistencyReportShape, ClientThreadInconsistencyReportShape, ClientEntryInconsistencyReportShape, } from './report-types.js'; import type { LegacyRawThreadInfo } from './thread-types.js'; import { type CurrentUserInfo, currentUserInfoValidator, type AccountUserInfo, accountUserInfoValidator, } from './user-types.js'; import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js'; import { tNumber, tShape, tID } from '../utils/validation-utils.js'; // "Server requests" are requests for information that the server delivers to // clients. Clients then respond to those requests with a "client response". export const serverRequestTypes = Object.freeze({ PLATFORM: 0, //DEVICE_TOKEN: 1, (DEPRECATED) THREAD_INCONSISTENCY: 2, PLATFORM_DETAILS: 3, //INITIAL_ACTIVITY_UPDATE: 4, (DEPRECATED) ENTRY_INCONSISTENCY: 5, CHECK_STATE: 6, INITIAL_ACTIVITY_UPDATES: 7, // MORE_ONE_TIME_KEYS: 8, (DEPRECATED) SIGNED_IDENTITY_KEYS_BLOB: 9, INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE: 10, }); type ServerRequestType = $Values; export function assertServerRequestType( serverRequestType: number, ): ServerRequestType { invariant( serverRequestType === 0 || serverRequestType === 2 || serverRequestType === 3 || serverRequestType === 5 || serverRequestType === 6 || serverRequestType === 7 || serverRequestType === 9 || serverRequestType === 10, 'number is not ServerRequestType enum', ); return serverRequestType; } type PlatformServerRequest = { +type: 0, }; const platformServerRequestValidator = tShape({ type: tNumber(serverRequestTypes.PLATFORM), }); type PlatformClientResponse = { +type: 0, +platform: Platform, }; export type ThreadInconsistencyClientResponse = { ...ThreadInconsistencyReportShape, +type: 2, }; type PlatformDetailsServerRequest = { type: 3, }; const platformDetailsServerRequestValidator = tShape({ type: tNumber(serverRequestTypes.PLATFORM_DETAILS), }); type PlatformDetailsClientResponse = { type: 3, platformDetails: PlatformDetails, }; export type EntryInconsistencyClientResponse = { type: 5, ...EntryInconsistencyReportShape, }; type FailUnmentioned = Partial<{ +threadInfos: boolean, +entryInfos: boolean, +userInfos: boolean, }>; type StateChanges = Partial<{ +rawThreadInfos: LegacyRawThreadInfo[] | RawThreadInfo[], +rawEntryInfos: RawEntryInfo[], +currentUserInfo: CurrentUserInfo, +userInfos: AccountUserInfo[], +deleteThreadIDs: string[], +deleteEntryIDs: string[], +deleteUserInfoIDs: string[], }>; export type ServerCheckStateServerRequest = { +type: 6, +hashesToCheck: { +[key: string]: number }, +failUnmentioned?: FailUnmentioned, +stateChanges?: StateChanges, }; const serverCheckStateServerRequestValidator = tShape({ type: tNumber(serverRequestTypes.CHECK_STATE), hashesToCheck: t.dict(t.String, t.Number), failUnmentioned: t.maybe( tShape({ threadInfos: t.maybe(t.Boolean), entryInfos: t.maybe(t.Boolean), userInfos: t.maybe(t.Boolean), }), ), stateChanges: t.maybe( tShape({ rawThreadInfos: t.maybe(t.list(mixedRawThreadInfoValidator)), rawEntryInfos: t.maybe(t.list(rawEntryInfoValidator)), currentUserInfo: t.maybe(currentUserInfoValidator), userInfos: t.maybe(t.list(accountUserInfoValidator)), deleteThreadIDs: t.maybe(t.list(tID)), deleteEntryIDs: t.maybe(t.list(tID)), deleteUserInfoIDs: t.maybe(t.list(t.String)), }), ), }); type CheckStateClientResponse = { +type: 6, +hashResults: { +[key: string]: boolean }, }; type InitialActivityUpdatesClientResponse = { +type: 7, +activityUpdates: $ReadOnlyArray, }; type MoreOneTimeKeysClientResponse = { +type: 8, +keys: $ReadOnlyArray, }; type SignedIdentityKeysBlobServerRequest = { +type: 9, }; const signedIdentityKeysBlobServerRequestValidator = tShape({ type: tNumber(serverRequestTypes.SIGNED_IDENTITY_KEYS_BLOB), }); type SignedIdentityKeysBlobClientResponse = { +type: 9, +signedIdentityKeysBlob: SignedIdentityKeysBlob, }; type InitialNotificationsEncryptedMessageServerRequest = { +type: 10, }; const initialNotificationsEncryptedMessageServerRequestValidator = tShape({ type: tNumber(serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE), }); type InitialNotificationsEncryptedMessageClientResponse = { +type: 10, +initialNotificationsEncryptedMessage: string, }; export type ServerServerRequest = | PlatformServerRequest | PlatformDetailsServerRequest | ServerCheckStateServerRequest | SignedIdentityKeysBlobServerRequest | InitialNotificationsEncryptedMessageServerRequest; export const serverServerRequestValidator: TUnion = t.union([ platformServerRequestValidator, platformDetailsServerRequestValidator, serverCheckStateServerRequestValidator, signedIdentityKeysBlobServerRequestValidator, initialNotificationsEncryptedMessageServerRequestValidator, ]); export type ClientResponse = | PlatformClientResponse | ThreadInconsistencyClientResponse | PlatformDetailsClientResponse | EntryInconsistencyClientResponse | CheckStateClientResponse | InitialActivityUpdatesClientResponse | MoreOneTimeKeysClientResponse | SignedIdentityKeysBlobClientResponse | InitialNotificationsEncryptedMessageClientResponse; export type ClientCheckStateServerRequest = { +type: 6, +hashesToCheck: { +[key: string]: number }, +failUnmentioned?: Partial<{ +threadInfos: boolean, +entryInfos: boolean, +userInfos: boolean, }>, +stateChanges?: Partial<{ +rawThreadInfos: RawThreadInfo[], +rawEntryInfos: RawEntryInfo[], +currentUserInfo: CurrentUserInfo, +userInfos: AccountUserInfo[], +deleteThreadIDs: string[], +deleteEntryIDs: string[], +deleteUserInfoIDs: string[], }>, }; export type ClientServerRequest = | PlatformServerRequest | PlatformDetailsServerRequest | ClientCheckStateServerRequest | SignedIdentityKeysBlobServerRequest | InitialNotificationsEncryptedMessageServerRequest; // This is just the client variant of ClientResponse. The server needs to handle // multiple client versions so the type supports old versions of certain client // responses, but the client variant only need to support the latest version. type ClientThreadInconsistencyClientResponse = { ...ClientThreadInconsistencyReportShape, +type: 2, }; type ClientEntryInconsistencyClientResponse = { +type: 5, ...ClientEntryInconsistencyReportShape, }; export type ClientClientResponse = | PlatformClientResponse | ClientThreadInconsistencyClientResponse | PlatformDetailsClientResponse | ClientEntryInconsistencyClientResponse | CheckStateClientResponse | InitialActivityUpdatesClientResponse | MoreOneTimeKeysClientResponse | SignedIdentityKeysBlobClientResponse | InitialNotificationsEncryptedMessageClientResponse; export type ClientInconsistencyResponse = | ClientThreadInconsistencyClientResponse | ClientEntryInconsistencyClientResponse; export const processServerRequestsActionType = 'PROCESS_SERVER_REQUESTS'; export type ProcessServerRequestsPayload = { +serverRequests: $ReadOnlyArray, +calendarQuery: CalendarQuery, +keyserverID: string, }; export type ProcessServerRequestAction = { + +messageID?: MessageID, +type: 'PROCESS_SERVER_REQUESTS', +payload: ProcessServerRequestsPayload, }; export type OlmSessionInitializationInfo = { +prekey: string, +prekeySignature: string, +oneTimeKey: string, }; export const olmSessionInitializationInfoValidator: TInterface = tShape({ prekey: t.String, prekeySignature: t.String, oneTimeKey: t.String, }); export type GetOlmSessionInitializationDataResponse = { +signedIdentityKeysBlob: SignedIdentityKeysBlob, +contentInitializationInfo: OlmSessionInitializationInfo, +notifInitializationInfo: OlmSessionInitializationInfo, }; export const getOlmSessionInitializationDataResponseValidator: TInterface = tShape({ signedIdentityKeysBlob: signedIdentityKeysBlobValidator, contentInitializationInfo: olmSessionInitializationInfoValidator, notifInitializationInfo: olmSessionInitializationInfoValidator, }); diff --git a/native/redux/action-types.js b/native/redux/action-types.js index 4aba28dac..752d43674 100644 --- a/native/redux/action-types.js +++ b/native/redux/action-types.js @@ -1,55 +1,61 @@ // @flow import type { Orientations } from 'react-native-orientation-locker'; import { saveMessagesActionType } from 'lib/actions/message-actions.js'; +import type { MessageID } from 'lib/types/db-ops-types'; import type { BaseAction } from 'lib/types/redux-types.js'; import type { DimensionsInfo } from './dimensions-updater.react.js'; import type { AppState } from './state-types.js'; import type { DeviceCameraInfo } from '../types/camera.js'; import type { ConnectivityInfo } from '../types/connectivity.js'; import type { LocalSettings } from '../types/local-settings-types.js'; export const updateDimensionsActiveType = 'UPDATE_DIMENSIONS'; export const updateConnectivityActiveType = 'UPDATE_CONNECTIVITY'; export const updateDeviceCameraInfoActionType = 'UPDATE_DEVICE_CAMERA_INFO'; export const updateDeviceOrientationActionType = 'UPDATE_DEVICE_ORIENTATION'; export const setStoreLoadedActionType = 'SET_STORE_LOADED'; export const setReduxStateActionType = 'SET_REDUX_STATE'; export const setLocalSettingsActionType = 'SET_LOCAL_SETTINGS'; export const backgroundActionTypes: Set = new Set([ saveMessagesActionType, ]); -export type Action = +export type Action = $ReadOnly< | BaseAction | { - +type: 'SET_REDUX_STATE', - +payload: { +state: AppState, +hideFromMonitor: boolean }, - } - | { - +type: 'UPDATE_DIMENSIONS', - +payload: Partial, - } - | { - +type: 'UPDATE_CONNECTIVITY', - +payload: ConnectivityInfo, - } - | { - +type: 'UPDATE_DEVICE_CAMERA_INFO', - +payload: Partial, - } - | { - +type: 'UPDATE_DEVICE_ORIENTATION', - +payload: Orientations, - } - | { - +type: 'UPDATE_THREAD_LAST_NAVIGATED', - +payload: { +threadID: string, +time: number }, - } - | { - +type: 'SET_STORE_LOADED', - } - | { +type: 'SET_LOCAL_SETTINGS', +payload: LocalSettings }; + +messageID?: MessageID, + ... + | { + +type: 'SET_REDUX_STATE', + +payload: { +state: AppState, +hideFromMonitor: boolean }, + } + | { + +type: 'UPDATE_DIMENSIONS', + +payload: Partial, + } + | { + +type: 'UPDATE_CONNECTIVITY', + +payload: ConnectivityInfo, + } + | { + +type: 'UPDATE_DEVICE_CAMERA_INFO', + +payload: Partial, + } + | { + +type: 'UPDATE_DEVICE_ORIENTATION', + +payload: Orientations, + } + | { + +type: 'UPDATE_THREAD_LAST_NAVIGATED', + +payload: { +threadID: string, +time: number }, + } + | { + +type: 'SET_STORE_LOADED', + } + | { +type: 'SET_LOCAL_SETTINGS', +payload: LocalSettings }, + }, +>; diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js index af29a9991..97ed40fc1 100644 --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -1,487 +1,492 @@ // @flow import invariant from 'invariant'; import type { PersistState } from 'redux-persist/es/types.js'; import { logOutActionTypes, deleteKeyserverAccountActionTypes, deleteAccountActionTypes, identityRegisterActionTypes, } from 'lib/actions/user-actions.js'; import { setNewSessionActionType } from 'lib/keyserver-conn/keyserver-conn-types.js'; import { type ReplaceKeyserverOperation, keyserverStoreOpsHandlers, } from 'lib/ops/keyserver-store-ops.js'; import { type ThreadStoreOperation, threadStoreOpsHandlers, } from 'lib/ops/thread-store-ops.js'; import { reduceLoadingStatuses } from 'lib/reducers/loading-reducer.js'; import baseReducer from 'lib/reducers/master-reducer.js'; import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js'; import { isLoggedIn } from 'lib/selectors/user-selectors.js'; import { invalidSessionDowngrade, identityInvalidSessionDowngrade, } from 'lib/shared/session-utils.js'; import type { CommunityStore } from 'lib/types/community-types.js'; -import type { DBOpsStore } from 'lib/types/db-ops-types.js'; +import type { MessageID, DBOpsStore } from 'lib/types/db-ops-types.js'; import type { DraftStore } from 'lib/types/draft-types.js'; import type { EnabledApps } from 'lib/types/enabled-apps.js'; import type { EntryStore } from 'lib/types/entry-types.js'; import { type CalendarFilter } from 'lib/types/filter-types.js'; import type { IntegrityStore } from 'lib/types/integrity-types.js'; import type { KeyserverStore } from 'lib/types/keyserver-types.js'; import type { LifecycleState } from 'lib/types/lifecycle-state-types.js'; import type { InviteLinksStore } from 'lib/types/link-types.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; import type { MessageStore } from 'lib/types/message-types.js'; import type { WebNavInfo } from 'lib/types/nav-types.js'; import type { UserPolicies } from 'lib/types/policy-types.js'; import type { BaseAction } from 'lib/types/redux-types.js'; import type { ReportStore } from 'lib/types/report-types.js'; import type { StoreOperations } from 'lib/types/store-ops-types.js'; import type { GlobalThemeInfo } from 'lib/types/theme-types.js'; import type { ThreadActivityStore } from 'lib/types/thread-activity-types'; import type { ThreadStore } from 'lib/types/thread-types.js'; import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js'; import type { NotifPermissionAlertInfo } from 'lib/utils/push-alerts.js'; import { resetUserSpecificState } from 'lib/utils/reducers-utils.js'; import { updateWindowActiveActionType, updateNavInfoActionType, updateWindowDimensionsActionType, setInitialReduxState, } from './action-types.js'; import { reduceCommunityPickerStore } from './community-picker-reducer.js'; import { defaultWebState } from './default-state.js'; import reduceNavInfo from './nav-reducer.js'; import { onStateDifference } from './redux-debug-utils.js'; import { reduceServicesAccessToken } from './services-access-token-reducer.js'; import { getVisibility } from './visibility.js'; import { activeThreadSelector } from '../selectors/nav-selectors.js'; import { processDBStoreOperations } from '../shared-worker/utils/store.js'; import type { InitialReduxState } from '../types/redux-types.js'; export type WindowDimensions = { width: number, height: number }; export type CommunityPickerStore = { +chat: ?string, +calendar: ?string, }; const nonUserSpecificFieldsWeb = [ 'loadingStatuses', 'windowDimensions', 'lifecycleState', 'nextLocalID', 'windowActive', 'pushApiPublicKey', 'keyserverStore', 'initialStateLoaded', '_persist', 'customServer', ]; export type AppState = { +navInfo: WebNavInfo, +currentUserInfo: ?CurrentUserInfo, +draftStore: DraftStore, +entryStore: EntryStore, +threadStore: ThreadStore, +userStore: UserStore, +messageStore: MessageStore, +loadingStatuses: { [key: string]: { [idx: number]: LoadingStatus } }, +calendarFilters: $ReadOnlyArray, +communityPickerStore: CommunityPickerStore, +windowDimensions: WindowDimensions, +notifPermissionAlertInfo: NotifPermissionAlertInfo, +watchedThreadIDs: $ReadOnlyArray, +lifecycleState: LifecycleState, +enabledApps: EnabledApps, +reportStore: ReportStore, +nextLocalID: number, +dataLoaded: boolean, +windowActive: boolean, +userPolicies: UserPolicies, +pushApiPublicKey: ?string, +_persist: ?PersistState, +commServicesAccessToken: ?string, +inviteLinksStore: InviteLinksStore, +keyserverStore: KeyserverStore, +threadActivityStore: ThreadActivityStore, +initialStateLoaded: boolean, +integrityStore: IntegrityStore, +globalThemeInfo: GlobalThemeInfo, +customServer: ?string, +communityStore: CommunityStore, +dbOpsStore: DBOpsStore, }; -export type Action = +export type Action = $ReadOnly< | BaseAction - | { +type: 'UPDATE_NAV_INFO', +payload: Partial } | { - +type: 'UPDATE_WINDOW_DIMENSIONS', - +payload: WindowDimensions, - } - | { - +type: 'UPDATE_WINDOW_ACTIVE', - +payload: boolean, - } - | { +type: 'SET_INITIAL_REDUX_STATE', +payload: InitialReduxState }; + +messageID?: MessageID, + ... + | { +type: 'UPDATE_NAV_INFO', +payload: Partial } + | { + +type: 'UPDATE_WINDOW_DIMENSIONS', + +payload: WindowDimensions, + } + | { + +type: 'UPDATE_WINDOW_ACTIVE', + +payload: boolean, + } + | { +type: 'SET_INITIAL_REDUX_STATE', +payload: InitialReduxState }, + }, +>; function reducer(oldState: AppState | void, action: Action): AppState { invariant(oldState, 'should be set'); let state = oldState; let storeOperations: StoreOperations = { draftStoreOperations: [], threadStoreOperations: [], messageStoreOperations: [], reportStoreOperations: [], userStoreOperations: [], keyserverStoreOperations: [], communityStoreOperations: [], integrityStoreOperations: [], }; if (action.type === setInitialReduxState) { const { userInfos, keyserverInfos, actualizedCalendarQuery, ...rest } = action.payload; const replaceOperations: ReplaceKeyserverOperation[] = []; for (const keyserverID in keyserverInfos) { replaceOperations.push({ type: 'replace_keyserver', payload: { id: keyserverID, keyserverInfo: { ...state.keyserverStore.keyserverInfos[keyserverID], ...keyserverInfos[keyserverID], actualizedCalendarQuery, }, }, }); } return validateStateAndProcessDBOperations( action, oldState, { ...state, ...rest, userStore: { userInfos }, keyserverStore: keyserverStoreOpsHandlers.processStoreOperations( state.keyserverStore, replaceOperations, ), initialStateLoaded: true, }, { ...storeOperations, keyserverStoreOperations: [ ...storeOperations.keyserverStoreOperations, ...replaceOperations, ], }, ); } else if (action.type === updateWindowDimensionsActionType) { return validateStateAndProcessDBOperations( action, oldState, { ...state, windowDimensions: action.payload, }, storeOperations, ); } else if (action.type === updateWindowActiveActionType) { return validateStateAndProcessDBOperations( action, oldState, { ...state, windowActive: action.payload, }, storeOperations, ); } else if (action.type === setNewSessionActionType) { const { keyserverID, sessionChange } = action.payload; if (!state.keyserverStore.keyserverInfos[keyserverID]) { if (sessionChange.cookie?.startsWith('user=')) { console.log( 'received sessionChange with user cookie, ' + `but keyserver ${keyserverID} is not in KeyserverStore!`, ); } return state; } if ( invalidSessionDowngrade( oldState, sessionChange.currentUserInfo, action.payload.preRequestUserState, keyserverID, ) ) { return { ...oldState, loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), }; } const replaceOperation: ReplaceKeyserverOperation = { type: 'replace_keyserver', payload: { id: keyserverID, keyserverInfo: { ...state.keyserverStore.keyserverInfos[keyserverID], sessionID: sessionChange.sessionID, }, }, }; state = { ...state, keyserverStore: keyserverStoreOpsHandlers.processStoreOperations( state.keyserverStore, [replaceOperation], ), }; storeOperations = { ...storeOperations, keyserverStoreOperations: [ ...storeOperations.keyserverStoreOperations, replaceOperation, ], }; } else if (action.type === deleteKeyserverAccountActionTypes.success) { const { currentUserInfo, preRequestUserState } = action.payload; const newKeyserverIDs = []; for (const keyserverID of action.payload.keyserverIDs) { if ( invalidSessionDowngrade( state, currentUserInfo, preRequestUserState, keyserverID, ) ) { continue; } newKeyserverIDs.push(keyserverID); } if (newKeyserverIDs.length === 0) { return { ...state, loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), }; } action = { ...action, payload: { ...action.payload, keyserverIDs: newKeyserverIDs, }, }; } else if ( action.type === logOutActionTypes.success || action.type === deleteAccountActionTypes.success ) { const { currentUserInfo, preRequestUserState } = action.payload; if ( identityInvalidSessionDowngrade( oldState, currentUserInfo, preRequestUserState, ) ) { return { ...oldState, loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), }; } state = resetUserSpecificState( state, defaultWebState, nonUserSpecificFieldsWeb, ); } else if (action.type === identityRegisterActionTypes.success) { state = resetUserSpecificState( state, defaultWebState, nonUserSpecificFieldsWeb, ); } if (action.type !== updateNavInfoActionType) { const baseReducerResult = baseReducer(state, action, onStateDifference); state = baseReducerResult.state; storeOperations = { ...baseReducerResult.storeOperations, keyserverStoreOperations: [ ...storeOperations.keyserverStoreOperations, ...baseReducerResult.storeOperations.keyserverStoreOperations, ], }; } const communityPickerStore = reduceCommunityPickerStore( state.communityPickerStore, action, ); state = { ...state, navInfo: reduceNavInfo( state.navInfo, action, state.threadStore.threadInfos, ), communityPickerStore, commServicesAccessToken: reduceServicesAccessToken( state.commServicesAccessToken, action, ), }; return validateStateAndProcessDBOperations( action, oldState, state, storeOperations, ); } function validateStateAndProcessDBOperations( action: Action, oldState: AppState, state: AppState, storeOperations: StoreOperations, ): AppState { const updateActiveThreadOps: ThreadStoreOperation[] = []; if ( (state.navInfo.activeChatThreadID && !state.navInfo.pendingThread && !state.threadStore.threadInfos[state.navInfo.activeChatThreadID]) || (!state.navInfo.activeChatThreadID && isLoggedIn(state)) ) { // Makes sure the active thread always exists state = { ...state, navInfo: { ...state.navInfo, activeChatThreadID: mostRecentlyReadThreadSelector(state), }, }; } const activeThread = activeThreadSelector(state); if ( activeThread && !state.navInfo.pendingThread && state.threadStore.threadInfos[activeThread].currentUser.unread && getVisibility().hidden() ) { console.warn( `thread ${activeThread} is active and unread, ` + 'but visibilityjs reports the window is not visible', ); } if ( activeThread && !state.navInfo.pendingThread && state.threadStore.threadInfos[activeThread].currentUser.unread && typeof document !== 'undefined' && document && 'hasFocus' in document && !document.hasFocus() ) { console.warn( `thread ${activeThread} is active and unread, ` + 'but document.hasFocus() is false', ); } if ( activeThread && !getVisibility().hidden() && typeof document !== 'undefined' && document && 'hasFocus' in document && document.hasFocus() && !state.navInfo.pendingThread && state.threadStore.threadInfos[activeThread].currentUser.unread ) { // Makes sure a currently focused thread is never unread const activeThreadInfo = state.threadStore.threadInfos[activeThread]; updateActiveThreadOps.push({ type: 'replace', payload: { id: activeThread, threadInfo: { ...activeThreadInfo, currentUser: { ...activeThreadInfo.currentUser, unread: false, }, }, }, }); } const oldActiveThread = activeThreadSelector(oldState); if ( activeThread && oldActiveThread !== activeThread && state.messageStore.threads[activeThread] ) { const now = Date.now(); state = { ...state, threadActivityStore: { ...state.threadActivityStore, [(activeThread: string)]: { ...state.threadActivityStore[activeThread], lastNavigatedTo: now, }, }, }; } if (updateActiveThreadOps.length > 0) { state = { ...state, threadStore: threadStoreOpsHandlers.processStoreOperations( state.threadStore, updateActiveThreadOps, ), }; storeOperations = { ...storeOperations, threadStoreOperations: [ ...storeOperations.threadStoreOperations, ...updateActiveThreadOps, ], }; } // The operations were already dispatched from the main tab // For now the `dispatchSource` field is not included in any of the // redux actions and this causes flow to throw an error. // As soon as one of the actions is updated, this fix (and the corresponding // one in tab-synchronization.js) can be removed. // $FlowFixMe if (action.dispatchSource !== 'tab-sync') { void processDBStoreOperations( storeOperations, state.currentUserInfo?.id ?? null, ); } return state; } export { nonUserSpecificFieldsWeb, reducer };