Skip to content

Commit 07ac284

Browse files
author
mivl
committed
Audio notification tone fix
1 parent 50c9578 commit 07ac284

File tree

5 files changed

+29
-44
lines changed

5 files changed

+29
-44
lines changed

assets/notify.mp3

-28.6 KB
Binary file not shown.

assets/notify.wav

315 KB
Binary file not shown.

cmd/jira-notificator-gui/main.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
const (
14-
notificationSound = "assets/notify.mp3"
14+
notificationSound = "assets/notify.wav"
1515
icon = "assets/icon.ico"
1616
interval = 15
1717
)
@@ -54,6 +54,11 @@ func makeBasicControlsPage() ui.Control {
5454

5555
button := ui.NewButton("Přihlásit se")
5656
button.OnClicked(func(*ui.Button) {
57+
if host.Text() == "" || username.Text() == "" || password.Text() == "" {
58+
ui.MsgBoxError(mainwin, "Chyba", "Vyplňte všechny údaje")
59+
return
60+
}
61+
5762
host.Disable()
5863
username.Disable()
5964
password.Disable()
@@ -64,6 +69,10 @@ func makeBasicControlsPage() ui.Control {
6469
if err != nil {
6570
ui.QueueMain(func() {
6671
ui.MsgBoxError(window, "Chyba", err.Error())
72+
host.Enable()
73+
username.Enable()
74+
password.Enable()
75+
button.Enable()
6776
})
6877
return
6978
}
@@ -72,6 +81,10 @@ func makeBasicControlsPage() ui.Control {
7281
if err != nil {
7382
ui.QueueMain(func() {
7483
ui.MsgBoxError(window, "Chyba", err.Error())
84+
host.Enable()
85+
username.Enable()
86+
password.Enable()
87+
button.Enable()
7588
})
7689
return
7790
}
@@ -83,6 +96,10 @@ func makeBasicControlsPage() ui.Control {
8396
if err != nil {
8497
ui.QueueMain(func() {
8598
ui.MsgBoxError(window, "Chyba", err.Error())
99+
host.Enable()
100+
username.Enable()
101+
password.Enable()
102+
button.Enable()
86103
})
87104
return
88105
}

pkg/jira/audio.go

-35
This file was deleted.

pkg/jira/notification.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package jira
22

33
import (
44
"github.com/gen2brain/beeep"
5+
"github.com/hajimehoshi/oto"
6+
"github.com/pkg/errors"
57
"log"
68
"time"
79
)
@@ -33,14 +35,14 @@ func FetchNewNotifications(c Client, data NotificationData) error {
3335
channel := make(chan []Notification)
3436
finished := make(chan bool)
3537

36-
player, err := NewPlayer(data.Sound)
38+
player, err := oto.NewPlayer(44100, 2, 2, 40000)
3739
if err != nil {
38-
return err
40+
return errors.Wrap(err, "Chyba při inicializaci zvukového zařízení")
3941
}
4042

4143
worker, err := NewWorker(c, channel, finished)
4244
if err != nil {
43-
return err
45+
return errors.Wrap(err, "Chyba navázání připojení na data notifikací")
4446
}
4547

4648
notificator := &notificator{beeep.Alert}
@@ -51,16 +53,17 @@ func FetchNewNotifications(c Client, data NotificationData) error {
5153
case notifications := <-channel:
5254
log.Println(data.Text)
5355

54-
if err := player.Play(); err != nil {
55-
return err
56+
_, err := player.Write(data.Sound)
57+
if err != nil {
58+
return errors.Wrap(err, "Chyba při přehrávání tónu notifikace")
5659
}
5760

58-
err := notificator.notify(notifications)
61+
err = notificator.notify(notifications)
5962
if err != nil {
60-
return err
63+
return errors.Wrap(err, "Chyba při vytváření notifikace")
6164
}
6265
case <-finished:
63-
return worker.e
66+
return errors.Wrap(worker.e, "Chyba při provádění aktualizace dat")
6467
}
6568
}
6669
}

0 commit comments

Comments
 (0)