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

actions.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // @flow
  2. import {
  3. _DIAL_ERROR,
  4. _POTENTIAL_TRANSCRIBER_JOINED,
  5. _TRANSCRIBER_JOINED,
  6. _TRANSCRIBER_LEFT,
  7. DIAL_TRANSCRIBER,
  8. SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
  9. STOP_TRANSCRIBING
  10. } from './actionTypes';
  11. import {
  12. NOTIFICATION_TIMEOUT,
  13. hideNotification,
  14. showErrorNotification,
  15. showNotification
  16. } from '../notifications';
  17. /**
  18. * Dial the transcriber into the room.
  19. *
  20. * @public
  21. * @returns {{
  22. * type: DIAL_TRANSCRIBER
  23. * }}
  24. */
  25. export function dialTranscriber() {
  26. return {
  27. type: DIAL_TRANSCRIBER
  28. };
  29. }
  30. /**
  31. * Stop the transcribing by kicking the transcriber participant.
  32. *
  33. * @returns {{
  34. * type: STOP_TRANSCRIBING
  35. * }}
  36. */
  37. export function stopTranscribing() {
  38. return {
  39. type: STOP_TRANSCRIBING
  40. };
  41. }
  42. /**
  43. * Notify that the transcriber, with a unique ID, has joined.
  44. *
  45. * @param {string} participantId - The participant id of the transcriber.
  46. * @returns {{
  47. * type: _TRANSCRIBER_JOINED,
  48. * participantId: string
  49. * }}
  50. */
  51. export function transcriberJoined(participantId: string) {
  52. return {
  53. type: _TRANSCRIBER_JOINED,
  54. transcriberJID: participantId
  55. };
  56. }
  57. /**
  58. * Notify that the transcriber, with a unique ID, has left.
  59. *
  60. * @param {string} participantId - The participant id of the transcriber.
  61. * @returns {{
  62. * type: _TRANSCRIBER_LEFT,
  63. * participantId: string
  64. * }}
  65. */
  66. export function transcriberLeft(participantId: string) {
  67. return {
  68. type: _TRANSCRIBER_LEFT,
  69. transcriberJID: participantId
  70. };
  71. }
  72. /**
  73. * Notify that a potential transcriber, with a unique ID, has joined.
  74. *
  75. * @param {string} participantId - The participant id of the transcriber.
  76. * @returns {{
  77. * type: _POTENTIAL_TRANSCRIBER_JOINED,
  78. * participantId: string
  79. * }}
  80. */
  81. export function potentialTranscriberJoined(participantId: string) {
  82. return {
  83. type: _POTENTIAL_TRANSCRIBER_JOINED,
  84. transcriberJID: participantId
  85. };
  86. }
  87. /**
  88. * Notify that dialing the transcriber resulted in an error.
  89. *
  90. * @returns {{
  91. * type: _DIAL_ERROR
  92. * }}
  93. */
  94. export function dialError() {
  95. return {
  96. type: _DIAL_ERROR
  97. };
  98. }
  99. /**
  100. * Signals that the pending transcribing notification should be shown on the
  101. * screen.
  102. *
  103. * @returns {Function}
  104. */
  105. export function showPendingTranscribingNotification() {
  106. return (dispatch: Function) => {
  107. const showNotificationAction = showNotification({
  108. descriptionKey: 'transcribing.pending',
  109. isDismissAllowed: false,
  110. titleKey: 'dialog.transcribing'
  111. });
  112. dispatch(showNotificationAction);
  113. dispatch(setPendingTranscribingNotificationUid(
  114. showNotificationAction.uid));
  115. };
  116. }
  117. /**
  118. * Sets UID of the the pending transcribing notification to use it when hiding
  119. * the notification is necessary, or unsets it when undefined (or no param) is
  120. * passed.
  121. *
  122. * @param {?number} uid - The UID of the notification.
  123. * @returns {{
  124. * type: SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
  125. * uid: number
  126. * }}
  127. */
  128. export function setPendingTranscribingNotificationUid(uid: ?number) {
  129. return {
  130. type: SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
  131. uid
  132. };
  133. }
  134. /**
  135. * Signals that the pending transcribing notification should be removed from the
  136. * screen.
  137. *
  138. * @returns {Function}
  139. */
  140. export function hidePendingTranscribingNotification() {
  141. return (dispatch: Function, getState: Function) => {
  142. const { pendingNotificationUid } = getState()['features/transcribing'];
  143. if (pendingNotificationUid) {
  144. dispatch(hideNotification(pendingNotificationUid));
  145. dispatch(setPendingTranscribingNotificationUid());
  146. }
  147. };
  148. }
  149. /**
  150. * Signals that the stopped transcribing notification should be shown on the
  151. * screen.
  152. *
  153. * @returns {showNotification}
  154. */
  155. export function showStoppedTranscribingNotification() {
  156. return showNotification({
  157. descriptionKey: 'transcribing.off',
  158. titleKey: 'dialog.transcribing'
  159. }, NOTIFICATION_TIMEOUT);
  160. }
  161. /**
  162. * Signals that the transcribing error notification should be shown.
  163. *
  164. * @returns {showErrorNotification}
  165. */
  166. export function showTranscribingError() {
  167. return showErrorNotification({
  168. descriptionKey: 'transcribing.error',
  169. titleKey: 'transcribing.failedToStart'
  170. });
  171. }