Pull apart settings module

This commit is contained in:
Julia Friesel
2018-09-13 19:05:06 +02:00
parent 3c1653bc8c
commit 88fc3cad09
10 changed files with 317 additions and 286 deletions
+31
View File
@@ -0,0 +1,31 @@
import Share from 'react-native-share'
import getDataAsCsvDataUri from '../../lib/import-export/export-to-csv'
import alertError from './alert-error'
import { settings as labels } from '../labels'
export default async function openShareDialogAndExport() {
let data
try {
data = getDataAsCsvDataUri()
if (!data) {
return alertError(labels.errors.noData)
}
} catch (err) {
console.error(err)
return alertError(labels.errors.couldNotConvert)
}
try {
await Share.open({
title: labels.export.title,
url: data,
subject: labels.export.subject,
type: 'text/csv',
showAppsToView: true
})
} catch (err) {
console.error(err)
return alertError(labels.export.errors.problemSharing)
}
}