From c020eddef60fb70f1c04dc033428abcf9204e252 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 13 Jul 2020 15:57:53 +1000 Subject: [PATCH] constants-to-ts --- _locales/en/messages.json | 14 +++--- libtextsecure/outgoing_message.js | 10 ++-- preload.js | 44 ----------------- stylesheets/_conversation.scss | 8 +--- stylesheets/_session.scss | 14 ------ stylesheets/_session_left_pane.scss | 4 -- .../session/SessionClosableOverlay.tsx | 1 - ts/components/session/SessionIdEditable.tsx | 6 +-- .../session/settings/SessionSettings.tsx | 12 ++--- ts/session/constants.ts | 13 +++++ ts/session/index.ts | 3 +- .../outgoing/content/ContentMessage.ts | 4 +- .../outgoing/content/EndSessionMessage.ts | 3 +- .../content/SessionEstablishedMessage.ts | 3 +- .../outgoing/content/SessionRequestMessage.ts | 8 +++- .../outgoing/content/TypingMessage.ts | 4 +- .../content/data/DeviceUnlinkMessage.ts | 3 +- .../content/link/DeviceLinkRequestMessage.ts | 3 +- ts/session/protocols/SessionProtocol.ts | 2 +- ts/session/utils/Number.ts | 47 +++++++++++++++++++ ts/session/utils/index.ts | 2 + .../session/protocols/SessionProtocol_test.ts | 6 +-- ts/test/session/sending/MessageSender_test.ts | 1 - ts/window.d.ts | 1 - 24 files changed, 105 insertions(+), 111 deletions(-) create mode 100644 ts/session/constants.ts create mode 100644 ts/session/utils/Number.ts diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e47117dd9..7fc3b92b3 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -878,7 +878,7 @@ "message": "Waiting for device to register..." }, "pairNewDevicePrompt": { - "message": "Scan the QR Code on your other device" + "message": "Scan the QR Code on your secondary device" }, "pairedDevices": { "message": "Linked Devices" @@ -2240,7 +2240,7 @@ "message": "Remove" }, "invalidHexId": { - "message": "Invalid Session ID", + "message": "Invalid Session ID or LNS Name", "description": "Error string shown when user types an invalid pubkey hex string" }, "invalidLnsFormat": { @@ -2360,7 +2360,7 @@ "message": "Say hello to your Session ID" }, "allUsersAreRandomly...": { - "message": "Your Session ID is the unique address people can use to contact you on Session. With no connection to your real identity, your Session ID is totally anonymous and private by design." + "message": "Your Session ID is the unique address people can use to contact you on Session. Your Session ID is totally private, anonymous, and has no connection to your real identity." }, "getStarted": { "message": "Get started" @@ -2409,7 +2409,7 @@ "message": "Enter your Session ID below to link this device to your Session ID." }, "enterSessionIDHere": { - "message": "Enter your Session ID" + "message": "Enter your Session ID here" }, "continueYourSession": { "message": "Continue Your Session" @@ -2460,7 +2460,7 @@ "message": "Enter Session ID" }, "pasteSessionIDRecipient": { - "message": "Enter a Session ID" + "message": "Enter a Session ID or LNS name" }, "usersCanShareTheir...": { "message": "Users can share their Session ID from their account settings, or by sharing their QR code." @@ -2604,10 +2604,10 @@ "message": "Secret words" }, "pairingDevice": { - "message": "Linking Device" + "message": "Pairing Device" }, "gotPairingRequest": { - "message": "Linking request received" + "message": "Pairing request received" }, "devicePairedSuccessfully": { "message": "Device linked successfully" diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index 0ad7e73cc..0dd3ed43a 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -14,14 +14,14 @@ const NUM_SEND_CONNECTIONS = 3; const getTTLForType = type => { switch (type) { - case 'pairing-request': - return window.CONSTANTS.TTL_DEFAULT_PAIRING_REQUEST; case 'device-unpairing': - return window.CONSTANTS.TTL_DEFAULT_DEVICE_UNPAIRING; + return 4 * 24 * 60 * 60 * 1000; // 4 days for device unpairing case 'onlineBroadcast': - return window.CONSTANTS.TTL_DEFAULT_ONLINE_BROADCAST; + return 60 * 1000; // 1 minute for online broadcast message + case 'pairing-request': + return 2 * 60 * 1000; // 2 minutes for pairing requests default: - return window.CONSTANTS.TTL_DEFAULT_REGULAR_MESSAGE; + return 24 * 60 * 60 * 1000; // 1 day default for any other message } }; diff --git a/preload.js b/preload.js index db2fb75a6..0a45db23f 100644 --- a/preload.js +++ b/preload.js @@ -75,44 +75,6 @@ window.isBeforeVersion = (toCheck, baseVersion) => { } }; -window.timeAsMs = (value, unit) => { - // Converts a time to milliseconds - // Valid units: second, minute, hour, day - const unitAsSingular = unit.replace(new RegExp('s?$'), ''); - - switch (unitAsSingular) { - case 'second': - return value * 1000; - case 'minute': - return value * 60 * 1000; - case 'hour': - return value * 60 * 60 * 1000; - case 'day': - return value * 24 * 60 * 60 * 1000; - default: - return value; - } -}; - -window.msAsUnit = (value, unit) => { - // Converts milliseconds to your preferred unit - // Valid units: second(s), minute(s), hour(s), day(s) - const unitAsSingular = unit.replace(new RegExp('s?$'), ''); - - switch (unitAsSingular) { - case 'second': - return value / 1000; - case 'minute': - return value / 60 / 1000; - case 'hour': - return value / 60 / 60 / 1000; - case 'day': - return value / 24 / 60 / 60 / 1000; - default: - return value; - } -}; - // eslint-disable-next-line func-names window.CONSTANTS = new (function() { this.MAX_LOGIN_TRIES = 3; @@ -129,12 +91,6 @@ window.CONSTANTS = new (function() { this.NOTIFICATION_ENABLE_TIMEOUT_SECONDS = 10; this.SESSION_ID_LENGTH = 66; - // TTL Defaults - this.TTL_DEFAULT_PAIRING_REQUEST = window.timeAsMs(2, 'minutes'); - this.TTL_DEFAULT_DEVICE_UNPAIRING = window.timeAsMs(4, 'days'); - this.TTL_DEFAULT_ONLINE_BROADCAST = window.timeAsMs(1, 'minute'); - this.TTL_DEFAULT_REGULAR_MESSAGE = window.timeAsMs(2, 'days'); - // Loki Name System (LNS) this.LNS_DEFAULT_LOOKUP_TIMEOUT = 6000; // Minimum nodes version for LNS lookup diff --git a/stylesheets/_conversation.scss b/stylesheets/_conversation.scss index 1aaf0643f..6b0e38c39 100644 --- a/stylesheets/_conversation.scss +++ b/stylesheets/_conversation.scss @@ -5,6 +5,7 @@ .panel, .panel-wrapper { + height: calc(100% - #{$header-height}); overflow-y: scroll; } @@ -21,16 +22,9 @@ .panel-wrapper { display: flex; flex-direction: column; - flex-grow: 1; overflow: initial; } - .conversation-content-left { - display: flex; - flex-direction: column; - flex-grow: 1; - } - .main.panel { .discussion-container { flex-grow: 1; diff --git a/stylesheets/_session.scss b/stylesheets/_session.scss index e92145d17..79fcac46e 100644 --- a/stylesheets/_session.scss +++ b/stylesheets/_session.scss @@ -1350,16 +1350,6 @@ label { overflow: hidden; user-select: all; overflow-y: auto; - padding: 0px 5px 20px 5px; - - &.session-id-editable-textarea:placeholder-shown { - padding: 20px 5px 0px 5px; - } - - &.group-id-editable-textarea { - margin-top: 15px; - white-space: nowrap; - } } input { @@ -1604,10 +1594,6 @@ input { } } .create-group-name-input { - display: flex; - justify-content: center; - width: 100%; - .session-id-editable { height: 60px !important; diff --git a/stylesheets/_session_left_pane.scss b/stylesheets/_session_left_pane.scss index a5ed85e82..b45426787 100644 --- a/stylesheets/_session_left_pane.scss +++ b/stylesheets/_session_left_pane.scss @@ -238,11 +238,9 @@ $session-compose-margin: 20px; box-shadow: 0 0 100px 0 rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; - flex-grow: 1; align-items: center; overflow-y: auto; overflow-x: hidden; - .session-icon .exit { padding: 13px; } @@ -309,8 +307,6 @@ $session-compose-margin: 20px; } .session-id-editable { - width: 90%; - textarea::-webkit-inner-spin-button { margin: 0px 20px; width: -webkit-fill-available; diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx index 749143d7e..a6ca82b3e 100644 --- a/ts/components/session/SessionClosableOverlay.tsx +++ b/ts/components/session/SessionClosableOverlay.tsx @@ -196,7 +196,6 @@ export class SessionClosableOverlay extends React.Component { editable={!noContactsForClosedGroup} placeholder={placeholder} value={groupName} - isGroup={true} maxLength={window.CONSTANTS.MAX_GROUPNAME_LENGTH} onChange={this.onGroupNameChanged} onPressEnter={() => onButtonClick(groupName, selectedMembers)} diff --git a/ts/components/session/SessionIdEditable.tsx b/ts/components/session/SessionIdEditable.tsx index e2a6cd134..e2d43024c 100644 --- a/ts/components/session/SessionIdEditable.tsx +++ b/ts/components/session/SessionIdEditable.tsx @@ -9,7 +9,6 @@ interface Props { onChange?: any; onPressEnter?: any; maxLength?: number; - isGroup?: boolean; } export class SessionIdEditable extends React.PureComponent { @@ -29,7 +28,7 @@ export class SessionIdEditable extends React.PureComponent { } public render() { - const { placeholder, editable, text, value, maxLength, isGroup } = this.props; + const { placeholder, editable, text, value, maxLength } = this.props; return (
{ )} >