Only use db functions when components are actually mounted
This commit is contained in:
+2
-2
@@ -13,8 +13,8 @@ export default function config(opts) {
|
||||
if (!opts) {
|
||||
// we only want to require (and run) the db module
|
||||
// when not running the tests
|
||||
bleedingDaysSortedByDate = require('../db').bleedingDaysSortedByDate
|
||||
cycleDaysSortedByDate = require('../db').cycleDaysSortedByDate
|
||||
bleedingDaysSortedByDate = require('../db').getBleedingDaysSortedByDate()
|
||||
cycleDaysSortedByDate = require('../db').getCycleDaysSortedByDate()
|
||||
maxBreakInBleeding = 1
|
||||
maxCycleLength = 99
|
||||
minCyclesForPrediction = 3
|
||||
|
||||
@@ -2,12 +2,6 @@ import getFertilityStatus from './sympto'
|
||||
import cycleModule from './cycle'
|
||||
import { fertilityStatus } from '../components/cycle-day/labels/labels'
|
||||
|
||||
const {
|
||||
getCycleForDay,
|
||||
getCyclesBefore,
|
||||
getPreviousCycle
|
||||
} = cycleModule()
|
||||
|
||||
export function getFertilityStatusStringForDay(dateString) {
|
||||
const status = getCycleStatusForDay(dateString)
|
||||
if (!status) return fertilityStatus.unknown
|
||||
@@ -28,6 +22,12 @@ export function getFertilityStatusStringForDay(dateString) {
|
||||
}
|
||||
|
||||
export function getCycleStatusForDay(dateString) {
|
||||
const {
|
||||
getCycleForDay,
|
||||
getCyclesBefore,
|
||||
getPreviousCycle
|
||||
} = cycleModule()
|
||||
|
||||
const cycle = getCycleForDay(dateString)
|
||||
if (!cycle) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user