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 995B

1234567891011121314151617181920212223242526272829303132333435
  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 { avatarBackgrounds = [] } = action.value;
  15. // The backend may send an empty string, make sure we skip that.
  16. if (Array.isArray(avatarBackgrounds)) {
  17. // TODO: implement support for gradients.
  18. action.value.avatarBackgrounds = avatarBackgrounds.filter(
  19. (color: string) => !color.includes('linear-gradient')
  20. );
  21. }
  22. break;
  23. }
  24. }
  25. return next(action);
  26. });