Skip to content
This repository was archived by the owner on May 26, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/state/epics/timerEpics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import timer from '../../assets/timer.svg'
type EpicType = Epic<IRootActions, IRootActions, IRootState>
const { stopTimer, countDownFinished, countDownOneSecond } = timerActions

const SOUND_EFFECT = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/123941/Yodel_Sound_Effect.mp3')

export const startTimerEpic: EpicType = action$ =>
action$.pipe(
filter(isOfType(START_TIMER)),
Expand Down Expand Up @@ -49,6 +51,7 @@ export const alertEpic: EpicType = (action$, state$) =>
badge: timer,
icon: timer,
vibrate: [2000, 2000, 2000],
sound: SOUND_EFFECT,
}),
]
}),
Expand Down
4 changes: 4 additions & 0 deletions src/utils/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface INotificationOptions {
lang?: string
tag?: string
vibrate?: number[]
sound?: HTMLAudioElement
onClose?: (e: Event) => any
}

Expand All @@ -21,6 +22,9 @@ export function requestPermission() {
export function notify(title: string, options?: INotificationOptions) {
const notification = new Notification(title, options)

// tslint:disable-next-line: no-floating-promises
if (options && options.sound) options.sound.play()

notification.onclick = () => {
notification.close()
}
Expand Down