mattermost-mobile/app/actions/views/account_notifications.js
enahum 248dafbe0e RN-97 Changed navigation from NavigationExperimental to ReactNative Navigation (#540)
* Add react-navigator dependency

* Add react-native-navigation dependency

* react-native-navigation, ios and android config

* update react-native-navigation

* New navigation and code cleanup

* Set ScreenBackgroundColor

* Fix channel drawer event issue

* Applied RNPN non-working popInitial notification

* Android navbar and back button

* packages and notices

* MM-redux update

* Fix draft on team switch

* Remove custom NavBar
2017-05-16 11:19:46 -04:00

35 lines
1.2 KiB
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {updateMe} from 'mattermost-redux/actions/users';
import {Preferences} from 'mattermost-redux/constants';
import {savePreferences} from 'mattermost-redux/actions/preferences';
export function handleUpdateUserNotifyProps(notifyProps) {
return async (dispatch, getState) => {
const state = getState();
const config = state.entities.general.config;
const {currentUserId} = state.entities.users;
const {interval, ...otherProps} = notifyProps;
const email = notifyProps.email;
if (config.EnableEmailBatching === 'true' && email !== 'false') {
const emailInterval = [{
user_id: notifyProps.user_id,
category: Preferences.CATEGORY_NOTIFICATIONS,
name: Preferences.EMAIL_INTERVAL,
value: interval
}];
savePreferences(currentUserId, emailInterval)(dispatch, getState);
}
const props = {...otherProps, email};
try {
await updateMe({notify_props: props})(dispatch, getState);
} catch (error) {
// do nothing
}
};
}