ui polished and ttl constants

pull/1242/head
Vincent 5 years ago
parent 39dea3b1bc
commit fd746a475a

@ -878,7 +878,7 @@
"message": "Waiting for device to register..."
},
"pairNewDevicePrompt": {
"message": "Scan the QR Code on your secondary device"
"message": "Scan the QR Code on your other device"
},
"pairedDevices": {
"message": "Linked Devices"
@ -2240,7 +2240,7 @@
"message": "Remove"
},
"invalidHexId": {
"message": "Invalid Session ID or LNS Name",
"message": "Invalid Session ID",
"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. Your Session ID is totally private, anonymous, and has no connection to your real identity."
"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."
},
"getStarted": {
"message": "Get started"
@ -2460,7 +2460,7 @@
"message": "Enter Session ID"
},
"pasteSessionIDRecipient": {
"message": "Enter a Session ID or LNS name"
"message": "Enter a Session ID"
},
"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": "Pairing Device"
"message": "Linking Device"
},
"gotPairingRequest": {
"message": "Pairing request received"
"message": "Linking request received"
},
"devicePairedSuccessfully": {
"message": "Device linked successfully"

@ -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 4 * 24 * 60 * 60 * 1000; // 4 days for device unpairing
return window.CONSTANTS.TTL_DEFAULT_DEVICE_UNPAIRING;
case 'onlineBroadcast':
return 60 * 1000; // 1 minute for online broadcast message
case 'pairing-request':
return 2 * 60 * 1000; // 2 minutes for pairing requests
return window.CONSTANTS.TTL_DEFAULT_ONLINE_BROADCAST;
default:
return 24 * 60 * 60 * 1000; // 1 day default for any other message
return window.CONSTANTS.TTL_DEFAULT_REGULAR_MESSAGE;
}
};

@ -75,6 +75,44 @@ 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;
@ -91,6 +129,12 @@ 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

@ -5,7 +5,6 @@
.panel,
.panel-wrapper {
height: calc(100% - #{$header-height});
overflow-y: scroll;
}
@ -22,9 +21,16 @@
.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;

@ -441,7 +441,10 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
id: 'message-ttl',
title: window.i18n('messageTTL'),
description: window.i18n('messageTTLSettingDescription'),
hidden: false,
// TODO: Revert
// TTL set to 2 days for mobile push notification compabability
// temporary fix .t 13/07/2020
hidden: true,
type: SessionSettingType.Slider,
category: SessionSettingCategory.Privacy,
setFn: undefined,
@ -452,7 +455,10 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
step: 6,
min: 12,
max: 96,
defaultValue: 24,
defaultValue: window.msAsUnit(
window.CONSTANTS.TTL_DEFAULT_REGULAR_MESSAGE,
'hour'
),
info: (value: number) => `${value} Hours`,
},
confirmationDialogParams: undefined,

@ -1,134 +0,0 @@
// This is the (Closed | Medium) Group equivalent to the SessionGroup type.
import { PubKey } from '.';
import { UserUtil } from '../../util';
enum ClosedGroupType {
SMALL,
MEDIUM,
}
interface ClosedGroupParams {
id: PubKey;
type: ClosedGroupType;
admins: Array<PubKey>;
members: Array<PubKey>;
}
class ClosedGroup {
public readonly id: PubKey;
public readonly type: ClosedGroupType;
public admins: Array<PubKey>;
public members: Array<PubKey>;
constructor(params: ClosedGroupParams) {
this.id = params.id;
this.type = params.type;
this.admins = params.admins;
this.members = params.members;
}
public static async create(name: string, type: ClosedGroupType, members: Array<PubKey>, onSuccess: any): Promise<ClosedGroup | undefined> {
const { ConversationController, StringView, libsignal } = window;
// Manage small group size
// TODO - Eventually we want to default to MediumGroups and abandon regular groups
// once medium groups have been thoroughly tested
if (
type === ClosedGroupType.SMALL &&
members.length === 0 ||
members.length >= window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT
) {
console.warn(`ClosedGroup create: Cannot create a small group with more than ${window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT} members`);
}
const primaryDevice = UserUtil.getCurrentPrimaryDevicePubKey();
const allMembers = [primaryDevice, ...members];
// Create Group Identity
const identityKeys = await libsignal.KeyHelper.generateIdentityKeyPair();
const keypair = await libsignal.KeyHelper.generateIdentityKeyPair();
const id = StringView.arrayBufferToHex(keypair.pubKey);
// Medium groups
const senderKey = (type === ClosedGroupType.MEDIUM)
? await window.SenderKeyAPI.createSenderKeyForGroup(id, primaryDevice)
: undefined;
const secretKey = (type === ClosedGroupType.MEDIUM)
? identityKeys.privKey
: undefined;
const groupSecretKeyHex = StringView.arrayBufferToHex(
identityKeys.privKey
);
const ev = {
groupDetails: {
id,
name,
members: allMembers,
recipients: allMembers,
active: true,
expireTimer: 0,
avatar: '',
secretKey,
senderKey,
is_medium_group: type === ClosedGroupType.MEDIUM,
},
confirm: () => null,
};
await window.NewReceiver.onGroupReceived(ev);
}
public static get(id: PubKey): ClosedGroup | undefined {
// Gets a closed group from its group id
return;
}
public update(): Promise<Array<PubKey>> {
//
}
public updateMembers(): Promise<Array<PubKey>> {
// Abstraction on update
// Update the conversation and this object
}
public async removeMembers(): Promise<Array<PubKey>> {
// Abstraction on updateMembers
}
public async addMembers(): Promise<Array<PubKey>> {
// Abstraction on updateMembers
}
public async setName(): Promise<void> {
// Set or update the name of the group
}
public leave() {
// Leave group
}
// static from(groupId) {
// // Returns a new instance from a groupId if it's valid
// const groupIdAsPubKey = groupId instanceof _1.PubKey
// ? groupId
// : _1.PubKey.from(groupId);
// openGroupParams = {
// groupId:
// };
// return new SessionGroup(openGroupParams);
// }
}

@ -49,7 +49,7 @@ describe('MessageSender', () => {
[string, Uint8Array, number, number],
Promise<void>
>();
TestUtils.stubWindow('lokiMessageAPI', {
sendMessage: lokiMessageAPISendStub,
});

@ -10,15 +10,6 @@ export async function getCurrentDevicePubKey(): Promise<string | undefined> {
return item.value.split('.')[0];
}
export async function getCurrentPrimaryDevicePubKey(): Promise<string | undefined> {
const item = await getItemById('primaryDevicePubKey');
if (!item || !item.value) {
return undefined;
}
return item.value;
}
export async function getIdentityKeyPair(): Promise<KeyPair | undefined> {
const item = await getItemById('identityKey');

1
ts/window.d.ts vendored

@ -19,6 +19,7 @@ If you import anything in global.d.ts, the type system won't work correctly.
declare global {
interface Window {
CONSTANTS: any;
msAsUnit: any;
ConversationController: any;
Events: any;
Lodash: any;

Loading…
Cancel
Save