If time has already passed, start notification tomorrow
This commit is contained in:
+11
-5
@@ -1,6 +1,7 @@
|
||||
import {tempReminderObservable} from '../local-storage'
|
||||
import Notification from 'react-native-push-notification'
|
||||
import { LocalDate } from 'js-joda'
|
||||
import Moment from 'moment'
|
||||
import { settings as labels } from '../components/labels'
|
||||
import { getOrCreateCycleDay } from '../db'
|
||||
|
||||
@@ -16,14 +17,19 @@ export default function setupNotifications(navigate) {
|
||||
tempReminderObservable(reminder => {
|
||||
Notification.cancelAllLocalNotifications()
|
||||
if (reminder.enabled) {
|
||||
const date = new Date()
|
||||
const [hours, minutes] = reminder.time.split(':')
|
||||
date.setHours(parseInt(hours))
|
||||
date.setMinutes(parseInt(minutes))
|
||||
date.setSeconds(0)
|
||||
let target = new Moment()
|
||||
.hours(parseInt(hours))
|
||||
.minutes(parseInt(minutes))
|
||||
.seconds(0)
|
||||
|
||||
if(target.isBefore(new Moment())) {
|
||||
target = target.add(1, 'd')
|
||||
}
|
||||
|
||||
Notification.localNotificationSchedule({
|
||||
message: labels.tempReminder.notification,
|
||||
date,
|
||||
date: target.toDate(),
|
||||
vibrate: false,
|
||||
repeatType: 'day'
|
||||
})
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
"isobject": "^3.0.1",
|
||||
"js-base64": "^2.4.8",
|
||||
"js-joda": "^1.8.2",
|
||||
"moment": "^2.22.1",
|
||||
"moment": "^2.22.2",
|
||||
"object-path": "^0.11.4",
|
||||
"obv": "0.0.1",
|
||||
"react": "16.4.1",
|
||||
|
||||
Reference in New Issue
Block a user