Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

middleware.js 891B

1234567891011121314151617181920212223242526272829303132
  1. // @flow
  2. import { MiddlewareRegistry } from '../base/redux';
  3. import { playSound } from '../base/sounds';
  4. import { INCOMING_MSG_SOUND_ID } from '../chat/constants';
  5. import { RECEIVE_POLL } from './actionTypes';
  6. MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
  7. const result = next(action);
  8. switch (action.type) {
  9. // Middleware triggered when a poll is received
  10. case RECEIVE_POLL: {
  11. const state = getState();
  12. const isChatOpen: boolean = state['features/chat'].isOpen;
  13. const isPollsTabFocused: boolean = state['features/chat'].isPollsTabFocused;
  14. // Finally, we notify user they received a new poll if their pane is not opened
  15. if (action.notify && (!isChatOpen || !isPollsTabFocused)) {
  16. dispatch(playSound(INCOMING_MSG_SOUND_ID));
  17. }
  18. break;
  19. }
  20. }
  21. return result;
  22. });