Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
992161e3
Commit
992161e3
authored
2 years ago
by
BloodyMarie
Browse files
Options
Downloads
Patches
Plain Diff
Implement review feedback
parent
407fa834
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/notifications.js
+4
-19
4 additions, 19 deletions
lib/notifications.js
with
4 additions
and
19 deletions
lib/notifications.js
+
4
−
19
View file @
992161e3
import
{
Platform
}
from
'
react-native
'
import
{
tempReminderObservable
,
periodReminderObservable
}
from
'
../local-storage
'
import
Notification
from
'
react-native-push-notification
'
import
Moment
from
'
moment
'
...
...
@@ -10,10 +9,8 @@ import nothingChanged from '../db/db-unchanged'
export
default
function
setupNotifications
(
navigate
)
{
Notification
.
configure
({
onNotification
:
(
notification
)
=>
{
if
(
Platform
.
OS
===
"
ios
"
&&
notification
.
data
&&
notification
.
data
.
id
===
'
11
'
)
{
navigate
(
'
TemperatureEditView
'
)
}
else
if
(
Platform
.
OS
===
"
android
"
&&
notification
.
id
===
'
1
'
)
{
// https://github.com/zo0r/react-native-push-notification/issues/966#issuecomment-479069106
if
(
notification
.
data
?.
id
===
'
1
'
||
notification
.
id
===
'
1
'
)
{
navigate
(
'
TemperatureEditView
'
)
}
else
{
navigate
(
'
Home
'
)
...
...
@@ -22,11 +19,7 @@ export default function setupNotifications(navigate) {
})
tempReminderObservable
(
reminder
=>
{
if
(
Platform
.
OS
===
"
ios
"
)
{
Notification
.
cancelLocalNotifications
({
id
:
'
11
'
})
}
else
{
Notification
.
cancelLocalNotifications
({
id
:
'
1
'
})
}
if
(
reminder
.
enabled
)
{
const
[
hours
,
minutes
]
=
reminder
.
time
.
split
(
'
:
'
)
let
target
=
new
Moment
()
...
...
@@ -40,7 +33,7 @@ export default function setupNotifications(navigate) {
Notification
.
localNotificationSchedule
({
id
:
'
1
'
,
userInfo
:
{
id
:
'
1
1
'
},
userInfo
:
{
id
:
'
1
'
},
message
:
labels
.
tempReminder
.
notification
,
date
:
target
.
toDate
(),
vibrate
:
false
,
...
...
@@ -50,22 +43,14 @@ export default function setupNotifications(navigate) {
},
false
)
periodReminderObservable
(
reminder
=>
{
if
(
Platform
.
OS
===
"
ios
"
)
{
Notification
.
cancelLocalNotifications
({
id
:
'
22
'
})
}
else
{
Notification
.
cancelLocalNotifications
({
id
:
'
2
'
})
}
if
(
reminder
.
enabled
)
setupPeriodReminder
()
},
false
)
getBleedingDaysSortedByDate
().
addListener
((
_
,
changes
)
=>
{
// the listener fires on setup, so we check if there were actually any changes
if
(
nothingChanged
(
changes
))
return
if
(
Platform
.
OS
===
"
ios
"
)
{
Notification
.
cancelLocalNotifications
({
id
:
'
22
'
})
}
else
{
Notification
.
cancelLocalNotifications
({
id
:
'
2
'
})
}
if
(
periodReminderObservable
.
value
.
enabled
)
setupPeriodReminder
()
})
...
...
@@ -88,7 +73,7 @@ function setupPeriodReminder() {
Notification
.
localNotificationSchedule
({
id
:
'
2
'
,
userInfo
:
{
id
:
'
2
2
'
},
userInfo
:
{
id
:
'
2
'
},
message
:
labels
.
periodReminder
.
notification
(
daysToEndOfPrediction
),
date
:
reminderDate
.
toDate
(),
vibrate
:
false
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment