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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. MiddlewareRegistry.register(store => next => action => {
  6. switch (action.type) {
  7. case SET_CONFIG: {
  8. const result = next(action);
  9. store.dispatch(fetchCustomBrandingData());
  10. return result;
  11. }
  12. case SET_DYNAMIC_BRANDING_DATA: {
  13. const {
  14. avatarBackgrounds = [],
  15. backgroundColor,
  16. backgroundImageUrl,
  17. didPageUrl,
  18. inviteDomain
  19. } = action.value;
  20. action.value = {
  21. avatarBackgrounds,
  22. backgroundColor,
  23. backgroundImageUrl,
  24. didPageUrl,
  25. inviteDomain
  26. };
  27. // The backend may send an empty string, make sure we skip that.
  28. if (Array.isArray(avatarBackgrounds)) {
  29. // TODO: implement support for gradients.
  30. action.value.avatarBackgrounds = avatarBackgrounds.filter(
  31. (color: string) => !color.includes('linear-gradient')
  32. );
  33. }
  34. break;
  35. }
  36. }
  37. return next(action);
  38. });