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.

reducer.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. SET_DYNAMIC_BRANDING_DATA,
  5. SET_DYNAMIC_BRANDING_FAILED,
  6. SET_DYNAMIC_BRANDING_READY
  7. } from './actionTypes';
  8. /**
  9. * The name of the redux store/state property which is the root of the redux
  10. * state of the feature {@code dynamic-branding}.
  11. */
  12. const STORE_NAME = 'features/dynamic-branding';
  13. const DEFAULT_STATE = {
  14. /**
  15. * The custom background color for the LargeVideo.
  16. *
  17. * @public
  18. * @type {string}
  19. */
  20. backgroundColor: '',
  21. /**
  22. * The custom background image used on the LargeVideo.
  23. *
  24. * @public
  25. * @type {string}
  26. */
  27. backgroundImageUrl: '',
  28. /**
  29. * Flag indicating that the logo (JitsiWatermark) can be displayed.
  30. * This is used in order to avoid image flickering.
  31. *
  32. * @public
  33. * @type {boolean}
  34. */
  35. customizationReady: false,
  36. /**
  37. * Flag indicating that the dynamic branding data request has failed.
  38. * When the request fails there is no logo (JitsiWatermark) displayed.
  39. *
  40. * @public
  41. * @type {boolean}
  42. */
  43. customizationFailed: false,
  44. /**
  45. * Flag indicating that the dynamic branding has not been modified and should use
  46. * the default options.
  47. *
  48. * @public
  49. * @type {boolean}
  50. */
  51. defaultBranding: true,
  52. /**
  53. * The custom invite domain.
  54. *
  55. * @public
  56. * @type {string}
  57. */
  58. inviteDomain: '',
  59. /**
  60. * The custom url used when the user clicks the logo.
  61. *
  62. * @public
  63. * @type {string}
  64. */
  65. logoClickUrl: '',
  66. /**
  67. * The custom logo (JitisWatermark).
  68. *
  69. * @public
  70. * @type {string}
  71. */
  72. logoImageUrl: '',
  73. /**
  74. * Flag used to signal if the app should use a custom logo or not
  75. *
  76. * @public
  77. * @type {boolean}
  78. */
  79. useDynamicBrandingData: false
  80. };
  81. /**
  82. * Reduces redux actions for the purposes of the feature {@code dynamic-branding}.
  83. */
  84. ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
  85. switch (action.type) {
  86. case SET_DYNAMIC_BRANDING_DATA: {
  87. const {
  88. backgroundColor,
  89. backgroundImageUrl,
  90. defaultBranding,
  91. inviteDomain,
  92. logoClickUrl,
  93. logoImageUrl
  94. } = action.value;
  95. return {
  96. backgroundColor,
  97. backgroundImageUrl,
  98. defaultBranding,
  99. inviteDomain,
  100. logoClickUrl,
  101. logoImageUrl,
  102. customizationFailed: false,
  103. customizationReady: true,
  104. useDynamicBrandingData: true
  105. };
  106. }
  107. case SET_DYNAMIC_BRANDING_FAILED: {
  108. return {
  109. ...state,
  110. customizationReady: true,
  111. customizationFailed: true,
  112. useDynamicBrandingData: true
  113. };
  114. }
  115. case SET_DYNAMIC_BRANDING_READY:
  116. return {
  117. ...state,
  118. customizationReady: true
  119. };
  120. }
  121. return state;
  122. });