Implement review feedback

This commit is contained in:
BloodyMarie
2022-04-15 16:03:17 +02:00
parent 407fa834ab
commit 992161e3ce
+4 -19
View File
@@ -1,4 +1,3 @@
import { Platform } from 'react-native'
import {tempReminderObservable, periodReminderObservable} from '../local-storage' import {tempReminderObservable, periodReminderObservable} from '../local-storage'
import Notification from 'react-native-push-notification' import Notification from 'react-native-push-notification'
import Moment from 'moment' import Moment from 'moment'
@@ -10,10 +9,8 @@ import nothingChanged from '../db/db-unchanged'
export default function setupNotifications(navigate) { export default function setupNotifications(navigate) {
Notification.configure({ Notification.configure({
onNotification: (notification) => { onNotification: (notification) => {
if (Platform.OS === "ios" && notification.data && notification.data.id === '11') { // https://github.com/zo0r/react-native-push-notification/issues/966#issuecomment-479069106
navigate('TemperatureEditView') if (notification.data?.id === '1' || notification.id === '1') {
}
else if (Platform.OS === "android" && notification.id === '1') {
navigate('TemperatureEditView') navigate('TemperatureEditView')
} else { } else {
navigate('Home') navigate('Home')
@@ -22,11 +19,7 @@ export default function setupNotifications(navigate) {
}) })
tempReminderObservable(reminder => { tempReminderObservable(reminder => {
if (Platform.OS === "ios") {
Notification.cancelLocalNotifications({id: '11'})
} else {
Notification.cancelLocalNotifications({id: '1'}) Notification.cancelLocalNotifications({id: '1'})
}
if (reminder.enabled) { if (reminder.enabled) {
const [hours, minutes] = reminder.time.split(':') const [hours, minutes] = reminder.time.split(':')
let target = new Moment() let target = new Moment()
@@ -40,7 +33,7 @@ export default function setupNotifications(navigate) {
Notification.localNotificationSchedule({ Notification.localNotificationSchedule({
id: '1', id: '1',
userInfo: { id: '11' }, userInfo: { id: '1' },
message: labels.tempReminder.notification, message: labels.tempReminder.notification,
date: target.toDate(), date: target.toDate(),
vibrate: false, vibrate: false,
@@ -50,22 +43,14 @@ export default function setupNotifications(navigate) {
}, false) }, false)
periodReminderObservable(reminder => { periodReminderObservable(reminder => {
if (Platform.OS === "ios") {
Notification.cancelLocalNotifications({id: '22'})
} else {
Notification.cancelLocalNotifications({id: '2'}) Notification.cancelLocalNotifications({id: '2'})
}
if (reminder.enabled) setupPeriodReminder() if (reminder.enabled) setupPeriodReminder()
}, false) }, false)
getBleedingDaysSortedByDate().addListener((_, changes) => { getBleedingDaysSortedByDate().addListener((_, changes) => {
// the listener fires on setup, so we check if there were actually any changes // the listener fires on setup, so we check if there were actually any changes
if (nothingChanged(changes)) return if (nothingChanged(changes)) return
if (Platform.OS === "ios") {
Notification.cancelLocalNotifications({id: '22'})
} else {
Notification.cancelLocalNotifications({id: '2'}) Notification.cancelLocalNotifications({id: '2'})
}
if (periodReminderObservable.value.enabled) setupPeriodReminder() if (periodReminderObservable.value.enabled) setupPeriodReminder()
}) })
@@ -88,7 +73,7 @@ function setupPeriodReminder() {
Notification.localNotificationSchedule({ Notification.localNotificationSchedule({
id: '2', id: '2',
userInfo: { id: '22' }, userInfo: { id: '2' },
message: labels.periodReminder.notification(daysToEndOfPrediction), message: labels.periodReminder.notification(daysToEndOfPrediction),
date: reminderDate.toDate(), date: reminderDate.toDate(),
vibrate: false vibrate: false