You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractEnableLobbyModeDialog.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @flow
  2. import { PureComponent } from 'react';
  3. import { getFieldValue } from '../../base/react';
  4. import { toggleLobbyMode } from '../actions';
  5. export type Props = {
  6. /**
  7. * The Redux Dispatch function.
  8. */
  9. dispatch: Function,
  10. /**
  11. * Function to be used to translate i18n labels.
  12. */
  13. t: Function
  14. };
  15. type State = {
  16. /**
  17. * The password value entered into the field.
  18. */
  19. password: string
  20. };
  21. /**
  22. * Abstract class to encapsulate the platform common code of the {@code EnableLobbyModeDialog}.
  23. */
  24. export default class AbstractEnableLobbyModeDialog<P: Props = Props> extends PureComponent<P, State> {
  25. /**
  26. * Instantiates a new component.
  27. *
  28. * @inheritdoc
  29. */
  30. constructor(props: P) {
  31. super(props);
  32. this.state = {
  33. password: ''
  34. };
  35. this._onEnableLobbyMode = this._onEnableLobbyMode.bind(this);
  36. this._onChangePassword = this._onChangePassword.bind(this);
  37. }
  38. _onChangePassword: Object => void;
  39. /**
  40. * Callback to be invoked when the user changes the password.
  41. *
  42. * @param {SyntheticEvent} event - The SyntheticEvent instance of the change.
  43. * @returns {void}
  44. */
  45. _onChangePassword(event) {
  46. this.setState({
  47. password: getFieldValue(event)
  48. });
  49. }
  50. _onEnableLobbyMode: () => void;
  51. /**
  52. * Callback to be invoked when the user initiates the lobby mode enable flow.
  53. *
  54. * @returns {void}
  55. */
  56. _onEnableLobbyMode() {
  57. this.props.dispatch(toggleLobbyMode(true, this.state.password));
  58. return true;
  59. }
  60. }