Map realm object on the export only

This commit is contained in:
Sofiya Tepikin
2022-05-01 16:33:57 +02:00
parent 7d109878fc
commit 9940c2c46e
2 changed files with 3 additions and 5 deletions
@@ -1,6 +1,6 @@
import Share from 'react-native-share' import Share from 'react-native-share'
import { getCycleDaysSortedByDate } from '../../../db' import { getCycleDaysSortedByDate, mapRealmObjToJsObj } from '../../../db'
import getDataAsCsvDataUri from '../../../lib/import-export/export-to-csv' import getDataAsCsvDataUri from '../../../lib/import-export/export-to-csv'
import alertError from '../common/alert-error' import alertError from '../common/alert-error'
import settings from '../../../i18n/en/settings' import settings from '../../../i18n/en/settings'
@@ -10,7 +10,7 @@ import RNFS from 'react-native-fs'
export default async function exportData() { export default async function exportData() {
let data let data
const labels = settings.export const labels = settings.export
const cycleDaysByDate = getCycleDaysSortedByDate() const cycleDaysByDate = mapRealmObjToJsObj(getCycleDaysSortedByDate())
if (!cycleDaysByDate.length) return alertError(labels.errors.noData) if (!cycleDaysByDate.length) return alertError(labels.errors.noData)
@@ -36,10 +36,8 @@ export default async function exportData() {
showAppsToView: true, showAppsToView: true,
failOnCancel: false, failOnCancel: false,
}) })
} catch (err) { } catch (err) {
console.error(err) console.error(err)
return alertError(labels.errors.problemSharing) return alertError(labels.errors.problemSharing)
} }
} }
+1 -1
View File
@@ -77,7 +77,7 @@ export function getTemperatureDaysSortedByDate() {
export function getCycleDaysSortedByDate() { export function getCycleDaysSortedByDate() {
const cycleDays = db.objects('CycleDay').sorted('date', true) const cycleDays = db.objects('CycleDay').sorted('date', true)
return mapRealmObjToJsObj(cycleDays) return cycleDays
} }
export function getCycleStartsSortedByDate() { export function getCycleStartsSortedByDate() {