Skip to content

Commit 6bd462d

Browse files
committed
feat: moved to user settings the App version info details
also cleanup remaining of the settings state in redux
1 parent fe57721 commit 6bd462d

File tree

10 files changed

+74
-393
lines changed

10 files changed

+74
-393
lines changed

ts/components/SessionMainPanel.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
import { useSelector } from 'react-redux';
21
import { useAppIsFocused } from '../hooks/useAppFocused';
3-
import { getFocusedSettingsSection } from '../state/selectors/section';
42

53
import { SmartSessionConversation } from '../state/smart/SessionConversation';
6-
import { SessionSettingsView } from './settings/SessionSettings';
74
import { useHTMLDirection } from '../util/i18n/rtlSupport';
85

9-
const FilteredSettingsView = SessionSettingsView as any;
10-
116
export const SessionMainPanel = () => {
12-
const focusedSettingsSection = useSelector(getFocusedSettingsSection);
13-
const isSettingsView = focusedSettingsSection !== undefined;
147
const htmlDirection = useHTMLDirection();
158

169
// even if it looks like this does nothing, this does update the redux store.
1710
useAppIsFocused();
1811

19-
if (isSettingsView) {
20-
return <FilteredSettingsView category={focusedSettingsSection} />;
21-
}
2212
return (
2313
<div className="session-conversation">
2414
<SmartSessionConversation htmlDirection={htmlDirection} />

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

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ProIconButton } from '../../../buttons/ProButton';
2424
import { type SessionIconProps, SessionIcon } from '../../../icon';
2525
import { LUCIDE_ICONS_UNICODE } from '../../../icon/lucide';
2626
import { type LucideIconProps, LucideIcon } from '../../../icon/LucideIcon';
27-
import { SessionLucideIconButton } from '../../../icon/SessionIconButton';
27+
import { SessionIconButton, SessionLucideIconButton } from '../../../icon/SessionIconButton';
2828
import { QRView } from '../../../qrview/QrView';
2929
import { ModalBasicHeader, SessionWrapperModal } from '../../../SessionWrapperModal';
3030
import { showLinkVisitWarningDialog } from '../../OpenUrlModal';
@@ -34,6 +34,7 @@ import { ProfileHeader, ProfileName } from '../components';
3434
import type { ProfileDialogModes } from '../ProfileDialogModes';
3535
import { tr } from '../../../../localization/localeTools';
3636
import { useIsProAvailable } from '../../../../hooks/useIsProAvailable';
37+
import { setDebugMode } from '../../../../state/ducks/debug';
3738

3839
const handleKeyQRMode = (mode: ProfileDialogModes, setMode: (mode: ProfileDialogModes) => void) => {
3940
switch (mode) {
@@ -252,6 +253,74 @@ function AdminSection() {
252253
);
253254
}
254255

256+
const StyledVersionInfo = styled.div`
257+
display: flex;
258+
align-items: center;
259+
flex-direction: column;
260+
gap: var(--margins-xs);
261+
background: none;
262+
font-size: var(--font-size-sm);
263+
`;
264+
265+
const StyledSpanSessionInfo = styled.span<{ opacity?: number }>`
266+
opacity: ${props => props.opacity ?? 0.5};
267+
transition: var(--default-duration);
268+
user-select: text;
269+
cursor: pointer;
270+
271+
&:hover {
272+
opacity: 1;
273+
}
274+
`;
275+
276+
const SessionInfo = () => {
277+
const [clickCount, setClickCount] = useState(0);
278+
279+
const dispatch = useDispatch();
280+
281+
return (
282+
<StyledVersionInfo>
283+
<SessionIconButton
284+
iconSize="medium"
285+
iconType="sessionTokenLogoWithText"
286+
onClick={() => {
287+
showLinkVisitWarningDialog('https://token.getsession.org/', dispatch);
288+
}}
289+
// disable transition here as the transition does the opposite that usual (hovering makes it more opaque/bright)
290+
style={{ transition: 'none' }}
291+
/>
292+
<Flex
293+
$container={true}
294+
$flexDirection="row"
295+
$alignItems="center"
296+
$flexGap="var(--margins-sm)"
297+
>
298+
<StyledSpanSessionInfo
299+
onClick={() => {
300+
showLinkVisitWarningDialog(
301+
`https://github.com/session-foundation/session-desktop/releases/tag/v${window.versionInfo.version}`,
302+
dispatch
303+
);
304+
}}
305+
>
306+
v{window.versionInfo.version}
307+
</StyledSpanSessionInfo>
308+
<StyledSpanSessionInfo
309+
onClick={() => {
310+
setClickCount(clickCount + 1);
311+
if (clickCount === 10) {
312+
dispatch(setDebugMode(true));
313+
setClickCount(0);
314+
}
315+
}}
316+
>
317+
{window.versionInfo.commitHash?.slice(0, 8)}
318+
</StyledSpanSessionInfo>
319+
</Flex>
320+
</StyledVersionInfo>
321+
);
322+
};
323+
255324
export const DefaultSettingPage = () => {
256325
const dispatch = useDispatch();
257326

@@ -344,6 +413,7 @@ export const DefaultSettingPage = () => {
344413
<MiscSection />
345414
<SettingsSection />
346415
<AdminSection />
416+
<SessionInfo />
347417
</Flex>
348418
</SessionWrapperModal>
349419
</StyledUserSettingsDialog>

ts/components/leftpane/LeftPane.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { IncomingCallDialog } from '../calling/IncomingCallDialog';
99
import { ModalContainer } from '../dialog/ModalContainer';
1010
import { ActionsPanel } from './ActionsPanel';
1111
import { LeftPaneMessageSection } from './LeftPaneMessageSection';
12-
import { LeftPaneSettingSection } from './LeftPaneSettingSection';
1312
import { useIsRtl } from '../../util/i18n/rtlSupport';
1413

1514
export const leftPaneListWidth = 300; // var(--left-panel-width) without the 80px of the action gutter
@@ -33,9 +32,6 @@ const LeftPaneSection = () => {
3332
return <LeftPaneMessageSection />;
3433
}
3534

36-
if (focusedSection === SectionType.Settings) {
37-
return <LeftPaneSettingSection />;
38-
}
3935
return null;
4036
};
4137

ts/components/leftpane/LeftPaneSectionHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { searchActions } from '../../state/ducks/search';
1818
import { LUCIDE_ICONS_UNICODE } from '../icon/lucide';
1919
import { SessionLucideIconButton } from '../icon/SessionIconButton';
2020
import { tr } from '../../localization/localeTools';
21+
import { userSettingsModal } from '../../state/ducks/modalDialog';
2122

2223
const StyledLeftPaneSectionHeader = styled(Flex)`
2324
height: var(--main-view-header-height);
@@ -114,8 +115,7 @@ export const LeftPaneBanner = () => {
114115

115116
const showRecoveryPhraseModal = () => {
116117
dispatch(disableRecoveryPhrasePrompt());
117-
dispatch(sectionActions.showLeftPaneSection(SectionType.Settings));
118-
dispatch(sectionActions.showSettingsSection('recovery-password'));
118+
dispatch(userSettingsModal({ userSettingsPage: 'recovery-password' }));
119119
};
120120

121121
if (section !== SectionType.Message || isSignInWithRecoveryPhrase || hideRecoveryPassword) {

ts/components/leftpane/LeftPaneSettingSection.tsx

Lines changed: 0 additions & 187 deletions
This file was deleted.

0 commit comments

Comments
 (0)