2023-05-25 16:15:16 +00:00
|
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import type { GlobalModalsStateType } from '../ducks/globalModals';
|
2024-01-29 20:09:54 +00:00
|
|
|
import { UsernameOnboardingState } from '../../types/globalModals';
|
2023-05-25 16:15:16 +00:00
|
|
|
|
|
|
|
export const getGlobalModalsState = (state: StateType): GlobalModalsStateType =>
|
|
|
|
state.globalModals;
|
|
|
|
|
|
|
|
export const isShowingAnyModal = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
(globalModalsState): boolean =>
|
2024-01-29 20:09:54 +00:00
|
|
|
Object.entries(globalModalsState).some(([key, value]) => {
|
|
|
|
if (key === 'usernameOnboardingState') {
|
|
|
|
return value === UsernameOnboardingState.Open;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Boolean(value);
|
|
|
|
})
|
2023-05-25 16:15:16 +00:00
|
|
|
);
|
2024-03-13 20:44:13 +00:00
|
|
|
|
2024-06-10 15:23:43 +00:00
|
|
|
export const getCallLinkEditModalRoomId = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ callLinkEditModalRoomId }) => callLinkEditModalRoomId
|
|
|
|
);
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const getContactModalState = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ contactModalState }) => contactModalState
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getIsStoriesSettingsVisible = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ isStoriesSettingsVisible }) => isStoriesSettingsVisible
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getSafetyNumberChangedBlockingData = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ safetyNumberChangedBlockingData }) => safetyNumberChangedBlockingData
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getDeleteMessagesProps = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ deleteMessagesProps }) => deleteMessagesProps
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getEditHistoryMessages = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ editHistoryMessages }) => editHistoryMessages
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getForwardMessagesProps = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ forwardMessagesProps }) => forwardMessagesProps
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getProfileEditorHasError = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ profileEditorHasError }) => profileEditorHasError
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getProfileEditorInitialEditState = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ profileEditorInitialEditState }) => profileEditorInitialEditState
|
|
|
|
);
|
2024-03-26 19:48:33 +00:00
|
|
|
|
|
|
|
export const getEditNicknameAndNoteModalProps = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ editNicknameAndNoteModalProps }) => editNicknameAndNoteModalProps
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getNotePreviewModalProps = createSelector(
|
|
|
|
getGlobalModalsState,
|
|
|
|
({ notePreviewModalProps }) => notePreviewModalProps
|
|
|
|
);
|