fix: import Notification from scripting, use HealthQuantityType type
- Notification is not global, must import from 'scripting' - queryQuantitySamples expects HealthQuantityType not string
This commit is contained in:
parent
bcd8c1241b
commit
ddc6a54d84
1 changed files with 3 additions and 3 deletions
|
|
@ -12,7 +12,7 @@
|
||||||
//
|
//
|
||||||
// Docs: https://scriptingapp.github.io/guide/Device%20Capabilities/Health/
|
// Docs: https://scriptingapp.github.io/guide/Device%20Capabilities/Health/
|
||||||
|
|
||||||
import { Script } from "scripting"
|
import { Script, Notification } from "scripting"
|
||||||
|
|
||||||
// Variables used by Scripting app. These must be at the very top of the file.
|
// Variables used by Scripting app. These must be at the very top of the file.
|
||||||
// icon-color: deep-blue; icon-glyph: heart;
|
// icon-color: deep-blue; icon-glyph: heart;
|
||||||
|
|
@ -30,7 +30,7 @@ const U = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the most recent sample of a type. Returns { value, startDate } or null.
|
// Read the most recent sample of a type. Returns { value, startDate } or null.
|
||||||
async function readLatest(type: string, unit: HealthUnit): Promise<{ value: number; startDate: Date } | null> {
|
async function readLatest(type: HealthQuantityType, unit: HealthUnit): Promise<{ value: number; startDate: Date } | null> {
|
||||||
try {
|
try {
|
||||||
const samples = await Health.queryQuantitySamples(type, {
|
const samples = await Health.queryQuantitySamples(type, {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
|
@ -51,7 +51,7 @@ async function readLatest(type: string, unit: HealthUnit): Promise<{ value: numb
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum all samples of a type since midnight. Returns a number or null.
|
// Sum all samples of a type since midnight. Returns a number or null.
|
||||||
async function readTodaySum(type: string, unit: HealthUnit): Promise<number | null> {
|
async function readTodaySum(type: HealthQuantityType, unit: HealthUnit): Promise<number | null> {
|
||||||
try {
|
try {
|
||||||
const start = new Date()
|
const start = new Date()
|
||||||
start.setHours(0, 0, 0, 0)
|
start.setHours(0, 0, 0, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue