Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
✨ Add icons to notification and use SW
Browse files Browse the repository at this point in the history
  • Loading branch information
sasa95 committed Mar 24, 2020
1 parent f5070ba commit 9d6f33e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ ReactDOM.render(
document.getElementById('root')
)

serviceWorker.unregister()
serviceWorker.register()
Binary file added src/scenes/Timer/assets/alarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/scenes/Timer/assets/alarm.svg

This file was deleted.

Binary file added src/scenes/Timer/assets/coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/scenes/Timer/assets/work.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions src/scenes/Timer/components/ToggleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import {
saveInterval,
} from '../actions'
import chime from '../assets/chime.mp3'
import icon from '../assets/alarm.svg'
import work from '../assets/work.png'
import alarm from '../assets/alarm.png'
import coffee from '../assets/coffee.png'

const ActionIcon = styled(IconButton)`
border: 1px solid #bababa;
Expand Down Expand Up @@ -72,7 +74,7 @@ const ToggleButton = () => {
setTitle(type, calculatedTimeLeft)

if (!calculatedProgress) {
setTimeout(() => {
setTimeout(async () => {
dispatch(setNextTimer())
audio.play()

Expand All @@ -83,9 +85,14 @@ const ToggleButton = () => {
const msg =
type === TYPES.work.id ? 'Take a break ☕️' : 'Start working 👨‍💻'

new Notification(msg, {
icon,
const icon = type === TYPES.work.id ? coffee : work

const registration = await navigator.serviceWorker.ready

registration.showNotification(msg, {
vibrate: [100, 50, 100],
badge: alarm,
icon,
})
}
}, 1000)
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/Timer/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const STATUSES = {

export const TYPES = {
work: { id: 'WORK', duration: 25 },
shortBreak: { id: 'SHORT_BREAK', duration: 0.1 },
shortBreak: { id: 'SHORT_BREAK', duration: 5 },
longBreak: { id: 'LONG_BREAK', duration: 20 },
}

Expand Down

0 comments on commit 9d6f33e

Please sign in to comment.