2022-10-26 09:59:21 +03:00
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
2024-10-02 18:59:04 -05:00
|
|
|
import { showErrorNotification } from '../notifications/actions';
|
|
|
|
|
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
2022-10-26 09:59:21 +03:00
|
|
|
|
2024-10-02 18:59:04 -05:00
|
|
|
import { TRANSCRIBER_LEFT } from './actionTypes';
|
2024-10-24 10:11:33 -05:00
|
|
|
import './subscriber';
|
2018-07-26 18:33:40 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements the middleware of the feature transcribing.
|
|
|
|
|
*
|
|
|
|
|
* @param {Store} store - The redux store.
|
|
|
|
|
* @returns {Function}
|
|
|
|
|
*/
|
2024-10-02 18:59:04 -05:00
|
|
|
MiddlewareRegistry.register(({ dispatch }) => next => action => {
|
2018-07-26 18:33:40 +02:00
|
|
|
switch (action.type) {
|
2024-10-02 18:59:04 -05:00
|
|
|
case TRANSCRIBER_LEFT:
|
|
|
|
|
if (action.abruptly) {
|
|
|
|
|
dispatch(showErrorNotification({
|
|
|
|
|
titleKey: 'transcribing.failed'
|
|
|
|
|
}, NOTIFICATION_TIMEOUT_TYPE.LONG));
|
2018-07-26 18:33:40 +02:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
|
});
|