Skip to content

Commit 7b112ca

Browse files
committed
feat: link delete account modal to new user settings page
1 parent f498b37 commit 7b112ca

File tree

6 files changed

+6
-22
lines changed

6 files changed

+6
-22
lines changed

ts/components/dialog/DeleteAccountModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export const DeleteAccountModal = () => {
123123
<SessionWrapperModal
124124
headerChildren={<ModalBasicHeader title={tr('clearDataAll')} />}
125125
onClose={onClickCancelHandler}
126+
topAnchor="center"
126127
buttonChildren={
127128
<ModalActionsContainer>
128129
<SessionButton

ts/components/dialog/user-settings/pages/DefaultSettingsPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
updateSessionNetworkModal,
1313
updateConversationDetailsModal,
1414
userSettingsModal,
15+
updateDeleteAccountModal,
1516
} from '../../../../state/ducks/modalDialog';
1617
import { networkDataActions } from '../../../../state/ducks/networkData';
1718
import { sectionActions } from '../../../../state/ducks/section';
@@ -214,6 +215,7 @@ function SettingsSection() {
214215
}
215216

216217
function AdminSection() {
218+
const dispatch = useDispatch();
217219
return (
218220
<PanelButtonGroup>
219221
<PanelIconButton
@@ -241,7 +243,7 @@ function AdminSection() {
241243
}
242244
text={tr('sessionClearData')}
243245
onClick={() => {
244-
throw new Error('Not implemented');
246+
dispatch(updateDeleteAccountModal({}));
245247
}}
246248
dataTestId="clear-data-settings-menu-item"
247249
color="var(--danger-color)"

ts/components/leftpane/LeftPaneSettingSection.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import { type ReactNode, SessionDataTestId, useMemo } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import styled from 'styled-components';
44

5-
import { updateDeleteAccountModal } from '../../state/ducks/modalDialog';
65
import { sectionActions } from '../../state/ducks/section';
76
import { getFocusedSettingsSection } from '../../state/selectors/section';
87
import { useHideRecoveryPasswordEnabled } from '../../state/selectors/settings';
98
import type { SessionSettingCategory } from '../../types/ReduxTypes';
109
import { Flex } from '../basic/Flex';
1110
import { SessionIcon, SessionIconType } from '../icon';
1211
import { LeftPaneSectionHeader } from './LeftPaneSectionHeader';
13-
import { getSessionNetworkModalState } from '../../state/selectors/modal';
1412
import { Localizer } from '../basic/Localizer';
1513
import { tr } from '../../localization/localeTools';
1614
import { LUCIDE_ICONS_UNICODE, type WithLucideUnicode } from '../icon/lucide';
@@ -111,12 +109,8 @@ const LeftPaneSettingsCategoryRow = ({ item }: { item: Categories }) => {
111109
const { id, title, titleColor, icon, dataTestId, isNew } = item;
112110
const dispatch = useDispatch();
113111
const focusedSettingsSection = useSelector(getFocusedSettingsSection);
114-
const sessionNetworkModalState = useSelector(getSessionNetworkModalState);
115112

116-
const isSelected = useMemo(
117-
() => (sessionNetworkModalState ? id === 'session-network' : focusedSettingsSection === id),
118-
[focusedSettingsSection, id, sessionNetworkModalState]
119-
);
113+
const isSelected = useMemo(() => focusedSettingsSection === id, [focusedSettingsSection, id]);
120114

121115
const iconSize = 'medium';
122116

@@ -135,13 +129,6 @@ const LeftPaneSettingsCategoryRow = ({ item }: { item: Categories }) => {
135129
switch (id) {
136130
case 'message-requests':
137131
break;
138-
case 'session-network':
139-
// if the network modal is not open yet do an info request
140-
141-
break;
142-
case 'clear-data':
143-
dispatch(updateDeleteAccountModal({}));
144-
break;
145132
default:
146133
dispatch(sectionActions.showSettingsSection(id));
147134
}

ts/components/settings/SessionSettings.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ const SettingInCategory = (props: { category: SessionSettingCategory }) => {
123123

124124
// these are just buttons or modals and don't have screens
125125
case 'message-requests':
126-
case 'session-network':
127-
case 'clear-data':
128126
default:
129127
return null;
130128
}

ts/components/settings/SessionSettingsHeader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ export const SettingsHeader = (props: Props) => {
4242
categoryTitleKey = 'sessionRecoveryPassword';
4343
break;
4444
// these are modals or other screens
45-
case 'session-network':
46-
case 'clear-data':
4745
case 'message-requests':
4846
throw new Error(`no header for should be tried to be rendered for "${category}"`);
4947

ts/types/ReduxTypes.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ export type SessionSettingCategory =
1010
| 'message-requests'
1111
| 'appearance'
1212
| 'permissions'
13-
| 'session-network'
1413
| 'recovery-password'
15-
| 'help'
16-
| 'clear-data';
14+
| 'help';
1715

1816
export type PasswordAction = 'set' | 'change' | 'remove' | 'enter';
1917

0 commit comments

Comments
 (0)