disnle link option on secondary device

pull/1011/head
Audric Ackermann 5 years ago
parent 21f7c8b9e6
commit c81fca5d90
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1006,6 +1006,9 @@
"noPairedDevices": { "noPairedDevices": {
"message": "No paired devices" "message": "No paired devices"
}, },
"deviceIsSecondaryNoPairing": {
"message": "This device is a secondary device and so cannot be paired."
},
"allowPairing": { "allowPairing": {
"message": "Allow Pairing" "message": "Allow Pairing"
}, },

@ -14,9 +14,13 @@ export const MainViewController = {
}, },
renderSettingsView: (category: SessionSettingCategory) => { 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')) { if (document.getElementById('main-view')) {
ReactDOM.render( ReactDOM.render(
<SettingsView category={category} />, <SettingsView category={category} isSecondaryDevice={isSecondaryDevice}/>,
document.getElementById('main-view') document.getElementById('main-view')
); );
} }

@ -27,6 +27,7 @@ export enum SessionSettingType {
export interface SettingsViewProps { export interface SettingsViewProps {
category: SessionSettingCategory; category: SessionSettingCategory;
isSecondaryDevice: boolean;
} }
interface State { interface State {
@ -221,7 +222,7 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
} }
public render() { public render() {
const { category } = this.props; const { category, isSecondaryDevice } = this.props;
const shouldRenderPasswordLock = const shouldRenderPasswordLock =
this.state.shouldLockSettings && this.state.hasPassword; this.state.shouldLockSettings && this.state.hasPassword;
@ -230,6 +231,7 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
<SettingsHeader <SettingsHeader
showLinkDeviceButton={!shouldRenderPasswordLock} showLinkDeviceButton={!shouldRenderPasswordLock}
category={category} category={category}
isSecondaryDevice={isSecondaryDevice}
/> />
<div className="session-settings-view"> <div className="session-settings-view">
@ -574,6 +576,11 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
private getLinkedDeviceSettings(): Array<LocalSettingType> { private getLinkedDeviceSettings(): Array<LocalSettingType> {
const { linkedPubKeys } = this.state; 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) { if (linkedPubKeys && linkedPubKeys.length > 0) {
return linkedPubKeys.map((pubkey: any) => { return linkedPubKeys.map((pubkey: any) => {
@ -621,7 +628,7 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
return [ return [
{ {
id: 'no-linked-device', id: 'no-linked-device',
title: window.i18n('noPairedDevices'), title: noPairedDeviceText,
type: undefined, type: undefined,
description: '', description: '',
category: SessionSettingCategory.Devices, category: SessionSettingCategory.Devices,

@ -6,19 +6,18 @@ import { SessionButton } from '../SessionButton';
interface Props extends SettingsViewProps { interface Props extends SettingsViewProps {
showLinkDeviceButton: boolean | null; showLinkDeviceButton: boolean | null;
disableLinkDeviceButton: boolean | null; isSecondaryDevice: boolean;
} }
export class SettingsHeader extends React.Component<Props, any> { export class SettingsHeader extends React.Component<Props, any> {
public static defaultProps = { public static defaultProps = {
showLinkDeviceButton: false, showLinkDeviceButton: false,
disableLinkDeviceButton: true,
}; };
public constructor(props: any) { public constructor(props: any) {
super(props); super(props);
this.state = { this.state = {
disableLinkDeviceButton: this.props.disableLinkDeviceButton, disableLinkDeviceButton: true,
}; };
this.showAddLinkedDeviceModal = this.showAddLinkedDeviceModal.bind(this); this.showAddLinkedDeviceModal = this.showAddLinkedDeviceModal.bind(this);
} }
@ -32,10 +31,12 @@ export class SettingsHeader extends React.Component<Props, any> {
} }
public componentDidMount() { public componentDidMount() {
window.Whisper.events.on('refreshLinkedDeviceList', async () => { if (!this.props.isSecondaryDevice) {
window.Whisper.events.on('refreshLinkedDeviceList', async () => {
this.refreshLinkedDevice();
});
this.refreshLinkedDevice(); this.refreshLinkedDevice();
}); }
this.refreshLinkedDevice();
} }
public refreshLinkedDevice() { public refreshLinkedDevice() {
@ -51,7 +52,9 @@ export class SettingsHeader extends React.Component<Props, any> {
} }
public componentWillUnmount() { public componentWillUnmount() {
window.Whisper.events.off('refreshLinkedDeviceList'); if (!this.props.isSecondaryDevice) {
window.Whisper.events.off('refreshLinkedDeviceList');
}
} }
public render() { public render() {

Loading…
Cancel
Save