You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.web.ts 1.2KB

123456789101112131415161718192021222324252627282930313233
  1. import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
  2. import { SETTINGS_UPDATED } from '../base/settings/actionTypes';
  3. import { getHideSelfView } from '../base/settings/functions.web';
  4. import { showNotification } from '../notifications/actions';
  5. import { DISABLE_SELF_VIEW_NOTIFICATION_ID, NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
  6. import { openSettingsDialog } from './actions';
  7. import { SETTINGS_TABS } from './constants';
  8. MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
  9. const oldValue = getHideSelfView(getState());
  10. const result = next(action);
  11. switch (action.type) {
  12. case SETTINGS_UPDATED: {
  13. const newValue = action.settings.disableSelfView;
  14. if (newValue !== oldValue && newValue) {
  15. dispatch(showNotification({
  16. uid: DISABLE_SELF_VIEW_NOTIFICATION_ID,
  17. titleKey: 'notify.selfViewTitle',
  18. customActionNameKey: [ 'settings.title' ],
  19. customActionHandler: [ () =>
  20. dispatch(openSettingsDialog(SETTINGS_TABS.MORE))
  21. ]
  22. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  23. }
  24. }
  25. }
  26. return result;
  27. });