2019-01-24 07:36:42 +03:00
|
|
|
/*
|
|
|
|
Copyright 2019 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
2019-02-22 20:47:18 +03:00
|
|
|
import {_t} from "../../../../../languageHandler";
|
|
|
|
import {SettingLevel} from "../../../../../settings/SettingsStore";
|
|
|
|
import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch";
|
|
|
|
import SettingsStore from "../../../../../settings/SettingsStore";
|
|
|
|
import Field from "../../../elements/Field";
|
|
|
|
const sdk = require("../../../../..");
|
|
|
|
const PlatformPeg = require("../../../../../PlatformPeg");
|
|
|
|
|
|
|
|
export default class PreferencesUserSettingsTab extends React.Component {
|
2019-01-24 07:36:42 +03:00
|
|
|
static COMPOSER_SETTINGS = [
|
|
|
|
'MessageComposerInput.autoReplaceEmoji',
|
2019-01-25 06:57:40 +03:00
|
|
|
'MessageComposerInput.suggestEmoji',
|
|
|
|
'sendTypingNotifications',
|
2019-01-24 07:36:42 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
static TIMELINE_SETTINGS = [
|
|
|
|
'autoplayGifsAndVideos',
|
|
|
|
'urlPreviewsEnabled',
|
2019-01-25 06:57:40 +03:00
|
|
|
'TextualBody.enableBigEmoji',
|
|
|
|
'showReadReceipts',
|
2019-01-24 07:36:42 +03:00
|
|
|
'showTwelveHourTimestamps',
|
|
|
|
'alwaysShowTimestamps',
|
2019-01-25 06:57:40 +03:00
|
|
|
'showRedactions',
|
2019-01-24 07:36:42 +03:00
|
|
|
'enableSyntaxHighlightLanguageDetection',
|
2019-01-25 06:57:40 +03:00
|
|
|
'showJoinLeaves',
|
|
|
|
'showAvatarChanges',
|
|
|
|
'showDisplaynameChanges',
|
2019-01-24 07:36:42 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
static ADVANCED_SETTINGS = [
|
|
|
|
'alwaysShowEncryptionIcons',
|
2019-01-25 06:57:40 +03:00
|
|
|
'Pill.shouldShowPillAvatar',
|
|
|
|
'TagPanel.enableTagPanel',
|
2019-01-24 07:36:42 +03:00
|
|
|
'promptBeforeInviteUnknownUsers',
|
|
|
|
// Start automatically after startup (electron-only)
|
|
|
|
// Autocomplete delay (niche text box)
|
|
|
|
];
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
autoLaunch: false,
|
|
|
|
autoLaunchSupported: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async componentWillMount(): void {
|
|
|
|
const autoLaunchSupported = await PlatformPeg.get().supportsAutoLaunch();
|
|
|
|
let autoLaunch = false;
|
|
|
|
|
|
|
|
if (autoLaunchSupported) {
|
|
|
|
autoLaunch = await PlatformPeg.get().getAutoLaunchEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({autoLaunch, autoLaunchSupported});
|
|
|
|
}
|
|
|
|
|
|
|
|
_onAutoLaunchChange = (checked) => {
|
|
|
|
PlatformPeg.get().setAutoLaunchEnabled(checked).then(() => this.setState({autoLaunch: checked}));
|
|
|
|
};
|
|
|
|
|
|
|
|
_onAutocompleteDelayChange = (e) => {
|
|
|
|
SettingsStore.setValue("autocompleteDelay", null, SettingLevel.DEVICE, e.target.value);
|
|
|
|
};
|
|
|
|
|
|
|
|
_renderGroup(settingIds) {
|
|
|
|
const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag");
|
|
|
|
return settingIds.map(i => <SettingsFlag key={i} name={i} level={SettingLevel.ACCOUNT} />);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let autoLaunchOption = null;
|
|
|
|
if (this.state.autoLaunchSupported) {
|
|
|
|
autoLaunchOption = <LabelledToggleSwitch value={this.state.autoLaunch}
|
|
|
|
onChange={this._onAutoLaunchChange}
|
|
|
|
label={_t('Start automatically after system login')} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2019-02-22 20:47:18 +03:00
|
|
|
<div className="mx_SettingsTab mx_PreferencesUserSettingsTab">
|
2019-01-24 07:36:42 +03:00
|
|
|
<div className="mx_SettingsTab_heading">{_t("Preferences")}</div>
|
|
|
|
<div className="mx_SettingsTab_section">
|
|
|
|
<span className="mx_SettingsTab_subheading">{_t("Composer")}</span>
|
2019-02-22 20:47:18 +03:00
|
|
|
{this._renderGroup(PreferencesUserSettingsTab.COMPOSER_SETTINGS)}
|
2019-01-24 07:36:42 +03:00
|
|
|
|
|
|
|
<span className="mx_SettingsTab_subheading">{_t("Timeline")}</span>
|
2019-02-22 20:47:18 +03:00
|
|
|
{this._renderGroup(PreferencesUserSettingsTab.TIMELINE_SETTINGS)}
|
2019-01-24 07:36:42 +03:00
|
|
|
|
|
|
|
<span className="mx_SettingsTab_subheading">{_t("Advanced")}</span>
|
2019-02-22 20:47:18 +03:00
|
|
|
{this._renderGroup(PreferencesUserSettingsTab.ADVANCED_SETTINGS)}
|
2019-01-24 07:36:42 +03:00
|
|
|
{autoLaunchOption}
|
|
|
|
<Field id={"autocompleteDelay"} label={_t('Autocomplete delay (ms)')} type='number'
|
|
|
|
value={SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay')}
|
|
|
|
onChange={this._onAutocompleteDelayChange} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|