general refactor for simpler code
This commit is contained in:
@@ -6,10 +6,6 @@ import (
|
||||
)
|
||||
|
||||
type Notifier interface {
|
||||
RecordingStarted()
|
||||
RecordingEnded()
|
||||
Aborted()
|
||||
Transcribing()
|
||||
Error(msg string)
|
||||
Notify(title, message string)
|
||||
}
|
||||
@@ -20,21 +16,10 @@ func (d Desktop) RecordingStarted() {
|
||||
d.Notify("Hyprvoice", "Recording Started")
|
||||
}
|
||||
|
||||
func (d Desktop) RecordingEnded() {
|
||||
d.Notify("Hyprvoice", "Recording Ended")
|
||||
}
|
||||
|
||||
func (d Desktop) Transcribing() {
|
||||
d.Notify("Hyprvoice", "Transcribing...")
|
||||
}
|
||||
|
||||
func (Desktop) Aborted() {
|
||||
cmd := exec.Command("notify-send", "-a", "Hyprvoice", "-u", "critical", "Hyprvoice: Aborted")
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Printf("Failed to send abort notification: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (Desktop) Error(msg string) {
|
||||
cmd := exec.Command("notify-send", "-a", "Hyprvoice", "-u", "critical", "Hyprvoice Error", msg)
|
||||
if err := cmd.Run(); err != nil {
|
||||
@@ -51,22 +36,6 @@ func (Desktop) Notify(title, message string) {
|
||||
|
||||
type Log struct{}
|
||||
|
||||
func (l Log) RecordingStarted() {
|
||||
l.Notify("Hyprvoice", "Recording Started")
|
||||
}
|
||||
|
||||
func (l Log) RecordingEnded() {
|
||||
l.Notify("Hyprvoice", "Recording Ended")
|
||||
}
|
||||
|
||||
func (l Log) Transcribing() {
|
||||
l.Notify("Hyprvoice", "Transcribing...")
|
||||
}
|
||||
|
||||
func (l Log) Aborted() {
|
||||
l.Notify("Hyprvoice", "Aborted")
|
||||
}
|
||||
|
||||
func (l Log) Error(msg string) {
|
||||
l.Notify("Hyprvoice Error", msg)
|
||||
}
|
||||
@@ -77,9 +46,5 @@ func (Log) Notify(title, message string) {
|
||||
|
||||
type Nop struct{}
|
||||
|
||||
func (Nop) RecordingStarted() {}
|
||||
func (Nop) RecordingEnded() {}
|
||||
func (Nop) Aborted() {}
|
||||
func (Nop) Transcribing() {}
|
||||
func (Nop) Error(msg string) {}
|
||||
func (Nop) Notify(title, message string) {}
|
||||
|
||||
Reference in New Issue
Block a user