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

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // TODO: implement support for gradients.
  28. action.value.avatarBackgrounds = avatarBackgrounds.filter(
  29. (color: string) => !color.includes('linear-gradient')
  30. );
  31. break;
  32. }
  33. }
  34. return next(action);
  35. });