您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AbstractDialogContainer.ts 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import React, { Component, ComponentType } from 'react';
  2. import { IReduxState } from '../../../app/types';
  3. import { IReactionEmojiProps } from '../../../reactions/constants';
  4. /**
  5. * The type of the React {@code Component} props of {@link DialogContainer}.
  6. */
  7. interface IProps {
  8. /**
  9. * The component to render.
  10. */
  11. _component?: ComponentType<any>;
  12. /**
  13. * The props to pass to the component that will be rendered.
  14. */
  15. _componentProps?: Object;
  16. /**
  17. * Array of reactions to be displayed.
  18. */
  19. _reactionsQueue: Array<IReactionEmojiProps>;
  20. /**
  21. * True if the UI is in a compact state where we don't show dialogs.
  22. */
  23. _reducedUI: boolean;
  24. }
  25. /**
  26. * Implements a DialogContainer responsible for showing all dialogs.
  27. */
  28. export default class AbstractDialogContainer extends Component<IProps> {
  29. /**
  30. * Returns the dialog to be displayed.
  31. *
  32. * @private
  33. * @returns {ReactElement|null}
  34. */
  35. _renderDialogContent() {
  36. const {
  37. _component: component,
  38. _reducedUI: reducedUI
  39. } = this.props;
  40. return (
  41. component && !reducedUI
  42. ? React.createElement(component, this.props._componentProps)
  43. : null);
  44. }
  45. }
  46. /**
  47. * Maps (parts of) the redux state to the associated
  48. * {@code AbstractDialogContainer}'s props.
  49. *
  50. * @param {Object} state - The redux state.
  51. * @private
  52. * @returns {IProps}
  53. */
  54. export function abstractMapStateToProps(state: IReduxState) {
  55. const stateFeaturesBaseDialog = state['features/base/dialog'];
  56. const { reducedUI } = state['features/base/responsive-ui'];
  57. return {
  58. _component: stateFeaturesBaseDialog.component,
  59. _componentProps: stateFeaturesBaseDialog.componentProps,
  60. _reducedUI: reducedUI
  61. };
  62. }