選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

actions.web.ts 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { createRestrictWhiteboardEvent } from '../analytics/AnalyticsEvents';
  2. import { sendAnalytics } from '../analytics/functions';
  3. import { IStore } from '../app/types';
  4. import { resetWhiteboard, setWhiteboardOpen } from './actions.any';
  5. import { isWhiteboardAllowed, isWhiteboardOpen, isWhiteboardVisible } from './functions';
  6. import { WhiteboardStatus } from './types';
  7. export * from './actions.any';
  8. /**
  9. * API to toggle the whiteboard.
  10. *
  11. * @returns {Function}
  12. */
  13. export function toggleWhiteboard() {
  14. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  15. const state = getState();
  16. const isAllowed = isWhiteboardAllowed(state);
  17. const isOpen = isWhiteboardOpen(state);
  18. if (isAllowed) {
  19. if (isOpen && !isWhiteboardVisible(state)) {
  20. dispatch(setWhiteboardOpen(true));
  21. } else if (isOpen && isWhiteboardVisible(state)) {
  22. dispatch(setWhiteboardOpen(false));
  23. } else if (!isOpen) {
  24. dispatch(setWhiteboardOpen(true));
  25. }
  26. } else if (typeof APP !== 'undefined') {
  27. APP.API.notifyWhiteboardStatusChanged(WhiteboardStatus.FORBIDDEN);
  28. }
  29. };
  30. }
  31. /**
  32. * Restricts the whiteboard usage.
  33. *
  34. * @param {boolean} shouldCloseWhiteboard - Whether to dismiss the whiteboard.
  35. * @returns {Function}
  36. */
  37. export const restrictWhiteboard = (shouldCloseWhiteboard = true) => (dispatch: IStore['dispatch']) => {
  38. if (shouldCloseWhiteboard) {
  39. dispatch(setWhiteboardOpen(false));
  40. }
  41. dispatch(resetWhiteboard());
  42. sendAnalytics(createRestrictWhiteboardEvent());
  43. };