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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. labels
  22. } = action.value;
  23. action.value = {
  24. avatarBackgrounds,
  25. backgroundColor,
  26. backgroundImageUrl,
  27. brandedIcons,
  28. didPageUrl,
  29. inviteDomain,
  30. labels
  31. };
  32. // The backend may send an empty string, make sure we skip that.
  33. if (Array.isArray(avatarBackgrounds)) {
  34. // TODO: implement support for gradients.
  35. action.value.avatarBackgrounds = avatarBackgrounds.filter(
  36. (color: string) => !color.includes('linear-gradient')
  37. );
  38. }
  39. break;
  40. }
  41. }
  42. return next(action);
  43. });