Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

reducer.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* @flow */
  2. import { assign, ReducerRegistry } from '../base/redux';
  3. import {
  4. CANCEL_LOGIN,
  5. STOP_WAIT_FOR_OWNER,
  6. UPGRADE_ROLE_FINISHED,
  7. UPGRADE_ROLE_STARTED,
  8. WAIT_FOR_OWNER
  9. } from './actionTypes';
  10. ReducerRegistry.register('features/authentication', (state = {}, action) => {
  11. switch (action.type) {
  12. case CANCEL_LOGIN:
  13. return assign(state, {
  14. error: undefined,
  15. progress: undefined,
  16. thenableWithCancel: undefined
  17. });
  18. case STOP_WAIT_FOR_OWNER:
  19. return assign(state, {
  20. error: undefined,
  21. waitForOwnerTimeoutID: undefined
  22. });
  23. case UPGRADE_ROLE_FINISHED: {
  24. let { thenableWithCancel } = action;
  25. if (state.thenableWithCancel === thenableWithCancel) {
  26. const { error, progress } = action;
  27. // An error interrupts the process of authenticating and upgrading
  28. // the role of the local participant/user i.e. the process is no
  29. // more. Obviously, the process seizes to exist also when it does
  30. // its whole job.
  31. if (error || progress === 1) {
  32. thenableWithCancel = undefined;
  33. }
  34. return assign(state, {
  35. error,
  36. progress: progress || undefined,
  37. thenableWithCancel
  38. });
  39. }
  40. break;
  41. }
  42. case UPGRADE_ROLE_STARTED:
  43. return assign(state, {
  44. error: undefined,
  45. progress: undefined,
  46. thenableWithCancel: action.thenableWithCancel
  47. });
  48. case WAIT_FOR_OWNER:
  49. return assign(state, {
  50. waitForOwnerTimeoutID: action.waitForOwnerTimeoutID
  51. });
  52. }
  53. return state;
  54. });