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
80bec57f
Commit
80bec57f
authored
6 years ago
by
tina
Browse files
Options
Downloads
Patches
Plain Diff
tries to enable notifications for next period
parent
ce5a8ce5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/labels.js
+1
-1
1 addition, 1 deletion
components/labels.js
components/settings/period-reminder.js
+2
-2
2 additions, 2 deletions
components/settings/period-reminder.js
lib/notifications.js
+31
-3
31 additions, 3 deletions
lib/notifications.js
with
34 additions
and
6 deletions
components/labels.js
+
1
−
1
View file @
80bec57f
...
...
@@ -57,7 +57,7 @@ export const settings = {
periodReminder
:
{
title
:
'
Next period reminder
'
,
reminderText
:
'
Get a notification 3 days before your next period is likely to start.
'
,
notification
:
'
y
our next period is likely to start in
x
days.
'
notification
:
daysToEndOfPrediction
=>
`Y
our next period is likely to start in
3 to
${
daysToEndOfPrediction
}
days.
`
},
passwordSettings
:
{
title
:
'
App password
'
,
...
...
This diff is collapsed.
Click to expand it.
components/settings/period-reminder.js
+
2
−
2
View file @
80bec57f
...
...
@@ -14,7 +14,7 @@ import { settings as labels } from '../labels'
export
default
class
PeriodReminderPicker
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
Object
.
assign
({},
periodReminderObservable
.
value
)
this
.
state
=
periodReminderObservable
.
value
}
render
()
{
...
...
@@ -31,7 +31,7 @@ export default class PeriodReminderPicker extends Component {
value
=
{
this
.
state
.
enabled
}
onValueChange
=
{
switchOn
=>
{
this
.
setState
({
enabled
:
switchOn
})
savePeriodReminder
({
enabled
:
true
})
savePeriodReminder
({
enabled
:
switchOn
})
}}
/
>
<
/View
>
...
...
This diff is collapsed.
Click to expand it.
lib/notifications.js
+
31
−
3
View file @
80bec57f
import
{
tempReminderObservable
}
from
'
../local-storage
'
import
{
tempReminderObservable
,
periodReminderObservable
}
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
'
import
cycleModule
from
'
./cycle
'
export
default
function
setupNotifications
(
navigate
)
{
Notification
.
configure
({
onNotification
:
()
=>
{
const
todayDateString
=
LocalDate
.
now
().
toString
()
const
cycleDay
=
getOrCreateCycleDay
(
todayDateString
)
navigate
(
'
TemperatureEditView
'
,
{
cycleDay
})
if
(
this
.
id
===
'
1
'
)
{
navigate
(
'
TemperatureEditView
'
,
{
cycleDay
})
}
else
if
(
this
.
id
===
'
2
'
)
{
navigate
(
'
Home
'
)
}
else
{
navigate
(
'
Home
'
)
}
}
})
tempReminderObservable
(
reminder
=>
{
Notification
.
cancelAllLocalNotifications
()
Notification
.
cancelAllLocalNotifications
(
{
id
:
'
1
'
}
)
if
(
reminder
.
enabled
)
{
const
[
hours
,
minutes
]
=
reminder
.
time
.
split
(
'
:
'
)
let
target
=
new
Moment
()
...
...
@@ -28,6 +35,7 @@ export default function setupNotifications(navigate) {
}
Notification
.
localNotificationSchedule
({
id
:
'
1
'
,
message
:
labels
.
tempReminder
.
notification
,
date
:
target
.
toDate
(),
vibrate
:
false
,
...
...
@@ -35,4 +43,24 @@ export default function setupNotifications(navigate) {
})
}
})
periodReminderObservable
(
reminder
=>
{
if
(
reminder
.
enabled
)
{
const
bleedingPrediction
=
cycleModule
().
getPredictedMenses
()
if
(
bleedingPrediction
.
length
>
0
)
{
const
bleedingStart
=
LocalDate
.
parse
(
bleedingPrediction
[
0
][
0
])
const
reminderDate
=
bleedingStart
.
minusDays
(
3
)
// period is likely to start in 3 to 3 + (length of prediction - 1) days
const
daysToEndOfPrediction
=
bleedingPrediction
[
0
].
length
+
2
Notification
.
localNotificationSchedule
({
id
:
'
2
'
,
message
:
labels
.
periodReminder
.
notification
(
daysToEndOfPrediction
),
date
:
reminderDate
,
vibrate
:
false
,
onNotification
:
navigate
(
'
Home
'
)
})
}
}
})
}
\ No newline at end of file
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