2019-04-26 21:15:25 +00:00
|
|
|
import { InteractionManager } from 'react-native';
|
|
|
|
|
|
|
|
import database from '../realm';
|
|
|
|
import log from '../../utils/log';
|
|
|
|
|
|
|
|
export default async function() {
|
|
|
|
try {
|
|
|
|
// RC 0.70.0
|
|
|
|
const result = await this.sdk.get('roles.list');
|
|
|
|
|
|
|
|
if (!result.success) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { roles } = result;
|
|
|
|
|
|
|
|
if (roles && roles.length) {
|
|
|
|
InteractionManager.runAfterInteractions(() => {
|
|
|
|
database.write(() => roles.forEach((role) => {
|
|
|
|
try {
|
|
|
|
database.create('roles', role, true);
|
|
|
|
} catch (e) {
|
2019-05-28 16:18:46 +00:00
|
|
|
log('err_get_roles_create', e);
|
2019-04-26 21:15:25 +00:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2019-05-28 16:18:46 +00:00
|
|
|
log('err_get_roles', e);
|
2019-04-26 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|