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.

middleware.native.ts 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { SET_CONFIG } from '../base/config/actionTypes';
  2. import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
  3. import { SET_DYNAMIC_BRANDING_DATA } from './actionTypes';
  4. import { fetchCustomBrandingData } from './actions.native';
  5. import './middleware.any';
  6. MiddlewareRegistry.register(store => next => action => {
  7. switch (action.type) {
  8. case SET_CONFIG: {
  9. const result = next(action);
  10. store.dispatch(fetchCustomBrandingData());
  11. return result;
  12. }
  13. case SET_DYNAMIC_BRANDING_DATA: {
  14. const {
  15. avatarBackgrounds = [],
  16. backgroundColor,
  17. backgroundImageUrl,
  18. brandedIcons,
  19. didPageUrl,
  20. inviteDomain
  21. } = action.value;
  22. action.value = {
  23. avatarBackgrounds,
  24. backgroundColor,
  25. backgroundImageUrl,
  26. brandedIcons,
  27. didPageUrl,
  28. inviteDomain
  29. };
  30. // The backend may send an empty string, make sure we skip that.
  31. if (Array.isArray(avatarBackgrounds)) {
  32. // TODO: implement support for gradients.
  33. action.value.avatarBackgrounds = avatarBackgrounds.filter(
  34. (color: string) => !color.includes('linear-gradient')
  35. );
  36. }
  37. break;
  38. }
  39. }
  40. return next(action);
  41. });