From a853d27b2850e3294f5a9dbef3e4e34f2a1c69c7 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 28 Jul 2020 08:34:20 +1000 Subject: [PATCH 1/5] disable multi device link and show warnings placeholder --- _locales/en/messages.json | 12 ++++++++++++ ts/components/session/ActionsPanel.tsx | 13 +++++++++++++ ts/components/session/RegistrationTabs.tsx | 6 ++++-- ts/components/session/settings/SessionSettings.tsx | 2 +- .../session/settings/SessionSettingsHeader.tsx | 5 ++++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e47117dd9..ba0f26866 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1318,6 +1318,18 @@ "message": "Typing Indicators", "description": "Title of the typing indicators setting" }, + "multiDeviceDisabledTemporary": { + "message": "", + "description": "Description of why multi device is disabled" + }, + "multiDeviceDisabledTemporaryToastMessage": { + "message": "", + "description": "Description of why multi device is disabled on a toast on app start" + }, + "multiDeviceDisabledTemporaryToastDescription": { + "message": " ", + "description": "Description of why multi device is disabled on a toast on app start" + }, "messageTTL": { "message": "Message TTL", "description": "Title of the Message TTL setting" diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 2664b6ba0..05fa564b8 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -56,6 +56,19 @@ export class ActionsPanel extends React.Component { }, 'refreshAvatarCallback' ); + setTimeout( + () => + window.pushToast({ + title: window.i18n('multiDeviceDisabledTemporaryToastMessage'), + description: window.i18n( + 'multiDeviceDisabledTemporaryToastMessage' + ), + type: 'warning', + id: 'multiDeviceDisabledTemporaryToastMessage', + shouldFade: false, + }), + 4000 + ); } ); } diff --git a/ts/components/session/RegistrationTabs.tsx b/ts/components/session/RegistrationTabs.tsx index be7d733ea..f934be28c 100644 --- a/ts/components/session/RegistrationTabs.tsx +++ b/ts/components/session/RegistrationTabs.tsx @@ -558,7 +558,8 @@ export class RegistrationTabs extends React.Component<{}, State> { SessionButtonColor.Green )}

{or}

- {this.renderLinkDeviceToExistingAccountButton()} + {/* FIXME enable back to allow linking of device + this.renderLinkDeviceToExistingAccountButton() */} ); } @@ -584,7 +585,8 @@ export class RegistrationTabs extends React.Component<{}, State> {
{this.renderContinueYourSessionButton()}

{or}

- {this.renderLinkDeviceToExistingAccountButton()} + {/* FIXME enable back to allow linking of device + this.renderLinkDeviceToExistingAccountButton()*/}
); } diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 3b4076da0..f60459ea8 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -644,7 +644,7 @@ export class SettingsView extends React.Component { id: 'no-linked-device', title: noPairedDeviceText, type: undefined, - description: '', + description: window.i18n('multiDeviceDisabledTemporary'), category: SessionSettingCategory.Devices, content: {}, comparisonValue: undefined, diff --git a/ts/components/session/settings/SessionSettingsHeader.tsx b/ts/components/session/settings/SessionSettingsHeader.tsx index 21e663e96..b1e33393a 100644 --- a/ts/components/session/settings/SessionSettingsHeader.tsx +++ b/ts/components/session/settings/SessionSettingsHeader.tsx @@ -74,9 +74,12 @@ export class SettingsHeader extends React.Component { ? `${categoryTitlePrefix.slice(0, -1)} Settings` : `${categoryTitlePrefix} Settings`; const showSearch = false; - const showAddDevice = + const showAddDevice = false; + /* FIXME enable back to allow linking of device + const showAddDevice = category === SessionSettingCategory.Devices && this.props.showLinkDeviceButton; + */ return (
From abc9456d14456903f0dc4b79d9ecff813ab8a317 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 30 Jul 2020 15:01:11 +1000 Subject: [PATCH 2/5] add popup for disabling multi device --- _locales/en/messages.json | 18 ++++++----- js/views/inbox_view.js | 4 ++- stylesheets/_theme_dark.scss | 4 +-- ts/components/session/ActionsPanel.tsx | 30 ++++++++++++------- ts/components/session/RegistrationTabs.tsx | 4 +-- ts/components/session/SessionConfirm.tsx | 3 +- ts/components/session/SessionHTMLRenderer.tsx | 5 +++- 7 files changed, 43 insertions(+), 25 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index ba0f26866..0eec9ab2a 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1319,16 +1319,20 @@ "description": "Title of the typing indicators setting" }, "multiDeviceDisabledTemporary": { - "message": "", + "message": "MultiDevice disabled temporarily", "description": "Description of why multi device is disabled" }, - "multiDeviceDisabledTemporaryToastMessage": { - "message": "", - "description": "Description of why multi device is disabled on a toast on app start" + "multiDeviceDisabledTemporaryTitle": { + "message": "Changes to Multi-device", + "description": "Description of why multi device is disabled on app start" }, - "multiDeviceDisabledTemporaryToastDescription": { - "message": " ", - "description": "Description of why multi device is disabled on a toast on app start" + "multiDeviceDisabledTemporaryDescriptionPrimary": { + "message": "You’re seeing this because you have a secondary device linked to your Session ID. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality on August 6th. Device linking has been disabled, and the next update will erase existing secondary devices.

To read more about this change, visit the Session FAQ at getsession.org/faq", + "description": "Description of why multi device is disabled on app start for a primary device" + }, + "multiDeviceDisabledTemporaryDescriptionSecondary": { + "message": "You’re seeing this because this is a secondary device in a multi-device setup. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality on August 6th. Device linking has been disabled, and the next update will erase existing secondary devices.
To read more about this change, visit the Session FAQ at getsession.org/faq", + "description": "Description of why multi device is disabled on app start for a secondary device" }, "messageTTL": { "message": "Message TTL", diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 8ec8e024b..31a6bf75b 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -90,12 +90,14 @@ type: 'success', }); }, - showConfirmationDialog({ title, message, onOk, onCancel }) { + showConfirmationDialog({ title, message, messageSub, onOk, onCancel, hideCancel }) { window.confirmationDialog({ title, message, resolve: onOk, reject: onCancel, + hideCancel, + messageSub, }); }, }); diff --git a/stylesheets/_theme_dark.scss b/stylesheets/_theme_dark.scss index 36cf6d68a..aa1d61477 100644 --- a/stylesheets/_theme_dark.scss +++ b/stylesheets/_theme_dark.scss @@ -242,7 +242,7 @@ body.dark-theme { } a { - color: $blue; + color: $session-color-green; } .file-input { @@ -410,7 +410,7 @@ body.dark-theme { } } a.link { - color: #2090ea; + color: $session-color-green; } .progress { diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 05fa564b8..c53b2b7af 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { SessionIconButton, SessionIconSize, SessionIconType } from './icon'; import { Avatar } from '../Avatar'; import { PropsData as ConversationListItemPropsType } from '../ConversationListItem'; +import { MultiDeviceProtocol } from '../../session/protocols'; export enum SectionType { Profile, @@ -57,17 +58,24 @@ export class ActionsPanel extends React.Component { 'refreshAvatarCallback' ); setTimeout( - () => - window.pushToast({ - title: window.i18n('multiDeviceDisabledTemporaryToastMessage'), - description: window.i18n( - 'multiDeviceDisabledTemporaryToastMessage' - ), - type: 'warning', - id: 'multiDeviceDisabledTemporaryToastMessage', - shouldFade: false, - }), - 4000 + async () => { + const hasMultipleDevices = (await MultiDeviceProtocol.getOurDevices()).length > 1; + const primaryWithSecondary = !window.textsecure.storage.get('isSecondaryDevice') && hasMultipleDevices; + const isSecondary = !!window.textsecure.storage.get('isSecondaryDevice'); + + if (!primaryWithSecondary && !isSecondary) { + return; + } + + const opts = { + hideCancel: true, + title: window.i18n('multiDeviceDisabledTemporaryTitle'), + message: primaryWithSecondary ? window.i18n('multiDeviceDisabledTemporaryDescriptionPrimary') : window.i18n('multiDeviceDisabledTemporaryDescriptionSecondary') + , + }; + window.Whisper.events.trigger('showConfirmationDialog', opts); + }, + 1000 ); } ); diff --git a/ts/components/session/RegistrationTabs.tsx b/ts/components/session/RegistrationTabs.tsx index f934be28c..6d610e8b6 100644 --- a/ts/components/session/RegistrationTabs.tsx +++ b/ts/components/session/RegistrationTabs.tsx @@ -557,7 +557,7 @@ export class RegistrationTabs extends React.Component<{}, State> { SessionButtonType.BrandOutline, SessionButtonColor.Green )} -

{or}

+ {/*

{or}

*/} {/* FIXME enable back to allow linking of device this.renderLinkDeviceToExistingAccountButton() */}
@@ -584,7 +584,7 @@ export class RegistrationTabs extends React.Component<{}, State> { return (
{this.renderContinueYourSessionButton()} -

{or}

+ {/*

{or}

*/} {/* FIXME enable back to allow linking of device this.renderLinkDeviceToExistingAccountButton()*/}
diff --git a/ts/components/session/SessionConfirm.tsx b/ts/components/session/SessionConfirm.tsx index 859e856c8..47ea5273f 100644 --- a/ts/components/session/SessionConfirm.tsx +++ b/ts/components/session/SessionConfirm.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { SessionModal } from './SessionModal'; import { SessionButton, SessionButtonColor } from './SessionButton'; +import { SessionHtmlRenderer } from './SessionHTMLRenderer'; interface Props { message: string; @@ -61,7 +62,7 @@ export class SessionConfirm extends React.Component { {!showHeader &&
}
- {message} + {messageSub && ( {messageSub} diff --git a/ts/components/session/SessionHTMLRenderer.tsx b/ts/components/session/SessionHTMLRenderer.tsx index f7f493b7b..438213be5 100644 --- a/ts/components/session/SessionHTMLRenderer.tsx +++ b/ts/components/session/SessionHTMLRenderer.tsx @@ -5,6 +5,7 @@ interface ReceivedProps { html: string; tag?: string; key?: any; + className?: string; } // Needed because of https://github.com/microsoft/tslint-microsoft-contrib/issues/339 @@ -14,14 +15,16 @@ export const SessionHtmlRenderer: React.SFC = ({ tag = 'div', key, html, + className, }) => { const clean = DOMPurify.sanitize(html, { USE_PROFILES: { html: true }, - FORBID_ATTR: ['style', 'script'], + FORBID_ATTR: ['script'], }); return React.createElement(tag, { key, + className, dangerouslySetInnerHTML: { __html: clean }, }); }; From 761ebf4a7c3db1e60024cd9b693def914f5aedd5 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 30 Jul 2020 15:03:08 +1000 Subject: [PATCH 3/5] lint --- js/views/inbox_view.js | 9 ++++- ts/components/session/ActionsPanel.tsx | 43 ++++++++++++---------- ts/components/session/RegistrationTabs.tsx | 2 +- ts/components/session/SessionConfirm.tsx | 6 ++- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 31a6bf75b..9d702b620 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -90,7 +90,14 @@ type: 'success', }); }, - showConfirmationDialog({ title, message, messageSub, onOk, onCancel, hideCancel }) { + showConfirmationDialog({ + title, + message, + messageSub, + onOk, + onCancel, + hideCancel, + }) { window.confirmationDialog({ title, message, diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index c53b2b7af..29b299fc7 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -57,26 +57,29 @@ export class ActionsPanel extends React.Component { }, 'refreshAvatarCallback' ); - setTimeout( - async () => { - const hasMultipleDevices = (await MultiDeviceProtocol.getOurDevices()).length > 1; - const primaryWithSecondary = !window.textsecure.storage.get('isSecondaryDevice') && hasMultipleDevices; - const isSecondary = !!window.textsecure.storage.get('isSecondaryDevice'); - - if (!primaryWithSecondary && !isSecondary) { - return; - } - - const opts = { - hideCancel: true, - title: window.i18n('multiDeviceDisabledTemporaryTitle'), - message: primaryWithSecondary ? window.i18n('multiDeviceDisabledTemporaryDescriptionPrimary') : window.i18n('multiDeviceDisabledTemporaryDescriptionSecondary') - , - }; - window.Whisper.events.trigger('showConfirmationDialog', opts); - }, - 1000 - ); + setTimeout(async () => { + const hasMultipleDevices = + (await MultiDeviceProtocol.getOurDevices()).length > 1; + const primaryWithSecondary = + !window.textsecure.storage.get('isSecondaryDevice') && + hasMultipleDevices; + const isSecondary = !!window.textsecure.storage.get( + 'isSecondaryDevice' + ); + + if (!primaryWithSecondary && !isSecondary) { + return; + } + + const opts = { + hideCancel: true, + title: window.i18n('multiDeviceDisabledTemporaryTitle'), + message: primaryWithSecondary + ? window.i18n('multiDeviceDisabledTemporaryDescriptionPrimary') + : window.i18n('multiDeviceDisabledTemporaryDescriptionSecondary'), + }; + window.Whisper.events.trigger('showConfirmationDialog', opts); + }, 1000); } ); } diff --git a/ts/components/session/RegistrationTabs.tsx b/ts/components/session/RegistrationTabs.tsx index 6d610e8b6..4690a3d34 100644 --- a/ts/components/session/RegistrationTabs.tsx +++ b/ts/components/session/RegistrationTabs.tsx @@ -584,7 +584,7 @@ export class RegistrationTabs extends React.Component<{}, State> { return (
{this.renderContinueYourSessionButton()} - {/*

{or}

*/} + {/*

{or}

*/} {/* FIXME enable back to allow linking of device this.renderLinkDeviceToExistingAccountButton()*/}
diff --git a/ts/components/session/SessionConfirm.tsx b/ts/components/session/SessionConfirm.tsx index 47ea5273f..ed8914c4a 100644 --- a/ts/components/session/SessionConfirm.tsx +++ b/ts/components/session/SessionConfirm.tsx @@ -62,7 +62,11 @@ export class SessionConfirm extends React.Component { {!showHeader &&
}
- + {messageSub && ( {messageSub} From 9464c038060c83884d90cd0ba91b90a6aab4c7d6 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 30 Jul 2020 15:53:44 +1000 Subject: [PATCH 4/5] adress reviews --- _locales/en/messages.json | 4 ++-- ts/components/session/ActionsPanel.tsx | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 0eec9ab2a..3140bc0f0 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1327,11 +1327,11 @@ "description": "Description of why multi device is disabled on app start" }, "multiDeviceDisabledTemporaryDescriptionPrimary": { - "message": "You’re seeing this because you have a secondary device linked to your Session ID. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality on August 6th. Device linking has been disabled, and the next update will erase existing secondary devices.

To read more about this change, visit the Session FAQ at getsession.org/faq", + "message": "You’re seeing this because you have a secondary device linked to your Session ID. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on August 6th.

To read more about this change, visit the Session FAQ at getsession.org/faq.", "description": "Description of why multi device is disabled on app start for a primary device" }, "multiDeviceDisabledTemporaryDescriptionSecondary": { - "message": "You’re seeing this because this is a secondary device in a multi-device setup. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality on August 6th. Device linking has been disabled, and the next update will erase existing secondary devices.
To read more about this change, visit the Session FAQ at getsession.org/faq", + "message": "You’re seeing this because this is a secondary device in a multi-device setup. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on August 6th.

To read more about this change, visit the Session FAQ at getsession.org/faq.", "description": "Description of why multi device is disabled on app start for a secondary device" }, "messageTTL": { diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 29b299fc7..067abaa8d 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -3,6 +3,7 @@ import { SessionIconButton, SessionIconSize, SessionIconType } from './icon'; import { Avatar } from '../Avatar'; import { PropsData as ConversationListItemPropsType } from '../ConversationListItem'; import { MultiDeviceProtocol } from '../../session/protocols'; +import { UserUtil } from '../../util'; export enum SectionType { Profile, @@ -58,14 +59,18 @@ export class ActionsPanel extends React.Component { 'refreshAvatarCallback' ); setTimeout(async () => { + const currentDevice = await UserUtil.getCurrentDevicePubKey(); + if (!currentDevice) { + return; + } + const secondaryDevices = await MultiDeviceProtocol.getSecondaryDevices(currentDevice); + const isSecondary = secondaryDevices.find(s => s.key === currentDevice) || !!window.textsecure.storage.get('isSecondaryDevice'); + const hasMultipleDevices = (await MultiDeviceProtocol.getOurDevices()).length > 1; const primaryWithSecondary = - !window.textsecure.storage.get('isSecondaryDevice') && + !isSecondary && hasMultipleDevices; - const isSecondary = !!window.textsecure.storage.get( - 'isSecondaryDevice' - ); if (!primaryWithSecondary && !isSecondary) { return; From 471a381b4bd3f30ae276bbd90399de9e6fd5016d Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 30 Jul 2020 16:14:47 +1000 Subject: [PATCH 5/5] show disabled multi device message every 5 loads --- ts/components/session/ActionsPanel.tsx | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 067abaa8d..484a3b89f 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -4,6 +4,7 @@ import { Avatar } from '../Avatar'; import { PropsData as ConversationListItemPropsType } from '../ConversationListItem'; import { MultiDeviceProtocol } from '../../session/protocols'; import { UserUtil } from '../../util'; +import { createOrUpdateItem, getItemById } from '../../../js/modules/data'; export enum SectionType { Profile, @@ -59,18 +60,33 @@ export class ActionsPanel extends React.Component { 'refreshAvatarCallback' ); setTimeout(async () => { + const disabledMultiDeviceCountDb = await getItemById( + 'disabledMultiDeviceCount' + ); + const disabledMultiDeviceCount = + Number(disabledMultiDeviceCountDb?.value) || 0; + const data = { + id: 'disabledMultiDeviceCount', + value: String(disabledMultiDeviceCount + 1), + }; + await createOrUpdateItem(data); + if (disabledMultiDeviceCount % 5 !== 0) { + return; + } const currentDevice = await UserUtil.getCurrentDevicePubKey(); if (!currentDevice) { return; } - const secondaryDevices = await MultiDeviceProtocol.getSecondaryDevices(currentDevice); - const isSecondary = secondaryDevices.find(s => s.key === currentDevice) || !!window.textsecure.storage.get('isSecondaryDevice'); + const secondaryDevices = await MultiDeviceProtocol.getSecondaryDevices( + currentDevice + ); + const isSecondary = + secondaryDevices.find(s => s.key === currentDevice) || + !!window.textsecure.storage.get('isSecondaryDevice'); const hasMultipleDevices = (await MultiDeviceProtocol.getOurDevices()).length > 1; - const primaryWithSecondary = - !isSecondary && - hasMultipleDevices; + const primaryWithSecondary = !isSecondary && hasMultipleDevices; if (!primaryWithSecondary && !isSecondary) { return;