From eb3ee8f6b0d15e8be97b304520e587493a79bc68 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 13 Aug 2020 13:44:03 +1000 Subject: [PATCH] make leftpane overlay closer to android --- _locales/en/messages.json | 73 +++++++------------ ts/components/MainViewController.tsx | 42 ++++++----- .../session/LeftPaneMessageSection.tsx | 13 +--- .../session/SessionClosableOverlay.tsx | 18 +++-- .../session/settings/SessionSettings.tsx | 11 ++- 5 files changed, 69 insertions(+), 88 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 108077218..24b8bee6e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -169,6 +169,10 @@ "message": "Choose folder", "description": "Button to allow the user to find a folder on disk" }, + "done": { + "message": "Done", + "description": "Button when a specific action is to be done." + }, "loadDataHeader": { "message": "Load your data", "description": "Header shown on the first screen in the data import process" @@ -1558,23 +1562,15 @@ } }, "blockUser": { - "message": "Block User" + "message": "Block contact" }, "unblockUser": { - "message": "Unblock User" + "message": "Unblock contact" }, "blockedSettingsTitle": { - "message": "Blocked Users", + "message": "Blocked contacts", "description": "Shown in the settings page as the heading for the blocked user settings" }, - "editProfileTitle": { - "message": "Change your own display name", - "description": "The title shown when user edits their own profile" - }, - "editProfileDisplayNameWarning": { - "message": "Note: Your display name will be visible to your contacts", - "description": "Shown to the user as a warning about setting display name" - }, "copyPublicKey": { "message": "Copy Public Key", "description": "Button action that the user can click to copy their public keys" @@ -1713,8 +1709,8 @@ "message": "This is your unique public QR Code.
Other users may scan this in order to begin a conversation with you.", "description": "Description given to QRCode modal" }, - "noServerURL": { - "message": "Please enter a server URL", + "invalidOpenGroupUrl": { + "message": "Please enter an open group URL", "description": "Error message when no server url entered" }, "copiedMnemonic": { @@ -1797,7 +1793,7 @@ "message": "You are already connected to this open group" }, "connectToServerFail": { - "message": "Failed to connect to server. Check URL" + "message": "Couldn't join group" }, "connectingToServer": { "message": "Connecting to server..." @@ -2047,11 +2043,8 @@ "newClosedGroup": { "message": "New Closed Group" }, - "createClosedGroup": { - "message": "Create Closed Group" - }, - "createClosedGroupDescription": { - "message": "Closed groups are end-to-end encrypted group chats for up to 10 members. They provide the same privacy protections as one-on-one sessions." + "newClosedGroupDescription": { + "message": "Closed groups support up to 10 members and provide the same privacy protections as one-on-one sessions." }, "createClosedGroupNamePrompt": { "message": "Group Name" @@ -2065,14 +2058,11 @@ "enterOpenGroupURL": { "message": "Enter Open Group URL" }, - "channelUrlPlaceholder": { - "message": "chat.getsession.org" - }, - "addChannelDescription": { - "message": "Enter an open group URL." + "openGroupURL": { + "message": "Open Group URL" }, - "joinChannel": { - "message": "Join Open Group" + "enterAnOpenGroupURL": { + "message": "Enter an open group URL" }, "next": { "message": "Next" @@ -2089,25 +2079,17 @@ "devicePairedSuccessfully": { "message": "Device linked successfully" }, - "invalidGroupName": { - "message": "Group Name length must be between 1 to $maxSize$", - "description": "Error message displayed on invalid group name", - "placeholders": { - "maxSize": { - "content": "$1", - "example": "125" - } - } + "invalidGroupNameTooShort": { + "message": "Please enter a group name" }, - "invalidGroupSize": { - "message": "Closed Group size must be between 1 to $maxSize$", - "description": "Error message displayed on invalid closed group size", - "placeholders": { - "maxSize": { - "content": "$1", - "example": "10" - } - } + "invalidGroupNameTooLong": { + "message": "Please enter a shorter group name" + }, + "pickClosedGroupMember": { + "message": "Please pick at least 2 group members" + }, + "closedGroupMaxSize": { + "message": "A closed group cannot have more than 10 members" }, "maxGroupMembersError": { "message": "Max number of members for small group chats is $maxSize$", @@ -2117,8 +2099,5 @@ "example": "10" } } - }, - "useSenderKeys": { - "message": "Use Sender Keys" } } diff --git a/ts/components/MainViewController.tsx b/ts/components/MainViewController.tsx index 7c5affc38..b8e120380 100644 --- a/ts/components/MainViewController.tsx +++ b/ts/components/MainViewController.tsx @@ -48,15 +48,17 @@ async function createClosedGroup( onSuccess: any ) { // Validate groupName and groupMembers length - if ( - groupName.length === 0 || - groupName.length > window.CONSTANTS.MAX_GROUP_NAME_LENGTH - ) { + if (groupName.length === 0) { window.pushToast({ - title: window.i18n( - 'invalidGroupName', - window.CONSTANTS.MAX_GROUP_NAME_LENGTH - ), + title: window.i18n('invalidGroupNameTooShort'), + type: 'error', + id: 'invalidGroupName', + }); + + return; + } else if (groupName.length > window.CONSTANTS.MAX_GROUP_NAME_LENGTH) { + window.pushToast({ + title: window.i18n('invalidGroupNameTooLong'), type: 'error', id: 'invalidGroupName', }); @@ -64,18 +66,22 @@ async function createClosedGroup( return; } - // >= because we add ourself as a member after this. so a 10 group is already invalid as it will be 11 with ourself - if ( - groupMembers.length === 0 || - groupMembers.length >= window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT - ) { + // >= because we add ourself as a member AFTER this. so a 10 group is already invalid as it will be 11 with ourself + // the same is valid with groups count <= 1 + + if (groupMembers.length <= 1) { + window.pushToast({ + title: window.i18n('pickClosedGroupMember'), + type: 'error', + id: 'pickClosedGroupMember', + }); + + return; + } else if (groupMembers.length >= window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT) { window.pushToast({ - title: window.i18n( - 'invalidGroupSize', - window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT - ), + title: window.i18n('closedGroupMaxSize'), type: 'error', - id: 'invalidGroupSize', + id: 'closedGroupMaxSize', }); return; diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index ac790ff00..52371b0e6 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -364,7 +364,7 @@ export class LeftPaneMessageSection extends React.Component { private renderBottomButtons(): JSX.Element { const edit = window.i18n('edit'); const joinOpenGroup = window.i18n('joinOpenGroup'); - const createClosedGroup = window.i18n('createClosedGroup'); + const newClosedGroup = window.i18n('newClosedGroup'); const showEditButton = false; return ( @@ -386,7 +386,7 @@ export class LeftPaneMessageSection extends React.Component { }} /> { @@ -447,15 +447,10 @@ export class LeftPaneMessageSection extends React.Component { return; } - // Server URL entered? - if (serverUrl.length === 0) { - return; - } - // Server URL valid? - if (!OpenGroup.validate(serverUrl)) { + if (serverUrl.length === 0 || !OpenGroup.validate(serverUrl)) { window.pushToast({ - title: window.i18n('noServerURL'), + title: window.i18n('invalidOpenGroupUrl'), id: 'connectToServer', type: 'error', }); diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx index 28aafe99c..35d6813a3 100644 --- a/ts/components/session/SessionClosableOverlay.tsx +++ b/ts/components/session/SessionClosableOverlay.tsx @@ -145,15 +145,15 @@ export class SessionClosableOverlay extends React.Component { break; case 'open-group': title = window.i18n('joinOpenGroup'); - buttonText = window.i18n('joinOpenGroup'); - descriptionLong = window.i18n('addChannelDescription'); - subtitle = window.i18n('enterOpenGroupURL'); - placeholder = window.i18n('channelUrlPlaceholder'); + buttonText = window.i18n('next'); + // descriptionLong = ''; + subtitle = window.i18n('openGroupURL'); + placeholder = window.i18n('enterAnOpenGroupURL'); break; case 'closed-group': title = window.i18n('newClosedGroup'); - buttonText = window.i18n('createClosedGroup'); - descriptionLong = window.i18n('createClosedGroupDescription'); + buttonText = window.i18n('done'); + descriptionLong = window.i18n('newClosedGroupDescription'); subtitle = window.i18n('createClosedGroupNamePrompt'); placeholder = window.i18n('createClosedGroupPlaceholder'); break; @@ -232,7 +232,9 @@ export class SessionClosableOverlay extends React.Component { )} -
{descriptionLong}
+ {descriptionLong && ( +
{descriptionLong}
+ )} {isMessageView &&

{window.i18n('or')}

} {isMessageView && ( @@ -272,7 +274,7 @@ export class SessionClosableOverlay extends React.Component { 'sender-keys-description' )} > - {window.i18n('useSenderKeys')} + Use Sender Keys )} diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index cd956000f..e9f859cf3 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -103,7 +103,7 @@ export class SettingsView extends React.Component { if (category === SessionSettingCategory.Devices) { // special case for linked devices settings = this.getLinkedDeviceSettings(); - } else if(category === SessionSettingCategory.Blocked) { + } else if (category === SessionSettingCategory.Blocked) { // special case for blocked user settings = this.getBlockedUserSettings(); } else { @@ -600,16 +600,15 @@ export class SettingsView extends React.Component { const blockedNumbers = BlockedNumberController.getBlockedNumbers(); for (const blockedNumber of blockedNumbers) { - let displayName = `User (...${blockedNumber.substr(-6)})`; const currentModel = window.ConversationController.get(blockedNumber); if ( - currentModel && - currentModel.attributes.profile && + currentModel && + currentModel.attributes.profile && currentModel.attributes.profile.displayName ) { - displayName = currentModel.attributes.profile.displayName + displayName = currentModel.attributes.profile.displayName; } results.push({ @@ -624,7 +623,7 @@ export class SettingsView extends React.Component { }, comparisonValue: undefined, setFn: async () => { - await BlockedNumberController.unblock(blockedNumber) + await BlockedNumberController.unblock(blockedNumber); }, hidden: false, onClick: undefined,