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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 pool of avatar backgrounds.
  16. *
  17. * @public
  18. * @type {Array<string>}
  19. */
  20. avatarBackgrounds: [],
  21. /**
  22. * The custom background color for the LargeVideo.
  23. *
  24. * @public
  25. * @type {string}
  26. */
  27. backgroundColor: '',
  28. /**
  29. * The custom background image used on the LargeVideo.
  30. *
  31. * @public
  32. * @type {string}
  33. */
  34. backgroundImageUrl: '',
  35. /**
  36. * Flag indicating that the branding data can be displayed.
  37. * This is used in order to avoid image flickering / text changing(blipping).
  38. *
  39. * @public
  40. * @type {boolean}
  41. */
  42. customizationReady: false,
  43. /**
  44. * Flag indicating that the dynamic branding data request has failed.
  45. * When the request fails there is no logo (JitsiWatermark) displayed.
  46. *
  47. * @public
  48. * @type {boolean}
  49. */
  50. customizationFailed: false,
  51. /**
  52. * Flag indicating that the dynamic branding has not been modified and should use
  53. * the default options.
  54. *
  55. * @public
  56. * @type {boolean}
  57. */
  58. defaultBranding: true,
  59. /**
  60. * Url for a custom page for DID numbers list.
  61. *
  62. * @public
  63. * @type {string}
  64. */
  65. didPageUrl: '',
  66. /**
  67. * The custom invite domain.
  68. *
  69. * @public
  70. * @type {string}
  71. */
  72. inviteDomain: '',
  73. /**
  74. * The custom url used when the user clicks the logo.
  75. *
  76. * @public
  77. * @type {string}
  78. */
  79. logoClickUrl: '',
  80. /**
  81. * The custom logo (JitisWatermark).
  82. *
  83. * @public
  84. * @type {string}
  85. */
  86. logoImageUrl: '',
  87. /**
  88. * Flag used to signal if the app should use a custom logo or not
  89. *
  90. * @public
  91. * @type {boolean}
  92. */
  93. useDynamicBrandingData: false
  94. };
  95. /**
  96. * Reduces redux actions for the purposes of the feature {@code dynamic-branding}.
  97. */
  98. ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
  99. switch (action.type) {
  100. case SET_DYNAMIC_BRANDING_DATA: {
  101. const {
  102. backgroundColor,
  103. backgroundImageUrl,
  104. defaultBranding,
  105. didPageUrl,
  106. inviteDomain,
  107. logoClickUrl,
  108. logoImageUrl,
  109. avatarBackgrounds
  110. } = action.value;
  111. return {
  112. avatarBackgrounds,
  113. backgroundColor,
  114. backgroundImageUrl,
  115. defaultBranding,
  116. didPageUrl,
  117. inviteDomain,
  118. logoClickUrl,
  119. logoImageUrl,
  120. customizationFailed: false,
  121. customizationReady: true,
  122. useDynamicBrandingData: true
  123. };
  124. }
  125. case SET_DYNAMIC_BRANDING_FAILED: {
  126. return {
  127. ...state,
  128. customizationReady: true,
  129. customizationFailed: true,
  130. useDynamicBrandingData: true
  131. };
  132. }
  133. case SET_DYNAMIC_BRANDING_READY:
  134. return {
  135. ...state,
  136. customizationReady: true
  137. };
  138. }
  139. return state;
  140. });