2017-07-21 14:41:01 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import { ImageCache } from 'react-native-img-cache';
|
|
|
|
|
|
|
|
import { APP_WILL_MOUNT } from '../../app';
|
|
|
|
import { CONFERENCE_FAILED, CONFERENCE_LEFT } from '../../base/conference';
|
|
|
|
import { MiddlewareRegistry } from '../../base/redux';
|
|
|
|
|
|
|
|
/**
|
2017-08-01 20:37:27 +00:00
|
|
|
* Middleware which captures app startup and conference actions in order to
|
|
|
|
* clear the image cache.
|
2017-07-21 14:41:01 +00:00
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2017-08-01 20:37:27 +00:00
|
|
|
MiddlewareRegistry.register(() => next => action => {
|
2017-07-21 14:41:01 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case APP_WILL_MOUNT:
|
|
|
|
case CONFERENCE_FAILED:
|
|
|
|
case CONFERENCE_LEFT:
|
|
|
|
ImageCache.get().clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|