More specific type definition and adhering to code style better
This commit is contained in:
parent
3f1ca970d6
commit
d22617c422
13 changed files with 66 additions and 72 deletions
|
@ -29,7 +29,7 @@ import InfoDialog from "./InfoDialog";
|
|||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||
import {Action} from "../../../dispatcher/actions";
|
||||
import { USER_TAB } from "./UserSettingsDialog";
|
||||
import { UserTab } from "./UserSettingsDialog";
|
||||
|
||||
interface IProps extends IDialogProps {
|
||||
featureId: string;
|
||||
|
@ -70,7 +70,7 @@ const BetaFeedbackDialog: React.FC<IProps> = ({featureId, onFinished}) => {
|
|||
onFinished(false);
|
||||
defaultDispatcher.dispatch({
|
||||
action: Action.ViewUserSettings,
|
||||
initialTabId: USER_TAB.LABS,
|
||||
initialTabId: UserTab.Labs,
|
||||
});
|
||||
}}>
|
||||
{ _t("To leave the beta, visit your settings.") }
|
||||
|
|
|
@ -58,12 +58,6 @@ export default class ConfirmUserActionDialog extends React.Component<IProps> {
|
|||
askReason: false,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.reasonField = null;
|
||||
}
|
||||
|
||||
public onOk = (): void => {
|
||||
let reason;
|
||||
if (this.reasonField) {
|
||||
|
|
|
@ -115,7 +115,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
|||
this.setState({errStr: _t("There was a problem communicating with the server. Please try again.")});
|
||||
};
|
||||
|
||||
private onUIAuthComplete = (auth): void => {
|
||||
private onUIAuthComplete = (auth: any): void => {
|
||||
MatrixClientPeg.get().deactivateAccount(auth, this.state.shouldErase).then(r => {
|
||||
// Deactivation worked - logout & close this dialog
|
||||
Analytics.trackEvent('Account', 'Deactivate Account');
|
||||
|
|
|
@ -19,7 +19,7 @@ import React from 'react';
|
|||
import TabbedView, {Tab} from "../../structures/TabbedView";
|
||||
import {_t, _td} from "../../../languageHandler";
|
||||
import GeneralUserSettingsTab from "../settings/tabs/user/GeneralUserSettingsTab";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import SettingsStore, { CallbackFn } from "../../../settings/SettingsStore";
|
||||
import LabsUserSettingsTab from "../settings/tabs/user/LabsUserSettingsTab";
|
||||
import AppearanceUserSettingsTab from "../settings/tabs/user/AppearanceUserSettingsTab";
|
||||
import SecurityUserSettingsTab from "../settings/tabs/user/SecurityUserSettingsTab";
|
||||
|
@ -34,17 +34,17 @@ import MjolnirUserSettingsTab from "../settings/tabs/user/MjolnirUserSettingsTab
|
|||
import {UIFeature} from "../../../settings/UIFeature";
|
||||
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
||||
|
||||
export enum USER_TAB {
|
||||
GENERAL = "USER_GENERAL_TAB",
|
||||
APPEARANCE = "USER_APPEARANCE_TAB",
|
||||
FLAIR = "USER_FLAIR_TAB",
|
||||
NOTIFICATIONS = "USER_NOTIFICATIONS_TAB",
|
||||
PREFERENCES = "USER_PREFERENCES_TAB",
|
||||
VOICE = "USER_VOICE_TAB",
|
||||
SECURITY = "USER_SECURITY_TAB",
|
||||
LABS = "USER_LABS_TAB",
|
||||
MJOLNIR = "USER_MJOLNIR_TAB",
|
||||
HELP = "USER_HELP_TAB",
|
||||
export enum UserTab {
|
||||
General = "USER_GENERAL_TAB",
|
||||
Appearance = "USER_APPEARANCE_TAB",
|
||||
Flair = "USER_FLAIR_TAB",
|
||||
Notifications = "USER_NOTIFICATIONS_TAB",
|
||||
Preferences = "USER_PREFERENCES_TAB",
|
||||
Voice = "USER_VOICE_TAB",
|
||||
Security = "USER_SECURITY_TAB",
|
||||
Labs = "USER_LABS_TAB",
|
||||
Mjolnir = "USER_MJOLNIR_TAB",
|
||||
Help = "USER_HELP_TAB",
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
|
@ -76,7 +76,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
SettingsStore.unwatchSetting(this.mjolnirWatcher);
|
||||
}
|
||||
|
||||
private mjolnirChanged = (settingName, roomId, atLevel, newValue: boolean) => {
|
||||
private mjolnirChanged: CallbackFn = (settingName, roomId, atLevel, newValue) => {
|
||||
// We can cheat because we know what levels a feature is tracked at, and how it is tracked
|
||||
this.setState({mjolnirEnabled: newValue});
|
||||
}
|
||||
|
@ -85,33 +85,33 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
const tabs = [];
|
||||
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.GENERAL,
|
||||
UserTab.General,
|
||||
_td("General"),
|
||||
"mx_UserSettingsDialog_settingsIcon",
|
||||
<GeneralUserSettingsTab closeSettingsFn={this.props.onFinished} />,
|
||||
));
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.APPEARANCE,
|
||||
UserTab.Appearance,
|
||||
_td("Appearance"),
|
||||
"mx_UserSettingsDialog_appearanceIcon",
|
||||
<AppearanceUserSettingsTab />,
|
||||
));
|
||||
if (SettingsStore.getValue(UIFeature.Flair)) {
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.FLAIR,
|
||||
UserTab.Flair,
|
||||
_td("Flair"),
|
||||
"mx_UserSettingsDialog_flairIcon",
|
||||
<FlairUserSettingsTab />,
|
||||
));
|
||||
}
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.NOTIFICATIONS,
|
||||
UserTab.Notifications,
|
||||
_td("Notifications"),
|
||||
"mx_UserSettingsDialog_bellIcon",
|
||||
<NotificationUserSettingsTab />,
|
||||
));
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.PREFERENCES,
|
||||
UserTab.Preferences,
|
||||
_td("Preferences"),
|
||||
"mx_UserSettingsDialog_preferencesIcon",
|
||||
<PreferencesUserSettingsTab />,
|
||||
|
@ -119,7 +119,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
|
||||
if (SettingsStore.getValue(UIFeature.Voip)) {
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.VOICE,
|
||||
UserTab.Voice,
|
||||
_td("Voice & Video"),
|
||||
"mx_UserSettingsDialog_voiceIcon",
|
||||
<VoiceUserSettingsTab />,
|
||||
|
@ -127,7 +127,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
}
|
||||
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.SECURITY,
|
||||
UserTab.Security,
|
||||
_td("Security & Privacy"),
|
||||
"mx_UserSettingsDialog_securityIcon",
|
||||
<SecurityUserSettingsTab closeSettingsFn={this.props.onFinished} />,
|
||||
|
@ -137,7 +137,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
|| SettingsStore.getFeatureSettingNames().some(k => SettingsStore.getBetaInfo(k))
|
||||
) {
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.LABS,
|
||||
UserTab.Labs,
|
||||
_td("Labs"),
|
||||
"mx_UserSettingsDialog_labsIcon",
|
||||
<LabsUserSettingsTab />,
|
||||
|
@ -145,14 +145,14 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
}
|
||||
if (this.state.mjolnirEnabled) {
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.MJOLNIR,
|
||||
UserTab.Mjolnir,
|
||||
_td("Ignored users"),
|
||||
"mx_UserSettingsDialog_mjolnirIcon",
|
||||
<MjolnirUserSettingsTab />,
|
||||
));
|
||||
}
|
||||
tabs.push(new Tab(
|
||||
USER_TAB.HELP,
|
||||
UserTab.Help,
|
||||
_td("Help & About"),
|
||||
"mx_UserSettingsDialog_helpIcon",
|
||||
<HelpUserSettingsTab closeSettingsFn={() => this.props.onFinished(true)} />,
|
||||
|
|
|
@ -34,7 +34,7 @@ interface IProps {
|
|||
|
||||
interface IState {
|
||||
error: Error | null;
|
||||
canUploadKeysWithPasswordOnly: boolean | null;
|
||||
canUploadKeysWithPasswordOnly?: boolean;
|
||||
accountPassword: string;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ interface IState {
|
|||
*/
|
||||
@replaceableComponent("views.dialogs.security.CreateCrossSigningDialog")
|
||||
export default class CreateCrossSigningDialog extends React.PureComponent<IProps, IState> {
|
||||
constructor(props) {
|
||||
constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
|
@ -90,7 +90,7 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
|
|||
}
|
||||
}
|
||||
|
||||
private doBootstrapUIAuth = async (makeRequest): Promise<void> => {
|
||||
private doBootstrapUIAuth = async (makeRequest: (authData: any) => void): Promise<void> => {
|
||||
if (this.state.canUploadKeysWithPasswordOnly && this.state.accountPassword) {
|
||||
await makeRequest({
|
||||
type: 'm.login.password',
|
||||
|
|
|
@ -18,11 +18,11 @@ import React from 'react';
|
|||
import SetupEncryptionBody from '../../../structures/auth/SetupEncryptionBody';
|
||||
import BaseDialog from '../BaseDialog';
|
||||
import { _t } from '../../../../languageHandler';
|
||||
import { SetupEncryptionStore, PHASE } from '../../../../stores/SetupEncryptionStore';
|
||||
import { SetupEncryptionStore, Phase } from '../../../../stores/SetupEncryptionStore';
|
||||
import {replaceableComponent} from "../../../../utils/replaceableComponent";
|
||||
|
||||
function iconFromPhase(phase: PHASE) {
|
||||
if (phase === PHASE.DONE) {
|
||||
function iconFromPhase(phase: Phase) {
|
||||
if (phase === Phase.Done) {
|
||||
return require("../../../../../res/img/e2e/verified.svg");
|
||||
} else {
|
||||
return require("../../../../../res/img/e2e/warning.svg");
|
||||
|
@ -34,14 +34,14 @@ interface IProps {
|
|||
}
|
||||
|
||||
interface IState {
|
||||
icon: PHASE;
|
||||
icon: Phase;
|
||||
}
|
||||
|
||||
@replaceableComponent("views.dialogs.security.SetupEncryptionDialog")
|
||||
export default class SetupEncryptionDialog extends React.Component<IProps, IState> {
|
||||
private store: SetupEncryptionStore;
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
this.store = SetupEncryptionStore.sharedInstance();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue