diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e8ab82436..bacb6883e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1006,6 +1006,9 @@ "noPairedDevices": { "message": "No paired devices" }, + "deviceIsSecondaryNoPairing": { + "message": "This device is a secondary device and so cannot be paired." + }, "allowPairing": { "message": "Allow Pairing" }, diff --git a/ts/components/MainViewController.tsx b/ts/components/MainViewController.tsx index 2641081fa..65a906407 100644 --- a/ts/components/MainViewController.tsx +++ b/ts/components/MainViewController.tsx @@ -14,9 +14,13 @@ export const MainViewController = { }, renderSettingsView: (category: SessionSettingCategory) => { + // tslint:disable-next-line: no-backbone-get-set-outside-model + const isSecondaryDevice = !!window.textsecure.storage.get( + 'isSecondaryDevice' + ); if (document.getElementById('main-view')) { ReactDOM.render( - , + , document.getElementById('main-view') ); } diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 01ab4dd16..8380bc4ad 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -27,6 +27,7 @@ export enum SessionSettingType { export interface SettingsViewProps { category: SessionSettingCategory; + isSecondaryDevice: boolean; } interface State { @@ -221,7 +222,7 @@ export class SettingsView extends React.Component { } public render() { - const { category } = this.props; + const { category, isSecondaryDevice } = this.props; const shouldRenderPasswordLock = this.state.shouldLockSettings && this.state.hasPassword; @@ -230,6 +231,7 @@ export class SettingsView extends React.Component {
@@ -574,6 +576,11 @@ export class SettingsView extends React.Component { private getLinkedDeviceSettings(): Array { const { linkedPubKeys } = this.state; + const { isSecondaryDevice } = this.props; + // tslint:disable-next-line: no-backbone-get-set-outside-model + const noPairedDeviceText = isSecondaryDevice + ? window.i18n('deviceIsSecondaryNoPairing') + : window.i18n('noPairedDevices'); if (linkedPubKeys && linkedPubKeys.length > 0) { return linkedPubKeys.map((pubkey: any) => { @@ -621,7 +628,7 @@ export class SettingsView extends React.Component { return [ { id: 'no-linked-device', - title: window.i18n('noPairedDevices'), + title: noPairedDeviceText, type: undefined, description: '', category: SessionSettingCategory.Devices, diff --git a/ts/components/session/settings/SessionSettingsHeader.tsx b/ts/components/session/settings/SessionSettingsHeader.tsx index b5dc93df0..453573f44 100644 --- a/ts/components/session/settings/SessionSettingsHeader.tsx +++ b/ts/components/session/settings/SessionSettingsHeader.tsx @@ -6,19 +6,18 @@ import { SessionButton } from '../SessionButton'; interface Props extends SettingsViewProps { showLinkDeviceButton: boolean | null; - disableLinkDeviceButton: boolean | null; + isSecondaryDevice: boolean; } export class SettingsHeader extends React.Component { public static defaultProps = { showLinkDeviceButton: false, - disableLinkDeviceButton: true, }; public constructor(props: any) { super(props); this.state = { - disableLinkDeviceButton: this.props.disableLinkDeviceButton, + disableLinkDeviceButton: true, }; this.showAddLinkedDeviceModal = this.showAddLinkedDeviceModal.bind(this); } @@ -32,10 +31,12 @@ export class SettingsHeader extends React.Component { } public componentDidMount() { - window.Whisper.events.on('refreshLinkedDeviceList', async () => { + if (!this.props.isSecondaryDevice) { + window.Whisper.events.on('refreshLinkedDeviceList', async () => { + this.refreshLinkedDevice(); + }); this.refreshLinkedDevice(); - }); - this.refreshLinkedDevice(); + } } public refreshLinkedDevice() { @@ -51,7 +52,9 @@ export class SettingsHeader extends React.Component { } public componentWillUnmount() { - window.Whisper.events.off('refreshLinkedDeviceList'); + if (!this.props.isSecondaryDevice) { + window.Whisper.events.off('refreshLinkedDeviceList'); + } } public render() {