Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

reducer.ts 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import PersistenceRegistry from '../redux/PersistenceRegistry';
  2. import ReducerRegistry from '../redux/ReducerRegistry';
  3. import { ADD_KNOWN_DOMAINS } from './actionTypes';
  4. /**
  5. * The default list of domains known to the feature base/known-domains.
  6. * Generally, it should be in sync with the domains associated with the app
  7. * through its manifest (in other words, Universal Links, deep linking). Anyway,
  8. * we need a hardcoded list because it has proven impossible to programmatically
  9. * read the information out of the app's manifests: App Store strips the
  10. * associated domains manifest out of the app so it's never downloaded on the
  11. * client and we did not spend a lot of effort to read the associated domains
  12. * out of the Android manifest.
  13. */
  14. export const DEFAULT_STATE = [
  15. 'alpha.jitsi.net',
  16. 'beta.meet.jit.si',
  17. 'meet.jit.si',
  18. '8x8.vc'
  19. ];
  20. const STORE_NAME = 'features/base/known-domains';
  21. PersistenceRegistry.register(STORE_NAME);
  22. export type IKnownDomainsState = Array<string>;
  23. ReducerRegistry.register<IKnownDomainsState>(STORE_NAME, (state = DEFAULT_STATE, action): IKnownDomainsState => {
  24. switch (action.type) {
  25. case ADD_KNOWN_DOMAINS:
  26. return _addKnownDomains(state, action.knownDomains);
  27. default:
  28. return state;
  29. }
  30. });
  31. /**
  32. * Adds an array of known domains to the list of domains known to the feature
  33. * base/known-domains.
  34. *
  35. * @param {Object} state - The redux state.
  36. * @param {Array<string>} knownDomains - The array of known domains to add to
  37. * the list of domains known to the feature base/known-domains.
  38. * @private
  39. * @returns {Object} The next redux state.
  40. */
  41. function _addKnownDomains(state: IKnownDomainsState, knownDomains: Array<string>) {
  42. // In case persistence has deserialized a weird redux state:
  43. let nextState = Array.isArray(state) ? state : [];
  44. if (Array.isArray(knownDomains)) {
  45. nextState = Array.from(state);
  46. for (let knownDomain of knownDomains) {
  47. knownDomain = knownDomain.toLowerCase();
  48. !nextState.includes(knownDomain) && nextState.push(knownDomain);
  49. }
  50. }
  51. return nextState;
  52. }