540 Rename method to get previous temperature

This commit is contained in:
Lisa Hillebrand
2022-04-15 17:28:35 +02:00
parent 534f554986
commit fe9d9b4fdc
3 changed files with 192 additions and 153 deletions
+26 -28
View File
@@ -11,22 +11,23 @@ import Segment from '../common/segment'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { getDate } from '../../slices/date' import { getDate } from '../../slices/date'
import { isTemperatureOutOfRange, isPreviousTemperature } from '../helpers/cycle-day' import {
isTemperatureOutOfRange,
getPreviousTemperature,
} from '../helpers/cycle-day'
import { temperature as labels } from '../../i18n/en/cycle-day' import { temperature as labels } from '../../i18n/en/cycle-day'
import { Colors, Containers, Sizes, Spacing } from '../../styles' import { Colors, Containers, Sizes, Spacing } from '../../styles'
const formatTemperature = value => value === null const formatTemperature = (value) =>
? value value === null ? value : Number.parseFloat(value).toFixed(2)
: Number.parseFloat(value).toFixed(2)
class Temperature extends Component { class Temperature extends Component {
static propTypes = { static propTypes = {
data: PropTypes.object, data: PropTypes.object,
date: PropTypes.string.isRequired, date: PropTypes.string.isRequired,
save: PropTypes.func save: PropTypes.func,
} }
constructor(props) { constructor(props) {
@@ -35,13 +36,13 @@ class Temperature extends Component {
const { data, date } = this.props const { data, date } = this.props
const { value } = data const { value } = data
const { shouldShowSuggestion, suggestedTemperature } = const { shouldShowSuggestion, suggestedTemperature } =
isPreviousTemperature(date) getPreviousTemperature(date)
this.state = { this.state = {
isTimePickerVisible: false, isTimePickerVisible: false,
shouldShowSuggestion, shouldShowSuggestion,
suggestedTemperature: formatTemperature(suggestedTemperature), suggestedTemperature: formatTemperature(suggestedTemperature),
value: formatTemperature(value) value: formatTemperature(value),
} }
} }
@@ -54,7 +55,7 @@ class Temperature extends Component {
this.setState({ this.setState({
value: value.trim(), value: value.trim(),
shouldShowSuggestion: false shouldShowSuggestion: false,
}) })
} }
@@ -80,9 +81,10 @@ class Temperature extends Component {
const { shouldShowSuggestion, suggestedTemperature, value } = this.state const { shouldShowSuggestion, suggestedTemperature, value } = this.state
const { time } = this.props.data const { time } = this.props.data
const inputStyle = (shouldShowSuggestion && value === null) const inputStyle =
? { color: Colors.grey } shouldShowSuggestion && value === null
: {color: Colors.greyDark} ? { color: Colors.grey }
: { color: Colors.greyDark }
const outOfRangeWarning = isTemperatureOutOfRange(value) const outOfRangeWarning = isTemperatureOutOfRange(value)
let temperatureToShow = null let temperatureToShow = null
@@ -109,17 +111,17 @@ class Temperature extends Component {
/> />
<AppText>°C</AppText> <AppText>°C</AppText>
</View> </View>
{ outOfRangeWarning !== null && {outOfRangeWarning !== null && (
<View style={styles.hintContainer}> <View style={styles.hintContainer}>
<AppText style={styles.hint}>{outOfRangeWarning}</AppText> <AppText style={styles.hint}>{outOfRangeWarning}</AppText>
</View> </View>
} )}
</Segment> </Segment>
<Segment> <Segment>
<AppText style={styles.title}>{labels.time}</AppText> <AppText style={styles.title}>{labels.time}</AppText>
<AppTextInput <AppTextInput
onFocus={this.onShowTimePicker} onFocus={this.onShowTimePicker}
testID='timeInput' testID="timeInput"
value={time} value={time}
/> />
<DateTimePicker <DateTimePicker
@@ -127,7 +129,7 @@ class Temperature extends Component {
mode="time" mode="time"
onConfirm={this.setTime} onConfirm={this.setTime}
onCancel={this.onCancelTimePicker} onCancel={this.onCancelTimePicker}
display={Platform.OS === "ios" ? "spinner" : "default"} display={Platform.OS === 'ios' ? 'spinner' : 'default'}
/> />
</Segment> </Segment>
</React.Fragment> </React.Fragment>
@@ -137,28 +139,24 @@ class Temperature extends Component {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
...Containers.rowContainer ...Containers.rowContainer,
}, },
hint: { hint: {
fontStyle: 'italic', fontStyle: 'italic',
fontSize: Sizes.small fontSize: Sizes.small,
}, },
hintContainer: { hintContainer: {
marginVertical: Spacing.tiny marginVertical: Spacing.tiny,
}, },
title: { title: {
fontSize: Sizes.subtitle fontSize: Sizes.subtitle,
} },
}) })
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return({ return {
date: getDate(state), date: getDate(state),
}) }
} }
export default connect( export default connect(mapStateToProps, null)(Temperature)
mapStateToProps,
null,
)(Temperature)
+132 -102
View File
@@ -1,6 +1,6 @@
import { ChronoUnit, LocalDate, LocalTime } from 'js-joda' import { ChronoUnit, LocalDate, LocalTime } from 'js-joda'
import { getPreviousTemperature, saveSymptom } from '../../db' import { getPreviousTemperatureForDate, saveSymptom } from '../../db'
import { scaleObservable } from '../../local-storage' import { scaleObservable } from '../../local-storage'
import * as labels from '../../i18n/en/cycle-day' import * as labels from '../../i18n/en/cycle-day'
@@ -23,15 +23,16 @@ const temperatureLabels = labels.temperature
const minutes = ChronoUnit.MINUTES const minutes = ChronoUnit.MINUTES
const isNumber = (value) => typeof value === 'number' const isNumber = (value) => typeof value === 'number'
export const shouldShow = (value) => value !== null ? true : false export const shouldShow = (value) => (value !== null ? true : false)
export const isPreviousTemperature = (temperature) => { export const formatTemperature = (temperature) =>
const previousTemperature = getPreviousTemperature(temperature) !temperature
const shouldShowSuggestion = previousTemperature ? true : false ? temperature
const suggestedTemperature = previousTemperature ? : Number.parseFloat(temperature.toString()).toFixed(2)
previousTemperature.toString() : null
return { shouldShowSuggestion, suggestedTemperature } export const getPreviousTemperature = (date) => {
const previousTemperature = getPreviousTemperatureForDate(date)
return formatTemperature(previousTemperature)
} }
export const isTemperatureOutOfRange = (temperature) => { export const isTemperatureOutOfRange = (temperature) => {
@@ -55,7 +56,7 @@ export const isTemperatureOutOfRange = (temperature) => {
export const blank = { export const blank = {
bleeding: { bleeding: {
exclude: false, exclude: false,
value: null value: null,
}, },
cervix: { cervix: {
exclude: false, exclude: false,
@@ -64,9 +65,9 @@ export const blank = {
position: null, position: null,
}, },
desire: { desire: {
value: null value: null,
}, },
mood:{ mood: {
happy: null, happy: null,
sad: null, sad: null,
stressed: null, stressed: null,
@@ -77,16 +78,16 @@ export const blank = {
fatigue: null, fatigue: null,
angry: null, angry: null,
other: null, other: null,
note: null note: null,
}, },
mucus: { mucus: {
exclude: false, exclude: false,
feeling: null, feeling: null,
texture: null, texture: null,
value: null value: null,
}, },
note: { note: {
value: null value: null,
}, },
pain: { pain: {
cramps: null, cramps: null,
@@ -97,7 +98,7 @@ export const blank = {
tenderBreasts: null, tenderBreasts: null,
migraine: null, migraine: null,
other: null, other: null,
note: null note: null,
}, },
sex: { sex: {
solo: null, solo: null,
@@ -111,14 +112,14 @@ export const blank = {
diaphragm: null, diaphragm: null,
none: null, none: null,
other: null, other: null,
note: null note: null,
}, },
temperature: { temperature: {
exclude: false, exclude: false,
note: null, note: null,
time: LocalTime.now().truncatedTo(minutes).toString(), time: LocalTime.now().truncatedTo(minutes).toString(),
value: null value: null,
} },
} }
export const symtomPage = { export const symtomPage = {
@@ -126,11 +127,13 @@ export const symtomPage = {
excludeText: labels.bleeding.exclude.explainer, excludeText: labels.bleeding.exclude.explainer,
note: null, note: null,
selectBoxGroups: null, selectBoxGroups: null,
selectTabGroups: [{ selectTabGroups: [
key: 'value', {
options: getLabelsList(bleedingLabels), key: 'value',
title: labels.bleeding.heaviness.explainer, options: getLabelsList(bleedingLabels),
}] title: labels.bleeding.heaviness.explainer,
},
],
}, },
cervix: { cervix: {
excludeText: cervixLabels.excludeExplainer, excludeText: cervixLabels.excludeExplainer,
@@ -151,18 +154,20 @@ export const symtomPage = {
key: 'position', key: 'position',
options: getLabelsList(cervixLabels.position.categories), options: getLabelsList(cervixLabels.position.categories),
title: cervixLabels.position.explainer, title: cervixLabels.position.explainer,
} },
] ],
}, },
desire: { desire: {
excludeText: null, excludeText: null,
note: null, note: null,
selectBoxGroups: null, selectBoxGroups: null,
selectTabGroups: [{ selectTabGroups: [
key: 'value', {
options: getLabelsList(intensityLabels), key: 'value',
title: labels.desire.explainer options: getLabelsList(intensityLabels),
}] title: labels.desire.explainer,
},
],
}, },
mucus: { mucus: {
excludeText: mucusLabels.excludeExplainer, excludeText: mucusLabels.excludeExplainer,
@@ -178,34 +183,38 @@ export const symtomPage = {
key: 'texture', key: 'texture',
options: getLabelsList(mucusLabels.texture.categories), options: getLabelsList(mucusLabels.texture.categories),
title: mucusLabels.texture.explainer, title: mucusLabels.texture.explainer,
} },
] ],
}, },
mood: { mood: {
excludeText: null, excludeText: null,
note: null, note: null,
selectBoxGroups: [{ selectBoxGroups: [
key: 'mood', {
options: moodLabels, key: 'mood',
title: labels.mood.explainer options: moodLabels,
}], title: labels.mood.explainer,
selectTabGroups: null },
],
selectTabGroups: null,
}, },
note: { note: {
excludeText: null, excludeText: null,
note: noteDescription, note: noteDescription,
selectBoxGroups: null, selectBoxGroups: null,
selectTabGroups: null selectTabGroups: null,
}, },
pain: { pain: {
excludeText: null, excludeText: null,
note: null, note: null,
selectBoxGroups: [{ selectBoxGroups: [
key: 'pain', {
options: painLabels, key: 'pain',
title: labels.pain.explainer options: painLabels,
}], title: labels.pain.explainer,
selectTabGroups: null },
],
selectTabGroups: null,
}, },
sex: { sex: {
excludeText: null, excludeText: null,
@@ -220,40 +229,42 @@ export const symtomPage = {
key: 'contraceptives', key: 'contraceptives',
options: contraceptiveLabels, options: contraceptiveLabels,
title: labels.contraceptives.explainer, title: labels.contraceptives.explainer,
} },
], ],
selectTabGroups: null selectTabGroups: null,
}, },
temperature: { temperature: {
excludeText: temperatureLabels.exclude.explainer, excludeText: temperatureLabels.exclude.explainer,
note: temperatureLabels.note.explainer, note: temperatureLabels.note.explainer,
selectBoxGroups: null, selectBoxGroups: null,
selectTabGroups: null selectTabGroups: null,
} },
} }
export const save = { export const save = {
bleeding: (data, date, shouldDeleteData) => { bleeding: (data, date, shouldDeleteData) => {
const { exclude, value } = data const { exclude, value } = data
const isDataEntered = isNumber(value) const isDataEntered = isNumber(value)
const valuesToSave = shouldDeleteData || !isDataEntered const valuesToSave =
? null : { value, exclude } shouldDeleteData || !isDataEntered ? null : { value, exclude }
saveSymptom('bleeding', date, valuesToSave) saveSymptom('bleeding', date, valuesToSave)
}, },
cervix: (data, date, shouldDeleteData) => { cervix: (data, date, shouldDeleteData) => {
const { opening, firmness, position, exclude } = data const { opening, firmness, position, exclude } = data
const isDataEntered = ['opening', 'firmness', 'position'].some( const isDataEntered = ['opening', 'firmness', 'position'].some((value) =>
value => isNumber(data[value])) isNumber(data[value])
const valuesToSave = shouldDeleteData || !isDataEntered )
? null : { opening, firmness, position, exclude } const valuesToSave =
shouldDeleteData || !isDataEntered
? null
: { opening, firmness, position, exclude }
saveSymptom('cervix', date, valuesToSave) saveSymptom('cervix', date, valuesToSave)
}, },
desire: (data, date, shouldDeleteData) => { desire: (data, date, shouldDeleteData) => {
const { value } = data const { value } = data
const valuesToSave = shouldDeleteData || !isNumber(value) const valuesToSave = shouldDeleteData || !isNumber(value) ? null : { value }
? null : { value }
saveSymptom('desire', date, valuesToSave) saveSymptom('desire', date, valuesToSave)
}, },
@@ -262,11 +273,18 @@ export const save = {
}, },
mucus: (data, date, shouldDeleteData) => { mucus: (data, date, shouldDeleteData) => {
const { feeling, texture, exclude } = data const { feeling, texture, exclude } = data
const isDataEntered = ['feeling', 'texture'].some( const isDataEntered = ['feeling', 'texture'].some((value) =>
value => isNumber(data[value])) isNumber(data[value])
const valuesToSave = shouldDeleteData || !isDataEntered )
? null const valuesToSave =
: { feeling, texture, value: computeNfpValue(feeling, texture), exclude } shouldDeleteData || !isDataEntered
? null
: {
feeling,
texture,
value: computeNfpValue(feeling, texture),
exclude,
}
saveSymptom('mucus', date, valuesToSave) saveSymptom('mucus', date, valuesToSave)
}, },
@@ -289,21 +307,20 @@ export const save = {
exclude, exclude,
note, note,
time, time,
value: Number(value) value: Number(value),
} }
saveSymptom( saveSymptom(
'temperature', 'temperature',
date, date,
(shouldDeleteData || value === null) ? null : valuesToSave shouldDeleteData || value === null ? null : valuesToSave
) )
} },
} }
const saveBoxSymptom = (data, date, shouldDeleteData, symptom) => { const saveBoxSymptom = (data, date, shouldDeleteData, symptom) => {
const isDataEntered = Object.keys(data).some(key => data[key] !== null) const isDataEntered = Object.keys(data).some((key) => data[key] !== null)
const valuesToSave = shouldDeleteData || !isDataEntered const valuesToSave = shouldDeleteData || !isDataEntered ? null : data
? null : data
saveSymptom(symptom, date, valuesToSave) saveSymptom(symptom, date, valuesToSave)
} }
@@ -327,46 +344,59 @@ const label = {
return temperatureLabel return temperatureLabel
} }
}, },
mucus: mucus => { mucus: (mucus) => {
const filledCategories = ['feeling', 'texture'].filter(c => isNumber(mucus[c])) const filledCategories = ['feeling', 'texture'].filter((c) =>
let label = filledCategories.map(category => { isNumber(mucus[c])
return labels.mucus.subcategories[category] + ': ' + labels.mucus[category].categories[mucus[category]] )
}).join(', ') let label = filledCategories
.map((category) => {
return (
labels.mucus.subcategories[category] +
': ' +
labels.mucus[category].categories[mucus[category]]
)
})
.join(', ')
if (isNumber(mucus.value)) label += `\n => ${labels.mucusNFP[mucus.value]}` if (isNumber(mucus.value)) label += `\n => ${labels.mucusNFP[mucus.value]}`
if (mucus.exclude) label = `(${label})` if (mucus.exclude) label = `(${label})`
return label return label
}, },
cervix: cervix => { cervix: (cervix) => {
const filledCategories = ['opening', 'firmness', 'position'].filter(c => isNumber(cervix[c])) const filledCategories = ['opening', 'firmness', 'position'].filter((c) =>
let label = filledCategories.map(category => { isNumber(cervix[c])
return labels.cervix.subcategories[category] + ': ' + labels.cervix[category].categories[cervix[category]] )
}).join(', ') let label = filledCategories
.map((category) => {
return (
labels.cervix.subcategories[category] +
': ' +
labels.cervix[category].categories[cervix[category]]
)
})
.join(', ')
if (cervix.exclude) label = `(${label})` if (cervix.exclude) label = `(${label})`
return label return label
}, },
note: note => note.value, note: (note) => note.value,
desire: ({ value }) => { desire: ({ value }) => {
if (isNumber(value)) { if (isNumber(value)) {
return intensityLabels[value] return intensityLabels[value]
} }
}, },
sex: sex => { sex: (sex) => {
const sexLabel = [] const sexLabel = []
if (sex && Object.values({...sex}).some(val => val)){ if (sex && Object.values({ ...sex }).some((val) => val)) {
Object.keys(sex).forEach(key => { Object.keys(sex).forEach((key) => {
if(sex[key] && key !== 'other' && key !== 'note') { if (sex[key] && key !== 'other' && key !== 'note') {
sexLabel.push( sexLabel.push(sexLabels[key] || contraceptiveLabels[key])
sexLabels[key] ||
contraceptiveLabels[key]
)
} }
if(key === 'other' && sex.other) { if (key === 'other' && sex.other) {
let label = contraceptiveLabels[key] let label = contraceptiveLabels[key]
if(sex.note) { if (sex.note) {
label = `${label} (${sex.note})` label = `${label} (${sex.note})`
} }
sexLabel.push(label) sexLabel.push(label)
@@ -375,16 +405,16 @@ const label = {
return sexLabel.join(', ') return sexLabel.join(', ')
} }
}, },
pain: pain => { pain: (pain) => {
const painLabel = [] const painLabel = []
if (pain && Object.values({...pain}).some(val => val)){ if (pain && Object.values({ ...pain }).some((val) => val)) {
Object.keys(pain).forEach(key => { Object.keys(pain).forEach((key) => {
if(pain[key] && key !== 'other' && key !== 'note') { if (pain[key] && key !== 'other' && key !== 'note') {
painLabel.push(painLabels[key]) painLabel.push(painLabels[key])
} }
if(key === 'other' && pain.other) { if (key === 'other' && pain.other) {
let label = painLabels[key] let label = painLabels[key]
if(pain.note) { if (pain.note) {
label = `${label} (${pain.note})` label = `${label} (${pain.note})`
} }
painLabel.push(label) painLabel.push(label)
@@ -393,16 +423,16 @@ const label = {
return painLabel.join(', ') return painLabel.join(', ')
} }
}, },
mood: mood => { mood: (mood) => {
const moodLabel = [] const moodLabel = []
if (mood && Object.values({...mood}).some(val => val)){ if (mood && Object.values({ ...mood }).some((val) => val)) {
Object.keys(mood).forEach(key => { Object.keys(mood).forEach((key) => {
if(mood[key] && key !== 'other' && key !== 'note') { if (mood[key] && key !== 'other' && key !== 'note') {
moodLabel.push(moodLabels[key]) moodLabel.push(moodLabels[key])
} }
if(key === 'other' && mood.other) { if (key === 'other' && mood.other) {
let label = moodLabels[key] let label = moodLabels[key]
if(mood.note) { if (mood.note) {
label = `${label} (${mood.note})` label = `${label} (${mood.note})`
} }
moodLabel.push(label) moodLabel.push(label)
@@ -410,7 +440,7 @@ const label = {
}) })
return moodLabel.join(', ') return moodLabel.join(', ')
} }
} },
} }
export const getData = (symptom, symptomData) => { export const getData = (symptom, symptomData) => {
+34 -23
View File
@@ -11,7 +11,7 @@ let db
let checkIsMensesStart let checkIsMensesStart
let getMensesDaysRightAfter let getMensesDaysRightAfter
export async function openDb (hash) { export async function openDb(hash) {
const realmConfig = {} const realmConfig = {}
if (hash) { if (hash) {
realmConfig.encryptionKey = hashToInt8Array(hash) realmConfig.encryptionKey = hashToInt8Array(hash)
@@ -22,7 +22,7 @@ export async function openDb (hash) {
let tempConnection let tempConnection
try { try {
tempConnection = await Realm.open(realmConfig) tempConnection = await Realm.open(realmConfig)
} catch(err) { } catch (err) {
const isErrorDecrypting = err.toString().includes('decrypt') const isErrorDecrypting = err.toString().includes('decrypt')
const isErrorMnemonic = err.toString().includes('Invalid mnemonic') const isErrorMnemonic = err.toString().includes('Invalid mnemonic')
// tried to open without password, but is encrypted or incorrect pwd // tried to open without password, but is encrypted or incorrect pwd
@@ -36,20 +36,16 @@ export async function openDb (hash) {
let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath) let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath)
tempConnection.close() tempConnection.close()
while (nextSchemaIndex < schemas.length - 1) { while (nextSchemaIndex < schemas.length - 1) {
const tempConfig = Object.assign( const tempConfig = Object.assign(realmConfig, schemas[nextSchemaIndex++])
realmConfig,
schemas[nextSchemaIndex++]
)
const migratedRealm = new Realm(tempConfig) const migratedRealm = new Realm(tempConfig)
migratedRealm.close() migratedRealm.close()
} }
// open the Realm with the latest schema // open the Realm with the latest schema
realmConfig.schema = schemas[schemas.length - 1] realmConfig.schema = schemas[schemas.length - 1]
const connection = await Realm.open(Object.assign( const connection = await Realm.open(
realmConfig, Object.assign(realmConfig, schemas[schemas.length - 1])
schemas[schemas.length - 1] )
))
db = connection db = connection
const cycle = cycleModule() const cycle = cycleModule()
@@ -63,17 +59,26 @@ export function closeDb() {
} }
export function getBleedingDaysSortedByDate() { export function getBleedingDaysSortedByDate() {
return db.objects('CycleDay').filtered('bleeding != null').sorted('date', true) return db
.objects('CycleDay')
.filtered('bleeding != null')
.sorted('date', true)
} }
export function getTemperatureDaysSortedByDate() { export function getTemperatureDaysSortedByDate() {
return db.objects('CycleDay').filtered('temperature != null').sorted('date', true) return db
.objects('CycleDay')
.filtered('temperature != null')
.sorted('date', true)
} }
export function getCycleDaysSortedByDate() { export function getCycleDaysSortedByDate() {
return db.objects('CycleDay').sorted('date', true) return db.objects('CycleDay').sorted('date', true)
} }
export function getCycleStartsSortedByDate() { export function getCycleStartsSortedByDate() {
return db.objects('CycleDay').filtered('isCycleStart = true').sorted('date', true) return db
.objects('CycleDay')
.filtered('isCycleStart = true')
.sorted('date', true)
} }
export function saveSymptom(symptom, date, val) { export function saveSymptom(symptom, date, val) {
let cycleDay = getCycleDay(date) let cycleDay = getCycleDay(date)
@@ -83,7 +88,10 @@ export function saveSymptom(symptom, date, val) {
if (symptom === 'bleeding') { if (symptom === 'bleeding') {
const mensesDaysAfter = getMensesDaysRightAfter(cycleDay) const mensesDaysAfter = getMensesDaysRightAfter(cycleDay)
maybeSetNewCycleStart({ maybeSetNewCycleStart({
val, cycleDay, mensesDaysAfter, checkIsMensesStart val,
cycleDay,
mensesDaysAfter,
checkIsMensesStart,
}) })
} else { } else {
cycleDay[symptom] = val cycleDay[symptom] = val
@@ -93,7 +101,7 @@ export function saveSymptom(symptom, date, val) {
export function updateCycleStartsForAllCycleDays() { export function updateCycleStartsForAllCycleDays() {
db.write(() => { db.write(() => {
getBleedingDaysSortedByDate().forEach(day => { getBleedingDaysSortedByDate().forEach((day) => {
if (checkIsMensesStart(day)) { if (checkIsMensesStart(day)) {
day.isCycleStart = true day.isCycleStart = true
} }
@@ -106,7 +114,7 @@ export function createCycleDay(dateString) {
db.write(() => { db.write(() => {
result = db.create('CycleDay', { result = db.create('CycleDay', {
date: dateString, date: dateString,
isCycleStart: false isCycleStart: false,
}) })
}) })
return result return result
@@ -116,9 +124,9 @@ export function getCycleDay(dateString) {
return db.objectForPrimaryKey('CycleDay', dateString) return db.objectForPrimaryKey('CycleDay', dateString)
} }
export function getPreviousTemperature(date) { export function getPreviousTemperatureForDate(date) {
const targetDate = LocalDate.parse(date) const targetDate = LocalDate.parse(date)
const winner = getTemperatureDaysSortedByDate().find(candidate => { const winner = getTemperatureDaysSortedByDate().find((candidate) => {
return LocalDate.parse(candidate.date).isBefore(targetDate) return LocalDate.parse(candidate.date).isBefore(targetDate)
}) })
if (!winner) return null if (!winner) return null
@@ -171,10 +179,13 @@ export function tryToImportWithoutDelete(cycleDays) {
} }
export function requestHash(type, pw) { export function requestHash(type, pw) {
nodejs.channel.post('request-SHA512', JSON.stringify({ nodejs.channel.post(
type: type, 'request-SHA512',
message: pw JSON.stringify({
})) type: type,
message: pw,
})
)
} }
export async function changeEncryptionAndRestartApp(hash) { export async function changeEncryptionAndRestartApp(hash) {
@@ -199,7 +210,7 @@ export async function changeEncryptionAndRestartApp(hash) {
restart.Restart() restart.Restart()
} }
export function isDbEmpty () { export function isDbEmpty() {
return db.empty return db.empty
} }