[FIX] Notification preferences update crashing the app (#2262)

This commit is contained in:
Diego Mello 2020-07-08 17:46:05 -03:00 committed by GitHub
parent f70d8285c9
commit 5782a3363b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 18 deletions

View File

@ -16,6 +16,7 @@ import RocketChat from '../../lib/rocketchat';
import { withTheme } from '../../theme';
import protectedFunction from '../../lib/methods/helpers/protectedFunction';
import SafeAreaView from '../../containers/SafeAreaView';
import log from '../../utils/log';
const SectionTitle = React.memo(({ title, theme }) => (
<Text
@ -183,6 +184,7 @@ class NotificationPreferencesView extends React.Component {
const { room } = this.state;
const db = database.active;
try {
await db.action(async() => {
await room.update(protectedFunction((r) => {
r[key] = value;
@ -203,6 +205,9 @@ class NotificationPreferencesView extends React.Component {
r[key] = room[key];
}));
});
} catch (e) {
log(e);
}
}
onValueChangeSwitch = (key, value) => this.saveNotificationSettings(key, value, { [key]: value ? '1' : '0' });