Demonstrate dis.fire() with view_user_settings
Like a5f3318f3b
, this proves that the new dispatcher conversion works for fire-and-forget style dispatches too. This is another obvious-if-broken and generally safe conversion to make.
Other actions which can be dispatched this way have been excluded for reasons mentioned in the Action enum's comments.
This commit is contained in:
parent
a5f3318f3b
commit
e4835c4b03
10 changed files with 24 additions and 13 deletions
|
@ -22,6 +22,7 @@ import { _t } from '../../../../languageHandler';
|
||||||
|
|
||||||
import SettingsStore, {SettingLevel} from "../../../../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../../../../settings/SettingsStore";
|
||||||
import EventIndexPeg from "../../../../indexing/EventIndexPeg";
|
import EventIndexPeg from "../../../../indexing/EventIndexPeg";
|
||||||
|
import {Action} from "../../../../dispatcher/actions";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allows the user to disable the Event Index.
|
* Allows the user to disable the Event Index.
|
||||||
|
@ -47,7 +48,7 @@ export default class DisableEventIndexDialog extends React.Component {
|
||||||
await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, false);
|
await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, false);
|
||||||
await EventIndexPeg.deleteEventIndex();
|
await EventIndexPeg.deleteEventIndex();
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
dis.dispatch({ action: 'view_user_settings' });
|
dis.fire(Action.ViewUserSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {MatrixClientPeg} from '../../../../MatrixClientPeg';
|
||||||
import dis from "../../../../dispatcher/dispatcher";
|
import dis from "../../../../dispatcher/dispatcher";
|
||||||
import { _t } from "../../../../languageHandler";
|
import { _t } from "../../../../languageHandler";
|
||||||
import Modal from "../../../../Modal";
|
import Modal from "../../../../Modal";
|
||||||
|
import {Action} from "../../../../dispatcher/actions";
|
||||||
|
|
||||||
export default class NewRecoveryMethodDialog extends React.PureComponent {
|
export default class NewRecoveryMethodDialog extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -36,7 +37,7 @@ export default class NewRecoveryMethodDialog extends React.PureComponent {
|
||||||
|
|
||||||
onGoToSettingsClick = () => {
|
onGoToSettingsClick = () => {
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
dis.dispatch({ action: 'view_user_settings' });
|
dis.fire(Action.ViewUserSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSetupClick = async () => {
|
onSetupClick = async () => {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import * as sdk from "../../../../index";
|
||||||
import dis from "../../../../dispatcher/dispatcher";
|
import dis from "../../../../dispatcher/dispatcher";
|
||||||
import { _t } from "../../../../languageHandler";
|
import { _t } from "../../../../languageHandler";
|
||||||
import Modal from "../../../../Modal";
|
import Modal from "../../../../Modal";
|
||||||
|
import {Action} from "../../../../dispatcher/actions";
|
||||||
|
|
||||||
export default class RecoveryMethodRemovedDialog extends React.PureComponent {
|
export default class RecoveryMethodRemovedDialog extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -29,7 +30,7 @@ export default class RecoveryMethodRemovedDialog extends React.PureComponent {
|
||||||
|
|
||||||
onGoToSettingsClick = () => {
|
onGoToSettingsClick = () => {
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
dis.dispatch({ action: 'view_user_settings' });
|
dis.fire(Action.ViewUserSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSetupClick = () => {
|
onSetupClick = () => {
|
||||||
|
|
|
@ -107,7 +107,7 @@ export enum Views {
|
||||||
// re-dispatched. NOTE: some actions are non-trivial and would require
|
// re-dispatched. NOTE: some actions are non-trivial and would require
|
||||||
// re-factoring to be included in this list in future.
|
// re-factoring to be included in this list in future.
|
||||||
const ONBOARDING_FLOW_STARTERS = [
|
const ONBOARDING_FLOW_STARTERS = [
|
||||||
'view_user_settings',
|
Action.ViewUserSettings,
|
||||||
'view_create_chat',
|
'view_create_chat',
|
||||||
'view_create_room',
|
'view_create_room',
|
||||||
'view_create_group',
|
'view_create_group',
|
||||||
|
@ -613,7 +613,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
case 'view_indexed_room':
|
case 'view_indexed_room':
|
||||||
this.viewIndexedRoom(payload.roomIndex);
|
this.viewIndexedRoom(payload.roomIndex);
|
||||||
break;
|
break;
|
||||||
case 'view_user_settings': {
|
case Action.ViewUserSettings: {
|
||||||
const UserSettingsDialog = sdk.getComponent("dialogs.UserSettingsDialog");
|
const UserSettingsDialog = sdk.getComponent("dialogs.UserSettingsDialog");
|
||||||
Modal.createTrackedDialog('User settings', '', UserSettingsDialog, {},
|
Modal.createTrackedDialog('User settings', '', UserSettingsDialog, {},
|
||||||
/*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
/*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
||||||
|
@ -1621,9 +1621,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
action: 'view_create_room',
|
action: 'view_create_room',
|
||||||
});
|
});
|
||||||
} else if (screen === 'settings') {
|
} else if (screen === 'settings') {
|
||||||
dis.dispatch({
|
dis.fire(Action.ViewUserSettings);
|
||||||
action: 'view_user_settings',
|
|
||||||
});
|
|
||||||
} else if (screen === 'welcome') {
|
} else if (screen === 'welcome') {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_welcome_page',
|
action: 'view_welcome_page',
|
||||||
|
|
|
@ -27,6 +27,7 @@ import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
||||||
import {MenuItem} from "../../structures/ContextMenu";
|
import {MenuItem} from "../../structures/ContextMenu";
|
||||||
import * as sdk from "../../../index";
|
import * as sdk from "../../../index";
|
||||||
import {getHomePageUrl} from "../../../utils/pages";
|
import {getHomePageUrl} from "../../../utils/pages";
|
||||||
|
import {Action} from "../../../dispatcher/actions";
|
||||||
|
|
||||||
export default class TopLeftMenu extends React.Component {
|
export default class TopLeftMenu extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -134,7 +135,7 @@ export default class TopLeftMenu extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
openSettings() {
|
openSettings() {
|
||||||
dis.dispatch({action: 'view_user_settings'});
|
dis.fire(Action.ViewUserSettings);
|
||||||
this.closeMenu();
|
this.closeMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import { getDefaultIdentityServerUrl, useDefaultIdentityServer } from '../../../
|
||||||
import { abbreviateUrl } from '../../../utils/UrlUtils';
|
import { abbreviateUrl } from '../../../utils/UrlUtils';
|
||||||
import {sleep} from "../../../utils/promise";
|
import {sleep} from "../../../utils/promise";
|
||||||
import {Key} from "../../../Keyboard";
|
import {Key} from "../../../Keyboard";
|
||||||
|
import {Action} from "../../../dispatcher/actions";
|
||||||
|
|
||||||
const TRUNCATE_QUERY_LIST = 40;
|
const TRUNCATE_QUERY_LIST = 40;
|
||||||
const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200;
|
const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200;
|
||||||
|
@ -615,7 +616,7 @@ export default createReactClass({
|
||||||
|
|
||||||
onManageSettingsClick(e) {
|
onManageSettingsClick(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dis.dispatch({ action: 'view_user_settings' });
|
dis.fire(Action.ViewUserSettings);
|
||||||
this.onCancel();
|
this.onCancel();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import PropTypes from 'prop-types';
|
||||||
import {_t} from "../../../languageHandler";
|
import {_t} from "../../../languageHandler";
|
||||||
import * as sdk from "../../../index";
|
import * as sdk from "../../../index";
|
||||||
import dis from '../../../dispatcher/dispatcher';
|
import dis from '../../../dispatcher/dispatcher';
|
||||||
|
import {Action} from "../../../dispatcher/actions";
|
||||||
|
|
||||||
export default class IntegrationsDisabledDialog extends React.Component {
|
export default class IntegrationsDisabledDialog extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -31,7 +32,7 @@ export default class IntegrationsDisabledDialog extends React.Component {
|
||||||
|
|
||||||
_onOpenSettingsClick = () => {
|
_onOpenSettingsClick = () => {
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
dis.dispatch({action: "view_user_settings"});
|
dis.fire(Action.ViewUserSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -36,6 +36,7 @@ import {inviteMultipleToRoom} from "../../../RoomInvite";
|
||||||
import SettingsStore from '../../../settings/SettingsStore';
|
import SettingsStore from '../../../settings/SettingsStore';
|
||||||
import RoomListStore, {TAG_DM} from "../../../stores/RoomListStore";
|
import RoomListStore, {TAG_DM} from "../../../stores/RoomListStore";
|
||||||
import {Key} from "../../../Keyboard";
|
import {Key} from "../../../Keyboard";
|
||||||
|
import {Action} from "../../../dispatcher/actions";
|
||||||
|
|
||||||
export const KIND_DM = "dm";
|
export const KIND_DM = "dm";
|
||||||
export const KIND_INVITE = "invite";
|
export const KIND_INVITE = "invite";
|
||||||
|
@ -902,7 +903,7 @@ export default class InviteDialog extends React.PureComponent {
|
||||||
|
|
||||||
_onManageSettingsClick = (e) => {
|
_onManageSettingsClick = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dis.dispatch({ action: 'view_user_settings' });
|
dis.fire(Action.ViewUserSettings);
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { _t, _td } from '../../../languageHandler';
|
||||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
||||||
|
import {Action} from "../../../dispatcher/actions";
|
||||||
|
|
||||||
|
|
||||||
export default createReactClass({
|
export default createReactClass({
|
||||||
|
@ -37,7 +38,7 @@ export default createReactClass({
|
||||||
_onClickUserSettings: (e) => {
|
_onClickUserSettings: (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
dis.dispatch({action: 'view_user_settings'});
|
dis.fire(Action.ViewUserSettings);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
|
@ -33,5 +33,10 @@ export enum Action {
|
||||||
* View a user's profile. Should be used with a ViewUserPayload.
|
* View a user's profile. Should be used with a ViewUserPayload.
|
||||||
*/
|
*/
|
||||||
ViewUser = "view_user",
|
ViewUser = "view_user",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the user settings. No additional payload information required.
|
||||||
|
*/
|
||||||
|
ViewUserSettings = "view_user_settings",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue