Merge branch 'clearnet' of https://github.com/loki-project/session-desktop into linked-devs-fixes

pull/1109/head
Vincent 5 years ago
commit 72c5db52aa

@ -1035,6 +1035,15 @@
"unpairDevice": { "unpairDevice": {
"message": "Unlink Device" "message": "Unlink Device"
}, },
"unpairDeviceWarning": {
"message": "Are you sure you want to unlink this device?",
"description": "Warning for device unlinking in settings view"
},
"unpairDeviceWarningSub": {
"message":
"Unlinking this device will delete all history, including all messages, sessions, and contacts from this device.",
"description": "Warning description for device unlinking in settings view"
},
"deviceUnpaired": { "deviceUnpaired": {
"message": "Device Unlinked" "message": "Device Unlinked"
}, },

@ -2750,16 +2750,9 @@ async function removeAll() {
db.serialize(() => { db.serialize(() => {
promise = Promise.all([ promise = Promise.all([
db.run('BEGIN TRANSACTION;'), db.run('BEGIN TRANSACTION;'),
...getRemoveConfigurationPromises(),
db.run('DELETE FROM conversations;'), db.run('DELETE FROM conversations;'),
db.run('DELETE FROM identityKeys;'),
db.run('DELETE FROM items;'),
db.run('DELETE FROM messages;'), db.run('DELETE FROM messages;'),
db.run('DELETE FROM preKeys;'),
db.run('DELETE FROM sessions;'),
db.run('DELETE FROM signedPreKeys;'),
db.run('DELETE FROM unprocessed;'),
db.run('DELETE FROM contactPreKeys;'),
db.run('DELETE FROM contactSignedPreKeys;'),
db.run('DELETE FROM attachment_downloads;'), db.run('DELETE FROM attachment_downloads;'),
db.run('DELETE FROM messages_fts;'), db.run('DELETE FROM messages_fts;'),
db.run('COMMIT TRANSACTION;'), db.run('COMMIT TRANSACTION;'),
@ -2769,13 +2762,8 @@ async function removeAll() {
await promise; await promise;
} }
// Anything that isn't user-visible data function getRemoveConfigurationPromises() {
async function removeAllConfiguration() { return [
let promise;
db.serialize(() => {
promise = Promise.all([
db.run('BEGIN TRANSACTION;'),
db.run('DELETE FROM identityKeys;'), db.run('DELETE FROM identityKeys;'),
db.run('DELETE FROM items;'), db.run('DELETE FROM items;'),
db.run('DELETE FROM preKeys;'), db.run('DELETE FROM preKeys;'),
@ -2784,6 +2772,20 @@ async function removeAllConfiguration() {
db.run('DELETE FROM unprocessed;'), db.run('DELETE FROM unprocessed;'),
db.run('DELETE FROM contactPreKeys;'), db.run('DELETE FROM contactPreKeys;'),
db.run('DELETE FROM contactSignedPreKeys;'), db.run('DELETE FROM contactSignedPreKeys;'),
db.run('DELETE FROM servers;'),
db.run('DELETE FROM lastHashes;'),
db.run('DELETE FROM seenMessages;'),
];
}
// Anything that isn't user-visible data
async function removeAllConfiguration() {
let promise;
db.serialize(() => {
promise = Promise.all([
db.run('BEGIN TRANSACTION;'),
...getRemoveConfigurationPromises(),
db.run('COMMIT TRANSACTION;'), db.run('COMMIT TRANSACTION;'),
]); ]);
}); });

@ -302,7 +302,8 @@ OutgoingMessage.prototype = {
let thisDeviceMessageType = this.messageType; let thisDeviceMessageType = this.messageType;
if ( if (
thisDeviceMessageType !== 'pairing-request' && thisDeviceMessageType !== 'pairing-request' &&
thisDeviceMessageType !== 'friend-request' thisDeviceMessageType !== 'friend-request' &&
thisDeviceMessageType !== 'onlineBroadcast'
) { ) {
try { try {
const conversation = ConversationController.get(devicePubKey); const conversation = ConversationController.get(devicePubKey);

@ -295,19 +295,21 @@ textarea {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-family: $session-font-accent; font-family: $session-font-default;
border-radius: 50%; border-radius: 50%;
font-weight: 700; font-weight: 700;
background: $session-color-danger; background: $session-color-danger;
color: $session-color-white; color: $session-color-white;
text-align: center; text-align: center;
span { div {
position: relative; position: relative;
sup { sup {
font-size: 130%;
position: absolute; position: absolute;
font-size: 1.3em;
top: -0.5em;
margin-left: -0.125em;
} }
} }
@ -693,7 +695,8 @@ label {
font-size: $session-font-md; font-size: $session-font-md;
} }
&-sub-message { &-sub-message {
margin-top: 5px; text-align: center;
margin-top: 20px;
} }
} }
@ -1385,10 +1388,6 @@ input {
opacity: 0.8; opacity: 0.8;
margin-bottom: $session-margin-xs; margin-bottom: $session-margin-xs;
} }
.session-confirm-sub-message {
text-align: center;
}
} }
} }

@ -172,7 +172,9 @@ export class LeftPane extends React.Component<Props, State> {
} }
private renderSettingSection() { private renderSettingSection() {
return <LeftPaneSettingSection />; const { isSecondaryDevice } = this.props;
return <LeftPaneSettingSection isSecondaryDevice={isSecondaryDevice} />;
} }
private renderChannelSection() { private renderChannelSection() {

@ -15,12 +15,16 @@ import { SessionIcon, SessionIconSize, SessionIconType } from './icon';
import { SessionSearchInput } from './SessionSearchInput'; import { SessionSearchInput } from './SessionSearchInput';
import { SessionSettingCategory } from './settings/SessionSettings'; import { SessionSettingCategory } from './settings/SessionSettings';
interface Props {
isSecondaryDevice: boolean;
}
export interface State { export interface State {
settingCategory: SessionSettingCategory; settingCategory: SessionSettingCategory;
searchQuery: string; searchQuery: string;
} }
export class LeftPaneSettingSection extends React.Component<any, State> { export class LeftPaneSettingSection extends React.Component<Props, State> {
public constructor(props: any) { public constructor(props: any) {
super(props); super(props);
@ -30,6 +34,7 @@ export class LeftPaneSettingSection extends React.Component<any, State> {
}; };
this.setCategory = this.setCategory.bind(this); this.setCategory = this.setCategory.bind(this);
this.onDeleteAccount = this.onDeleteAccount.bind(this);
} }
public componentDidMount() { public componentDidMount() {
@ -140,41 +145,61 @@ export class LeftPaneSettingSection extends React.Component<any, State> {
); );
} }
public renderBottomButtons(): JSX.Element { public renderBottomButtons(): JSX.Element | undefined {
const deleteAccount = window.i18n('deleteAccount'); const { isSecondaryDevice } = this.props;
const dangerButtonText = isSecondaryDevice
? window.i18n('unpairDevice')
: window.i18n('deleteAccount');
const showSeed = window.i18n('showSeed'); const showSeed = window.i18n('showSeed');
return ( return (
<div className="left-pane-setting-bottom-buttons"> <div className="left-pane-setting-bottom-buttons">
<SessionButton <SessionButton
text={deleteAccount} text={dangerButtonText}
buttonType={SessionButtonType.SquareOutline} buttonType={SessionButtonType.SquareOutline}
buttonColor={SessionButtonColor.Danger} buttonColor={SessionButtonColor.Danger}
onClick={this.onDeleteAccount} onClick={this.onDeleteAccount}
/> />
{!isSecondaryDevice && (
<SessionButton <SessionButton
text={showSeed} text={showSeed}
buttonType={SessionButtonType.SquareOutline} buttonType={SessionButtonType.SquareOutline}
buttonColor={SessionButtonColor.White} buttonColor={SessionButtonColor.White}
onClick={window.showSeedDialog} onClick={window.showSeedDialog}
/> />
)}
</div> </div>
); );
} }
public onDeleteAccount() { public onDeleteAccount() {
const params = { const { isSecondaryDevice } = this.props;
title: window.i18n('deleteAccount'),
message: window.i18n('deleteAccountWarning'), const title = window.i18n(
messageSub: window.i18n('deleteAccountWarningSub'), isSecondaryDevice ? 'unpairDevice' : 'deleteAccount'
);
const message = window.i18n(
isSecondaryDevice ? 'unpairDeviceWarning' : 'deleteAccountWarning'
);
const messageSub = window.i18n(
isSecondaryDevice ? 'unpairDeviceWarningSub' : 'deleteAccountWarningSub'
);
window.confirmationDialog({
title,
message,
messageSub,
resolve: window.deleteAccount, resolve: window.deleteAccount,
okTheme: 'danger', okTheme: 'danger',
}; });
window.confirmationDialog(params);
} }
public getCategories() { public getCategories() {
const { isSecondaryDevice } = this.props;
return [ return [
{ {
id: SessionSettingCategory.Appearance, id: SessionSettingCategory.Appearance,
@ -199,6 +224,7 @@ export class LeftPaneSettingSection extends React.Component<any, State> {
{ {
id: SessionSettingCategory.Devices, id: SessionSettingCategory.Devices,
title: window.i18n('devicesSettingsTitle'), title: window.i18n('devicesSettingsTitle'),
hidden: isSecondaryDevice,
}, },
]; ];
} }

@ -713,13 +713,8 @@ export class RegistrationTabs extends React.Component<{}, State> {
} }
private async resetRegistration() { private async resetRegistration() {
await window.Signal.Data.removeAllIdentityKeys(); await window.Signal.Data.removeAll();
await window.Signal.Data.removeAllPrivateConversations(); await window.storage.fetch();
window.Whisper.Registration.remove();
// Do not remove all items since they are only set
// at startup.
window.textsecure.storage.remove('identityKey');
window.textsecure.storage.remove('secondaryDeviceStatus');
window.ConversationController.reset(); window.ConversationController.reset();
await window.ConversationController.load(); await window.ConversationController.load();
window.Whisper.RotateSignedPreKeyListener.stop(window.Whisper.events); window.Whisper.RotateSignedPreKeyListener.stop(window.Whisper.events);

@ -30,28 +30,24 @@ export class SessionNotificationCount extends React.Component<Props> {
const MAX_SINGLE_DIGIT = 9; const MAX_SINGLE_DIGIT = 9;
const overflow = typeof count === 'number' && count > MAX_SINGLE_DIGIT; const overflow = typeof count === 'number' && count > MAX_SINGLE_DIGIT;
const fontSizeVal = overflow ? size / 2 : size / 2 + 2;
const fontSize = `${fontSizeVal}px`;
const bubbleStyle = { const bubbleStyle = {
width: `${size}px`, width: `${size}px`,
height: `${size}px`, height: `${size}px`,
fontSize: `${size}px`,
}; };
const fontSize = overflow ? '0.5em' : '0.6em';
const countStyle = { const countStyle = {
fontSize, fontSize,
marginTop: overflow ? `${size / 8}px` : '0px', marginTop: overflow ? '0.35em' : '0em',
marginLeft: overflow ? `-${size / 4}px` : '0px', marginLeft: overflow ? '-0.45em' : '0em',
};
const supStyle = {
top: `-${size * (3 / 8)}px`,
}; };
const countElement: JSX.Element = overflow ? ( const countElement: JSX.Element = overflow ? (
<> <>
{MAX_SINGLE_DIGIT} {MAX_SINGLE_DIGIT}
<sup style={supStyle}>+</sup> <sup>+</sup>
</> </>
) : ( ) : (
<>{count}</> <>{count}</>
@ -68,7 +64,7 @@ export class SessionNotificationCount extends React.Component<Props> {
style={bubbleStyle} style={bubbleStyle}
role="button" role="button"
> >
<span style={countStyle}>{countElement}</span> <div style={countStyle}>{countElement}</div>
</div> </div>
)} )}
</> </>

Loading…
Cancel
Save