Skip to content

Commit

Permalink
Merge pull request #3077 from oxen-io/clearnet
Browse files Browse the repository at this point in the history
Session 1.12.2
  • Loading branch information
Bilb authored Apr 12, 2024
2 parents 7329920 + ab971ab commit c681916
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 57 deletions.
3 changes: 2 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,5 +578,6 @@
"resolution": "Resolution",
"duration": "Duration",
"notApplicable": "N/A",
"unknownError": "Unknown Error"
"unknownError": "Unknown Error",
"displayNameErrorNew": "We were unable to load your display name. Please enter a new display name to continue."
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "session-desktop",
"productName": "Session",
"description": "Private messaging from your desktop",
"version": "1.12.1",
"version": "1.12.2",
"license": "GPL-3.0",
"author": {
"name": "Oxen Labs",
Expand Down
2 changes: 1 addition & 1 deletion preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ window.getNodeVersion = () => configAny.node_version;

window.sessionFeatureFlags = {
useOnionRequests: true,
useTestNet: isTestNet(),
useTestNet: isTestNet() || isTestIntegration(),
integrationTestEnv: isTestIntegration(),
useClosedGroupV3: false,
debug: {
Expand Down
1 change: 0 additions & 1 deletion stylesheets/_session_constants.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ $session-margin-md: 15px;
$session-margin-lg: 20px;

// Animations
$session-transition-duration: 0.25s;

@keyframes fadein {
from {
Expand Down
4 changes: 2 additions & 2 deletions stylesheets/_session_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@
}
.rc-slider-tooltip-zoom-down-enter,
.rc-slider-tooltip-zoom-down-appear {
animation-duration: 0.3s;
animation-duration: var(--default-duration);
animation-fill-mode: both;
display: block !important;
animation-play-state: paused;
}
.rc-slider-tooltip-zoom-down-leave {
animation-duration: 0.3s;
animation-duration: var(--default-duration);
animation-fill-mode: both;
display: block !important;
animation-play-state: paused;
Expand Down
21 changes: 21 additions & 0 deletions ts/components/SessionFocusTrap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import FocusTrap from 'focus-trap-react';
import React, { useState } from 'react';
import { useMount } from 'react-use';

/**
* Focus trap which activates on mount.
*/
export function SessionFocusTrap(props: { children: React.ReactNode }) {
const [active, setActive] = useState(false);

// Activate the trap on mount so we **should** have a button to tab through. focus-trap-react will throw if we don't have a button when the trap becomes active.
// We might still have an issue for dialogs which have buttons added with a useEffect, or asynchronously but have no buttons on mount.
// If that happens we will need to force those dialogs to have at least one button so focus-trap-react does not throw.
useMount(() => setActive(true));

return (
<FocusTrap active={active} focusTrapOptions={{ initialFocus: false, allowOutsideClick: true }}>
{props.children}
</FocusTrap>
);
}
8 changes: 4 additions & 4 deletions ts/components/SessionWrapperModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import classNames from 'classnames';
import FocusTrap from 'focus-trap-react';
import React, { useRef } from 'react';
import useKey from 'react-use/lib/useKey';

import { SessionIconButton } from './icon';

import { SessionButton, SessionButtonColor, SessionButtonType } from './basic/SessionButton';
import { SessionFocusTrap } from './SessionFocusTrap';

export type SessionWrapperModalType = {
title?: string;
Expand All @@ -17,7 +17,7 @@ export type SessionWrapperModalType = {
cancelText?: string;
showExitIcon?: boolean;
headerIconButtons?: Array<any>;
children: any;
children: React.ReactNode;
headerReverse?: boolean;
additionalClassName?: string;
};
Expand Down Expand Up @@ -64,7 +64,7 @@ export const SessionWrapperModal = (props: SessionWrapperModalType) => {
};

return (
<FocusTrap focusTrapOptions={{ initialFocus: false, allowOutsideClick: true }}>
<SessionFocusTrap>
<div
className={classNames('loki-dialog modal', additionalClassName || null)}
onClick={handleClick}
Expand Down Expand Up @@ -128,6 +128,6 @@ export const SessionWrapperModal = (props: SessionWrapperModalType) => {
</div>
</div>
</div>
</FocusTrap>
</SessionFocusTrap>
);
};
2 changes: 1 addition & 1 deletion ts/components/calling/CallButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ const StyledCallWindowControls = styled.div<{ isFullScreen: boolean; makeVisible
margin-right: auto;
left: 0;
right: 0;
transition: all 0.25s ease-in-out;
transition: all var(--default-duration) ease-in-out;
display: flex;
justify-content: center;
Expand Down
4 changes: 2 additions & 2 deletions ts/components/conversation/composition/UserMentions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { SuggestionDataItem } from 'react-mentions';
import { MemberListItem } from '../../MemberListItem';
import { HTMLDirection } from '../../../util/i18n';
import { MemberListItem } from '../../MemberListItem';

const listRTLStyle = { position: 'absolute', bottom: '0px', right: '100%' };

Expand All @@ -21,7 +21,7 @@ export const styleForCompositionBoxSuggestions = (dir: HTMLDirection = 'ltr') =>
paddingBottom: '5px',
backgroundColor: 'var(--suggestions-background-color)',
color: 'var(--suggestions-text-color)',
transition: '0.25s',
transition: 'var(--default-duration)',

'&focused': {
backgroundColor: 'var(--suggestions-background-hover-color)',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FocusTrap from 'focus-trap-react';
import React from 'react';

import { useDispatch, useSelector } from 'react-redux';
import useKey from 'react-use/lib/useKey';

Expand All @@ -17,6 +17,7 @@ import {
SessionButtonType,
} from '../../basic/SessionButton';
import { SessionIconButton } from '../../icon';
import { SessionFocusTrap } from '../../SessionFocusTrap';

export const SelectionOverlay = () => {
const selectedMessageIds = useSelector(getSelectedMessageIds);
Expand Down Expand Up @@ -69,7 +70,7 @@ export const SelectionOverlay = () => {
const classNameAndId = 'message-selection-overlay';

return (
<FocusTrap focusTrapOptions={{ initialFocus: false, allowOutsideClick: true }}>
<SessionFocusTrap>
<div className={classNameAndId} id={classNameAndId}>
<div className="close-button">
<SessionIconButton iconType="exit" iconSize="medium" onClick={onCloseOverlay} />
Expand All @@ -93,6 +94,6 @@ export const SelectionOverlay = () => {
/>
</div>
</div>
</FocusTrap>
</SessionFocusTrap>
);
};
4 changes: 2 additions & 2 deletions ts/components/conversation/right-panel/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const StyledRightPanelContainer = styled.div`
height: var(--right-panel-height);
right: 0vw;
transition: transform 0.3s ease-in-out;
transition: transform var(--default-duration) ease-in-out;
transform: translateX(100%);
will-change: transform;
width: var(--right-panel-width);
Expand All @@ -25,7 +25,7 @@ export const StyledRightPanelContainer = styled.div`
&.show {
transform: none;
transition: transform 0.3s ease-in-out;
transition: transform var(--default-duration) ease-in-out;
z-index: 3;
visibility: visible;
}
Expand Down
3 changes: 3 additions & 0 deletions ts/components/dialog/SessionSeedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const Password = (props: PasswordProps) => {
<input
type="password"
id="seed-input-password"
data-testid="password-input"
placeholder={i18n('enterPassword')}
onKeyUp={onEnter}
/>
Expand All @@ -77,12 +78,14 @@ const Password = (props: PasswordProps) => {
text={i18n('done')}
buttonType={SessionButtonType.Simple}
onClick={confirmPassword}
dataTestId="session-confirm-ok-button"
/>
<SessionButton
text={i18n('cancel')}
buttonType={SessionButtonType.Simple}
buttonColor={SessionButtonColor.Danger}
onClick={onClose}
dataTestId="session-confirm-cancel-button"
/>
</div>
</>
Expand Down
2 changes: 1 addition & 1 deletion ts/components/leftpane/LeftPaneSectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const StyledProgressBarContainer = styled.div`
const StyledProgressBarInner = styled.div`
background: var(--primary-color);
width: 90%;
transition: width 0.5s ease-in;
transition: width var(--default-duration) ease-in;
height: 100%;
`;

Expand Down
4 changes: 2 additions & 2 deletions ts/components/leftpane/MessageRequestsBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { createPortal } from 'react-dom';
import { useSelector } from 'react-redux';
import styled from 'styled-components';
import { getUnreadConversationRequests } from '../../state/selectors/conversations';
import { isSearching } from '../../state/selectors/search';
import { getHideMessageRequestBanner } from '../../state/selectors/userConfig';
import { SessionIcon, SessionIconSize, SessionIconType } from '../icon';
import { MessageRequestBannerContextMenu } from '../menu/MessageRequestBannerContextMenu';
import { isSearching } from '../../state/selectors/search';

const StyledMessageRequestBanner = styled.div`
height: 64px;
Expand Down Expand Up @@ -137,6 +137,6 @@ export const MessageRequestsBanner = (props: { handleOnClick: () => any }) => {
);
};

const Portal = ({ children }: { children: any }) => {
const Portal = ({ children }: { children: React.ReactNode }) => {
return createPortal(children, document.querySelector('.inbox.index') as Element);
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type PropsHousekeeping = {

type Props = { conversationId: string } & PropsHousekeeping;

const Portal = ({ children }: { children: any }) => {
const Portal = ({ children }: { children: React.ReactNode }) => {
return createPortal(children, document.querySelector('.inbox.index') as Element);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const StyledActionRow = styled.button`
display: flex;
align-items: center;
border-bottom: 1px var(--border-color) solid;
transition-duration: 0.25s;
transition-duration: var(--default-duration);
width: 100%;
&:first-child {
Expand Down
36 changes: 17 additions & 19 deletions ts/components/registration/RegistrationStages.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import React, { createContext, useEffect, useState } from 'react';
import { SignUpMode, SignUpTab } from './SignUpTab';
import { SignInMode, SignInTab } from './SignInTab';
import { Data } from '../../data/data';
import { SettingsKey } from '../../data/settings-key';
import { getSwarmPollingInstance } from '../../session/apis/snode_api';
import { getConversationController } from '../../session/conversations';
import { mnDecode } from '../../session/crypto/mnemonic';
import { PromiseUtils, StringUtils, ToastUtils } from '../../session/utils';
import { TaskTimedOutError } from '../../session/utils/Promise';
import { fromHex } from '../../session/utils/String';
import { trigger } from '../../shims/events';
import {
generateMnemonic,
registerSingleDevice,
sessionGenerateKeyPair,
signInByLinkingDevice,
} from '../../util/accountManager';
import { fromHex } from '../../session/utils/String';
import { setSignInByLinking, setSignWithRecoveryPhrase, Storage } from '../../util/storage';
import { SettingsKey } from '../../data/settings-key';
import { Storage, setSignInByLinking, setSignWithRecoveryPhrase } from '../../util/storage';
import { SignInMode, SignInTab } from './SignInTab';
import { SignUpMode, SignUpTab } from './SignUpTab';

export async function resetRegistration() {
await Data.removeAll();
Expand Down Expand Up @@ -104,7 +103,10 @@ export async function signInWithRecovery(signInDetails: {
* This is will try to sign in with the user recovery phrase.
* If no ConfigurationMessage is received in 60seconds, the loading will be canceled.
*/
export async function signInWithLinking(signInDetails: { userRecoveryPhrase: string }) {
export async function signInWithLinking(
signInDetails: { userRecoveryPhrase: string },
setSignInMode: (phase: SignInMode) => void
) {
const { userRecoveryPhrase } = signInDetails;
window?.log?.info('LINKING DEVICE');

Expand Down Expand Up @@ -136,18 +138,14 @@ export async function signInWithLinking(signInDetails: { userRecoveryPhrase: str
trigger('openInbox');
} catch (e) {
await resetRegistration();
if (e instanceof TaskTimedOutError) {
ToastUtils.pushToastError(
'registrationError',
'Could not find your display name. Please Sign In by Restoring Your Account instead.'
);
} else {
ToastUtils.pushToastError(
'registrationError',
`Error: ${e.message || 'Something went wrong'}`
);
}
window?.log?.warn('exception during registration:', e);
ToastUtils.pushToastError('registrationError', window.i18n('displayNameErrorNew'));
window?.log?.error(
'[signInWithLinking] Error during sign in by linking lets try and sign in by recovery phrase',
e.message || e
);
getSwarmPollingInstance().stop(e);
await setSignWithRecoveryPhrase(false);
setSignInMode(SignInMode.UsingRecoveryPhrase);
}
}

Expand Down
11 changes: 7 additions & 4 deletions ts/components/registration/SignInTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const SignInTab = () => {
// from the configuration message will be used.
const showDisplayNameField = isRecovery;

// Display name is required only on isRecoveryMode
// Display name is required only on isRecoveryMode or if linking a device fails
const displayNameOK = (isRecovery && !displayNameError && !!displayName) || isLinking;

// Seed is mandatory no matter which mode
Expand All @@ -139,9 +139,12 @@ export const SignInTab = () => {
});
} else if (isLinking) {
setIsLoading(true);
await signInWithLinking({
userRecoveryPhrase: recoveryPhrase,
});
await signInWithLinking(
{
userRecoveryPhrase: recoveryPhrase,
},
setSignInMode
);
setIsLoading(false);
}
};
Expand Down
2 changes: 1 addition & 1 deletion ts/mains/main_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ async function createWindow() {
}, 5000);
}

if (isDevProd()) {
if (isDevProd() && !isTestIntegration()) {
// Open the DevTools.
mainWindow.webContents.openDevTools({
mode: 'bottom',
Expand Down
Loading

0 comments on commit c681916

Please sign in to comment.