Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

actions.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // @flow
  2. import JitsiMeetJS from '../base/lib-jitsi-meet';
  3. import {
  4. hideNotification,
  5. showErrorNotification,
  6. showNotification
  7. } from '../notifications';
  8. import {
  9. CLEAR_RECORDING_SESSIONS,
  10. RECORDING_SESSION_UPDATED,
  11. SET_PENDING_RECORDING_NOTIFICATION_UID,
  12. SET_STREAM_KEY
  13. } from './actionTypes';
  14. /**
  15. * Clears the data of every recording sessions.
  16. *
  17. * @returns {{
  18. * type: CLEAR_RECORDING_SESSIONS
  19. * }}
  20. */
  21. export function clearRecordingSessions() {
  22. return {
  23. type: CLEAR_RECORDING_SESSIONS
  24. };
  25. }
  26. /**
  27. * Signals that the pending recording notification should be removed from the
  28. * screen.
  29. *
  30. * @param {string} streamType - The type of the stream (e.g. file or stream).
  31. * @returns {Function}
  32. */
  33. export function hidePendingRecordingNotification(streamType: string) {
  34. return (dispatch: Function, getState: Function) => {
  35. const { pendingNotificationUids } = getState()['features/recording'];
  36. const pendingNotificationUid = pendingNotificationUids[streamType];
  37. if (pendingNotificationUid) {
  38. dispatch(hideNotification(pendingNotificationUid));
  39. dispatch(
  40. _setPendingRecordingNotificationUid(
  41. undefined, streamType));
  42. }
  43. };
  44. }
  45. /**
  46. * Sets the stream key last used by the user for later reuse.
  47. *
  48. * @param {string} streamKey - The stream key to set.
  49. * redux.
  50. * @returns {{
  51. * type: SET_STREAM_KEY,
  52. * streamKey: string
  53. * }}
  54. */
  55. export function setLiveStreamKey(streamKey: string) {
  56. return {
  57. type: SET_STREAM_KEY,
  58. streamKey
  59. };
  60. }
  61. /**
  62. * Signals that the pending recording notification should be shown on the
  63. * screen.
  64. *
  65. * @param {string} streamType - The type of the stream (e.g. file or stream).
  66. * @returns {Function}
  67. */
  68. export function showPendingRecordingNotification(streamType: string) {
  69. return (dispatch: Function) => {
  70. const isLiveStreaming
  71. = streamType === JitsiMeetJS.constants.recording.mode.STREAM;
  72. const dialogProps = isLiveStreaming ? {
  73. descriptionKey: 'liveStreaming.pending',
  74. titleKey: 'dialog.liveStreaming'
  75. } : {
  76. descriptionKey: 'recording.pending',
  77. titleKey: 'dialog.recording'
  78. };
  79. const showNotificationAction = showNotification({
  80. isDismissAllowed: false,
  81. ...dialogProps
  82. });
  83. dispatch(showNotificationAction);
  84. dispatch(_setPendingRecordingNotificationUid(
  85. showNotificationAction.uid, streamType));
  86. };
  87. }
  88. /**
  89. * Signals that the recording error notification should be shown.
  90. *
  91. * @param {Object} props - The Props needed to render the notification.
  92. * @returns {showErrorNotification}
  93. */
  94. export function showRecordingError(props: Object) {
  95. return showErrorNotification(props);
  96. }
  97. /**
  98. * Signals that the stopped recording notification should be shown on the
  99. * screen for a given period.
  100. *
  101. * @param {string} streamType - The type of the stream (e.g. file or stream).
  102. * @returns {showNotification}
  103. */
  104. export function showStoppedRecordingNotification(streamType: string) {
  105. const isLiveStreaming
  106. = streamType === JitsiMeetJS.constants.recording.mode.STREAM;
  107. const dialogProps = isLiveStreaming ? {
  108. descriptionKey: 'liveStreaming.off',
  109. titleKey: 'dialog.liveStreaming'
  110. } : {
  111. descriptionKey: 'recording.off',
  112. titleKey: 'dialog.recording'
  113. };
  114. return showNotification(dialogProps, 2500);
  115. }
  116. /**
  117. * Updates the known state for a given recording session.
  118. *
  119. * @param {Object} session - The new state to merge with the existing state in
  120. * redux.
  121. * @returns {{
  122. * type: RECORDING_SESSION_UPDATED,
  123. * sessionData: Object
  124. * }}
  125. */
  126. export function updateRecordingSessionData(session: Object) {
  127. return {
  128. type: RECORDING_SESSION_UPDATED,
  129. sessionData: {
  130. error: session.getError(),
  131. id: session.getID(),
  132. liveStreamViewURL: session.getLiveStreamViewURL(),
  133. mode: session.getMode(),
  134. status: session.getStatus()
  135. }
  136. };
  137. }
  138. /**
  139. * Sets UID of the the pending streaming notification to use it when hinding
  140. * the notification is necessary, or unsets it when undefined (or no param) is
  141. * passed.
  142. *
  143. * @param {?number} uid - The UID of the notification.
  144. * redux.
  145. * @param {string} streamType - The type of the stream (e.g. file or stream).
  146. * @returns {{
  147. * type: SET_PENDING_RECORDING_NOTIFICATION_UID,
  148. * streamType: string,
  149. * uid: number
  150. * }}
  151. */
  152. function _setPendingRecordingNotificationUid(uid: ?number, streamType: string) {
  153. return {
  154. type: SET_PENDING_RECORDING_NOTIFICATION_UID,
  155. streamType,
  156. uid
  157. };
  158. }