Skip to content

Commit 367c0c9

Browse files
committed
Merge branch 'clearnet' into theming
2 parents f9c9ec4 + d1a33ad commit 367c0c9

29 files changed

+303
-120
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ Please visit https://deb.oxen.io/<br/>
5656
Copyright 2011 Whisper Systems<br/>
5757
Copyright 2013-2017 Open Whisper Systems<br/>
5858
Copyright 2019-2021 The Oxen Project<br/>
59-
Licensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html<br/>
59+
Licensed under the GPLv3: https://www.gnu.org/licenses/gpl-3.0.html<br/>

_locales/en/messages.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
"notificationPreview": "Preview",
364364
"recoveryPhraseEmpty": "Enter your recovery phrase",
365365
"displayNameEmpty": "Please enter a display name",
366+
"displayNameTooLong": "Display name is too long",
366367
"members": "$count$ members",
367368
"activeMembers": "$count$ active members",
368369
"join": "Join",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
"build-everything": "yarn clean && yarn protobuf && grunt && yarn sass && tsc && yarn parcel-util-worker",
5151
"build-everything:watch": "yarn clean && yarn protobuf && grunt && yarn sass && yarn parcel-util-worker && tsc -w",
52+
"watch": "yarn clean && yarn protobuf && grunt && concurrently 'yarn build-everything:watch' 'yarn sass:watch'",
5253

5354
"protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long",
5455
"sass": "rimraf 'stylesheets/dist/' && parcel build --target sass --no-autoinstall --no-cache",
@@ -198,6 +199,7 @@
198199
"chai": "^4.3.4",
199200
"chai-as-promised": "^7.1.1",
200201
"chai-bytes": "^0.1.2",
202+
"concurrently": "^7.4.0",
201203
"cross-env": "^6.0.3",
202204
"crypto-browserify": "^3.12.0",
203205
"electron": "^17.2.0",

stylesheets/_modules.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,8 @@
740740
flex-shrink: 1;
741741

742742
font-size: var(--font-size-sm);
743-
line-height: 18px;
744-
745743
color: var(--conversation-tab-text-color);
746744

747-
height: 1.3em;
748745
overflow: hidden;
749746
white-space: nowrap;
750747
text-overflow: ellipsis;

stylesheets/_session_theme.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66
background: var(--background-primary-color);
77
}
88

9+
.module-message__container {
10+
.module-message__text {
11+
font-size: 14px;
12+
text-align: start;
13+
overflow-wrap: break-word;
14+
word-wrap: break-word;
15+
word-break: break-word;
16+
white-space: pre-wrap;
17+
18+
a {
19+
text-decoration: underline;
20+
}
21+
}
22+
}
23+
924
.module-message {
1025
position: relative;
1126
display: inline-flex;

ts/components/SessionWrapperModal.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef } from 'react';
1+
import React, { useRef } from 'react';
22
import classNames from 'classnames';
33

44
import { SessionIconButton } from './icon/';
@@ -63,17 +63,11 @@ export const SessionWrapperModal = (props: SessionWrapperModalType) => {
6363
}
6464
};
6565

66-
useEffect(() => {
67-
document.addEventListener('mousedown', handleClick);
68-
69-
return () => {
70-
document.removeEventListener('mousedown', handleClick);
71-
};
72-
}, []);
73-
7466
return (
7567
<div
7668
className={classNames('loki-dialog modal', additionalClassName ? additionalClassName : null)}
69+
onClick={handleClick}
70+
role="dialog"
7771
>
7872
<div className="session-confirm-wrapper">
7973
<div ref={modalRef} className="session-modal">

ts/components/basic/SessionToast.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from 'react';
22

33
import { Flex } from '../basic/Flex';
44
import styled from 'styled-components';
5-
import { noop } from 'lodash';
65
import { SessionIcon, SessionIconType } from '../icon';
6+
import { noop } from 'lodash';
77

88
// NOTE We don't change the color strip on the left based on the type. 16/09/2022
99
export enum SessionToastType {
@@ -45,6 +45,8 @@ const IconDiv = styled.div`
4545
margin: 0 var(--margins-xs);
4646
`;
4747

48+
// tslint:disable: use-simple-attributes
49+
4850
export const SessionToast = (props: Props) => {
4951
const { title, description, type, icon } = props;
5052

@@ -72,12 +74,14 @@ export const SessionToast = (props: Props) => {
7274
}
7375
}
7476

77+
const onToastClick = props?.onToastClick || noop;
78+
7579
return (
7680
// tslint:disable-next-line: use-simple-attributes
7781
<Flex
7882
container={true}
7983
alignItems="center"
80-
onClick={props?.onToastClick || noop}
84+
onClick={onToastClick}
8185
data-testid="session-toast"
8286
padding="var(--margins-sm) 0"
8387
>

ts/components/dialog/EditProfileDialog.tsx

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import { uploadOurAvatar } from '../../interactions/conversationInteractions';
1515
import { SessionButton, SessionButtonType } from '../basic/SessionButton';
1616
import { SessionSpinner } from '../basic/SessionSpinner';
1717
import { SessionIconButton } from '../icon';
18-
import { MAX_USERNAME_LENGTH } from '../registration/RegistrationStages';
1918
import { SessionWrapperModal } from '../SessionWrapperModal';
2019
import { pickFileForAvatar } from '../../types/attachments/VisualAttachment';
2120
import { sanitizeSessionUsername } from '../../session/utils/String';
2221
import { setLastProfileUpdateTimestamp } from '../../util/storage';
2322
import { ConversationTypeEnum } from '../../models/conversationAttributes';
23+
import { MAX_USERNAME_BYTES } from '../../session/constants';
2424

2525
interface State {
2626
profileName: string;
@@ -211,7 +211,7 @@ export class EditProfileDialog extends React.Component<{}, State> {
211211
value={this.state.profileName}
212212
placeholder={placeholderText}
213213
onChange={this.onNameEdited}
214-
maxLength={MAX_USERNAME_LENGTH}
214+
maxLength={MAX_USERNAME_BYTES}
215215
tabIndex={0}
216216
required={true}
217217
aria-required={true}
@@ -237,10 +237,18 @@ export class EditProfileDialog extends React.Component<{}, State> {
237237
}
238238

239239
private onNameEdited(event: ChangeEvent<HTMLInputElement>) {
240-
const newName = sanitizeSessionUsername(event.target.value);
241-
this.setState({
242-
profileName: newName,
243-
});
240+
const displayName = event.target.value;
241+
try {
242+
const newName = sanitizeSessionUsername(displayName);
243+
this.setState({
244+
profileName: newName,
245+
});
246+
} catch (e) {
247+
this.setState({
248+
profileName: displayName,
249+
});
250+
ToastUtils.pushToastError('nameTooLong', window.i18n('displayNameTooLong'));
251+
}
244252
}
245253

246254
private onKeyUp(event: any) {
@@ -263,26 +271,37 @@ export class EditProfileDialog extends React.Component<{}, State> {
263271
*/
264272
private onClickOK() {
265273
const { newAvatarObjectUrl, profileName } = this.state;
266-
const newName = profileName ? profileName.trim() : '';
274+
try {
275+
const newName = profileName ? profileName.trim() : '';
276+
277+
if (newName.length === 0 || newName.length > MAX_USERNAME_BYTES) {
278+
return;
279+
}
280+
281+
// this throw if the length in bytes is too long
282+
const sanitizedName = sanitizeSessionUsername(newName);
283+
const trimName = sanitizedName.trim();
284+
285+
this.setState(
286+
{
287+
profileName: trimName,
288+
loading: true,
289+
},
290+
async () => {
291+
await commitProfileEdits(newName, newAvatarObjectUrl);
292+
this.setState({
293+
loading: false,
294+
295+
mode: 'default',
296+
updatedProfileName: this.state.profileName,
297+
});
298+
}
299+
);
300+
} catch (e) {
301+
ToastUtils.pushToastError('nameTooLong', window.i18n('displayNameTooLong'));
267302

268-
if (newName.length === 0 || newName.length > MAX_USERNAME_LENGTH) {
269303
return;
270304
}
271-
272-
this.setState(
273-
{
274-
loading: true,
275-
},
276-
async () => {
277-
await commitProfileEdits(newName, newAvatarObjectUrl);
278-
this.setState({
279-
loading: false,
280-
281-
mode: 'default',
282-
updatedProfileName: this.state.profileName,
283-
});
284-
}
285-
);
286305
}
287306

288307
private closeDialog() {

ts/components/leftpane/ActionsPanel.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import { getSwarmPollingInstance } from '../../session/apis/snode_api';
3939
import { forceRefreshRandomSnodePool } from '../../session/apis/snode_api/snodePool';
4040
import { Avatar, AvatarSize } from '../avatar/Avatar';
4141
import { SessionIconButton } from '../icon';
42-
import { SessionToastContainer } from '../SessionToastContainer';
4342
import { LeftPaneSectionContainer } from './LeftPaneSectionContainer';
4443
import { ipcRenderer } from 'electron';
4544
import { UserUtils } from '../../session/utils';
@@ -292,8 +291,6 @@ export const ActionsPanel = () => {
292291
<Section type={SectionType.Message} />
293292
<Section type={SectionType.Settings} />
294293

295-
<SessionToastContainer />
296-
297294
<Section type={SectionType.PathIndicator} />
298295
<Section type={SectionType.ColorMode} />
299296
</LeftPaneSectionContainer>

ts/components/leftpane/LeftPane.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CallInFullScreenContainer } from '../calling/CallInFullScreenContainer'
1212
import { DraggableCallContainer } from '../calling/DraggableCallContainer';
1313
import { IncomingCallDialog } from '../calling/IncomingCallDialog';
1414
import { ModalContainer } from '../dialog/ModalContainer';
15+
import { SessionToastContainer } from '../SessionToastContainer';
1516
import { ActionsPanel } from './ActionsPanel';
1617
import { LeftPaneMessageSection } from './LeftPaneMessageSection';
1718
import { LeftPaneSettingSection } from './LeftPaneSettingSection';
@@ -71,6 +72,7 @@ export const LeftPane = () => {
7172
<div className="module-left-pane-session">
7273
<ModalContainer />
7374
<CallContainer />
75+
<SessionToastContainer />
7476
<ActionsPanel />
7577

7678
<StyledLeftPane className="module-left-pane">

0 commit comments

Comments
 (0)