2022-10-21 07:33:10 +00:00
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
|
|
|
import { SETTINGS_UPDATED } from '../base/settings/actionTypes';
|
2022-11-10 08:45:56 +00:00
|
|
|
import { getHideSelfView } from '../base/settings/functions.web';
|
2022-10-21 07:33:10 +00:00
|
|
|
import { showNotification } from '../notifications/actions';
|
|
|
|
import { DISABLE_SELF_VIEW_NOTIFICATION_ID, NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
2021-12-16 16:55:45 +00:00
|
|
|
|
|
|
|
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({
|
2022-10-17 07:03:06 +00:00
|
|
|
uid: DISABLE_SELF_VIEW_NOTIFICATION_ID,
|
2021-12-16 16:55:45 +00:00
|
|
|
titleKey: 'notify.selfViewTitle',
|
|
|
|
customActionNameKey: [ 'settings.title' ],
|
|
|
|
customActionHandler: [ () =>
|
|
|
|
dispatch(openSettingsDialog(SETTINGS_TABS.MORE))
|
|
|
|
]
|
|
|
|
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|