2021-12-16 16:55:45 +00:00
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { SETTINGS_UPDATED, getHideSelfView } from '../base/settings';
|
2021-12-16 16:55:45 +00:00
|
|
|
import { NOTIFICATION_TIMEOUT_TYPE, showNotification } from '../notifications';
|
|
|
|
|
|
|
|
import { openSettingsDialog } from './actions';
|
|
|
|
import { SETTINGS_TABS } from './constants';
|
|
|
|
|
|
|
|
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
|
|
|
const oldValue = getHideSelfView(getState());
|
|
|
|
|
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case SETTINGS_UPDATED: {
|
|
|
|
const newValue = action.settings.disableSelfView;
|
|
|
|
|
|
|
|
if (newValue !== oldValue && newValue) {
|
|
|
|
dispatch(showNotification({
|
|
|
|
titleKey: 'notify.selfViewTitle',
|
|
|
|
customActionNameKey: [ 'settings.title' ],
|
|
|
|
customActionHandler: [ () =>
|
|
|
|
dispatch(openSettingsDialog(SETTINGS_TABS.MORE))
|
|
|
|
]
|
|
|
|
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|