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.

reducer.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // @flow
  2. import { APP_WILL_MOUNT } from '../../app';
  3. import { ReducerRegistry } from '../redux';
  4. import { PersistenceRegistry } from '../storage';
  5. import { PROFILE_UPDATED } from './actionTypes';
  6. /**
  7. * The default/initial redux state of the feature {@code base/profile}.
  8. *
  9. * @type Object
  10. */
  11. const DEFAULT_STATE = {};
  12. const STORE_NAME = 'features/base/profile';
  13. /**
  14. * Sets up the persistence of the feature {@code base/profile}.
  15. */
  16. PersistenceRegistry.register(STORE_NAME);
  17. ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
  18. switch (action.type) {
  19. case APP_WILL_MOUNT:
  20. // XXX APP_WILL_MOUNT is the earliest redux action of ours dispatched in
  21. // the store. For the purposes of legacy support, make sure that the
  22. // deserialized base/profile's state is in the format deemed current by
  23. // the current app revision.
  24. if (state && typeof state === 'object') {
  25. // In an enterprise/internal build of Jitsi Meet for Android and iOS
  26. // we had base/profile's state as an object with property profile.
  27. const { profile } = state;
  28. if (profile && typeof profile === 'object') {
  29. return { ...profile };
  30. }
  31. } else {
  32. // In the weird case that we have previously persisted/serialized
  33. // null.
  34. return DEFAULT_STATE;
  35. }
  36. break;
  37. case PROFILE_UPDATED:
  38. return {
  39. ...state,
  40. ...action.profile
  41. };
  42. }
  43. return state;
  44. });