chore: moved more types to ReduxTypes.d.ts

pull/3080/head
Audric Ackermann 3 weeks ago
parent fb99c3491c
commit 4589bde672

@ -2,7 +2,6 @@ import React, { useState } from 'react';
import classNames from 'classnames';
import { SessionIconButton } from '../icon';
import { Noop } from '../../types/Util';
import { useHTMLDirection } from '../../util/i18n';
type Props = {
@ -46,7 +45,7 @@ const ErrorItem = (props: { error: string | undefined }) => {
);
};
const ShowHideButton = (props: { toggleForceShow: Noop }) => {
const ShowHideButton = (props: { toggleForceShow: () => void }) => {
const htmlDirection = useHTMLDirection();
const position = htmlDirection === 'ltr' ? { right: '0px' } : { left: '0px' };

@ -1,6 +1,5 @@
import React from 'react';
import styled from 'styled-components';
import { Noop } from '../../../types/Util';
import { SessionIconButton } from '../../icon';
const StyledChatButtonContainer = styled.div`
@ -15,7 +14,7 @@ const StyledChatButtonContainer = styled.div`
}
`;
export const AddStagedAttachmentButton = (props: { onClick: Noop }) => {
export const AddStagedAttachmentButton = (props: { onClick: () => void }) => {
return (
<StyledChatButtonContainer>
<SessionIconButton
@ -32,7 +31,7 @@ export const AddStagedAttachmentButton = (props: { onClick: Noop }) => {
);
};
export const StartRecordingButton = (props: { onClick: Noop }) => {
export const StartRecordingButton = (props: { onClick: () => void }) => {
return (
<StyledChatButtonContainer>
<SessionIconButton
@ -50,7 +49,7 @@ export const StartRecordingButton = (props: { onClick: Noop }) => {
};
// eslint-disable-next-line react/display-name
export const ToggleEmojiButton = React.forwardRef<HTMLButtonElement, { onClick: Noop }>(
export const ToggleEmojiButton = React.forwardRef<HTMLButtonElement, { onClick: () => void }>(
(props, ref) => {
return (
<StyledChatButtonContainer>
@ -70,7 +69,7 @@ export const ToggleEmojiButton = React.forwardRef<HTMLButtonElement, { onClick:
}
);
export const SendMessageButton = (props: { onClick: Noop }) => {
export const SendMessageButton = (props: { onClick: () => void }) => {
return (
<StyledChatButtonContainer className="send-message-button">
<SessionIconButton

@ -11,6 +11,7 @@ import { SessionSpinner } from '../basic/SessionSpinner';
import { SpacerLG } from '../basic/Text';
import { SessionIconButton } from '../icon';
import { ProfileAvatar } from './EditProfileDialog';
import type { EditProfilePictureModalProps } from '../../types/ReduxTypes';
const StyledAvatarContainer = styled.div`
cursor: pointer;
@ -59,11 +60,6 @@ const uploadProfileAvatar = async (scaledAvatarUrl: string | null) => {
}
};
export type EditProfilePictureModalProps = {
avatarPath: string | null;
profileName: string | undefined;
ourId: string;
};
export const EditProfilePictureModal = (props: EditProfilePictureModalProps) => {
const dispatch = useDispatch();

@ -11,8 +11,7 @@ import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/S
import { SessionWrapperModal } from '../SessionWrapperModal';
import { matchesHash, validatePassword } from '../../util/passwordUtils';
import { assertUnreachable } from '../../types/sqlSharedTypes';
export type PasswordAction = 'set' | 'change' | 'remove' | 'enter';
import type { PasswordAction } from '../../types/ReduxTypes';
interface Props {
passwordAction: PasswordAction;

@ -13,7 +13,7 @@ import {
import { getFocusedSettingsSection } from '../../state/selectors/section';
import { SessionIcon } from '../icon';
import { LeftPaneSectionHeader } from './LeftPaneSectionHeader';
import type { SessionSettingCategory } from '../../types/SessionSettingCategory';
import type { SessionSettingCategory } from '../../types/ReduxTypes';
const StyledSettingsSectionTitle = styled.strong`
font-family: var(--font-accent), var(--font-default);

@ -7,7 +7,6 @@ import { RegistrationContext, RegistrationPhase, signUp } from './RegistrationSt
import { RegistrationUserDetails } from './RegistrationUserDetails';
import { sanitizeDisplayNameOrToast, SignInMode } from './SignInTab';
import { TermsAndConditions } from './TermsAndConditions';
import { Noop } from '../../types/Util';
export enum SignUpMode {
Default,
@ -23,7 +22,7 @@ const ContinueSignUpButton = ({ continueSignUp }: { continueSignUp: any }) => {
return <SessionButton onClick={continueSignUp} text={window.i18n('continue')} />;
};
const SignUpDefault = (props: { createSessionID: Noop }) => {
const SignUpDefault = (props: { createSessionID: () => void }) => {
return (
<div className="session-registration__content">
<CreateSessionIdButton createSessionID={props.createSessionID} />
@ -47,7 +46,7 @@ export const GoBackMainMenuButton = () => {
);
};
const SignUpSessionIDShown = (props: { continueSignUp: Noop }) => {
const SignUpSessionIDShown = (props: { continueSignUp: () => void }) => {
return (
<div className="session-registration__content">
<Flex flexDirection="row" container={true} alignItems="center">

@ -10,7 +10,7 @@ import {
import { SessionToggle } from '../basic/SessionToggle';
import { SessionConfirmDialogProps } from '../dialog/SessionConfirm';
import { SessionIconButton } from '../icon';
import { Noop } from '../../types/Util';
type ButtonSettingsProps = {
title?: string;
@ -113,7 +113,7 @@ export const SessionSettingsItemWrapper = (props: {
);
};
export const SessionSettingsTitleWithLink = (props: { title: string; onClick: Noop }) => {
export const SessionSettingsTitleWithLink = (props: { title: string; onClick: () => void }) => {
const { onClick, title } = props;
return (
<StyledSettingItemClickable onClick={onClick}>

@ -13,13 +13,12 @@ import { SessionNotificationGroupSettings } from './SessionNotificationGroupSett
import { Data } from '../../data/data';
import { sessionPassword } from '../../state/ducks/modalDialog';
import { SectionType, showLeftPaneSection } from '../../state/ducks/section';
import { PasswordAction } from '../dialog/SessionPasswordDialog';
import { SettingsCategoryAppearance } from './section/CategoryAppearance';
import { CategoryConversations } from './section/CategoryConversations';
import { SettingsCategoryHelp } from './section/CategoryHelp';
import { SettingsCategoryPermissions } from './section/CategoryPermissions';
import { SettingsCategoryPrivacy } from './section/CategoryPrivacy';
import type { SessionSettingCategory } from '../../types/SessionSettingCategory';
import type { SessionSettingCategory, PasswordAction } from '../../types/ReduxTypes';
export function displayPasswordModal(
passwordAction: PasswordAction,

@ -1,6 +1,5 @@
import { isString } from 'lodash';
import { LocaleMessagesType } from './locale';
import { Noop } from '../types/Util';
export const createTemplate = (
options: {
@ -157,7 +156,7 @@ export const createTemplate = (
function updateForMac(
template: any,
messages: LocaleMessagesType,
options: { showAbout: Noop; showWindow: Noop }
options: { showAbout: () => void; showWindow: () => void }
) {
const { showAbout, showWindow } = options;

@ -1,8 +1,6 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { EditProfilePictureModalProps } from '../../components/dialog/EditProfilePictureModal';
import { SessionConfirmDialogProps } from '../../components/dialog/SessionConfirm';
import { PasswordAction } from '../../components/dialog/SessionPasswordDialog';
import { Noop } from '../../types/Util';
import type { EditProfilePictureModalProps, PasswordAction } from '../../types/ReduxTypes';
export type BanType = 'ban' | 'unban';
@ -23,7 +21,7 @@ export type OnionPathModalState = EditProfileModalState;
export type RecoveryPhraseModalState = EditProfileModalState;
export type DeleteAccountModalState = EditProfileModalState;
export type SessionPasswordModalState = { passwordAction: PasswordAction; onOk: Noop } | null;
export type SessionPasswordModalState = { passwordAction: PasswordAction; onOk: () => void } | null;
export type UserDetailsModalState = {
conversationId: string;

@ -1,6 +1,6 @@
// TODO move into redux slice
import type { SessionSettingCategory } from '../../types/SessionSettingCategory';
import type { SessionSettingCategory } from '../../types/ReduxTypes';
export const FOCUS_SECTION = 'FOCUS_SECTION';
export const FOCUS_SETTINGS_SECTION = 'FOCUS_SETTINGS_SECTION';

@ -1,9 +1,5 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { isFinite, sortBy, uniq, xor } from 'lodash';
import {
getCanWriteOutsideRedux,
getCurrentSubscriberCountOutsideRedux,
} from '../selectors/sogsRoomInfo';
type RoomInfo = {
canWrite: boolean;
@ -79,16 +75,10 @@ export const ReduxSogsRoomInfos = {
};
function setSubscriberCountOutsideRedux(convoId: string, subscriberCount: number) {
if (subscriberCount === getCurrentSubscriberCountOutsideRedux(convoId)) {
return;
}
window.inboxStore?.dispatch(setSubscriberCount({ convoId, subscriberCount }));
}
function setCanWriteOutsideRedux(convoId: string, canWrite: boolean) {
if (getCanWriteOutsideRedux(convoId) === canWrite) {
return;
}
window.inboxStore?.dispatch(setCanWrite({ convoId, canWrite }));
}

@ -6,14 +6,14 @@ import { defaultRoomReducer as defaultRooms, DefaultRoomsState } from './ducks/d
import { reducer as primaryColor } from './ducks/primaryColor'; // ok: importing only Constants.tsx which is not importing anything else
import { reducer as search, SearchStateType } from './ducks/search'; // todo
import { reducer as section, SectionStateType } from './ducks/section'; // ok: importing only SessionSettingsCategory which is not importing anything else
import { ReduxSogsRoomInfos, SogsRoomInfoState } from './ducks/sogsRoomInfo'; // todo
import { ReduxSogsRoomInfos, SogsRoomInfoState } from './ducks/sogsRoomInfo'; // ok: importing nothing else
import { reducer as theme } from './ducks/theme'; // ok: importing only Constants.tsx which is not importing anything else
import { reducer as user, UserStateType } from './ducks/user'; // ok: not importing anything else
import { PrimaryColorStateType, ThemeStateType } from '../themes/constants/colors'; // ok: not importing anything else
import { modalReducer as modals, ModalState } from './ducks/modalDialog';
import { modalReducer as modals, ModalState } from './ducks/modalDialog'; // todo
import { defaultOnionReducer as onionPaths, OnionState } from './ducks/onion'; // ok: not importing anything else
import { settingsReducer, SettingsState } from './ducks/settings';
import { settingsReducer, SettingsState } from './ducks/settings'; // ok: just importing settings-key.tsx which is not importing anything else
import {
reducer as stagedAttachments,
StagedAttachmentsStateType,

@ -2,7 +2,7 @@ import { createSelector } from '@reduxjs/toolkit';
import { LeftOverlayMode, SectionStateType, SectionType } from '../ducks/section';
import { StateType } from '../reducer';
import type { SessionSettingCategory } from '../../types/SessionSettingCategory';
import type { SessionSettingCategory } from '../../types/ReduxTypes';
export const getSection = (state: StateType): SectionStateType => state.section;

@ -0,0 +1,23 @@
/**
* Note: The types defined in this file have to be self contained.
* We must not import anything in this file, especially not something relying on the window object (even indirectly, through an import chain).
*/
export type SessionSettingCategory =
| 'privacy'
| 'notifications'
| 'conversations'
| 'messageRequests'
| 'appearance'
| 'permissions'
| 'help'
| 'recoveryPhrase'
| 'ClearData';
export type PasswordAction = 'set' | 'change' | 'remove' | 'enter';
export type EditProfilePictureModalProps = {
avatarPath: string | null;
profileName: string | undefined;
ourId: string;
};

@ -1,10 +0,0 @@
export type SessionSettingCategory =
| 'privacy'
| 'notifications'
| 'conversations'
| 'messageRequests'
| 'appearance'
| 'permissions'
| 'help'
| 'recoveryPhrase'
| 'ClearData';

@ -7,5 +7,3 @@ export type RenderTextCallbackType = (options: {
}) => JSX.Element;
export type LocalizerType = (key: LocalizerKeys, values?: Array<string>) => string;
export type Noop = () => void;

Loading…
Cancel
Save