feat: add keyboard controls
- add keyboard listener for space, r, and q keys
- create shared state for server messages
- update desktop and terminal notifications to use shared state
🤖
This commit is contained in:
parent
11c599a371
commit
4dcc984784
7 changed files with 107 additions and 9 deletions
|
@ -2,9 +2,9 @@ package websocket
|
|||
|
||||
import (
|
||||
"ChronoTomato/internal/notifications"
|
||||
"ChronoTomato/internal/shared"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
@ -12,7 +12,6 @@ import (
|
|||
var Done = make(chan struct{})
|
||||
|
||||
func ProcessServerMessages(conn *websocket.Conn) {
|
||||
var serverMessage models.ServerMessage
|
||||
|
||||
defer close(Done)
|
||||
|
||||
|
@ -24,14 +23,14 @@ func ProcessServerMessages(conn *websocket.Conn) {
|
|||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(message, &serverMessage)
|
||||
err = json.Unmarshal(message, &shared.ServerMessage)
|
||||
if err != nil {
|
||||
log.Error("Error unmarshalling!", "reason", err)
|
||||
continue
|
||||
}
|
||||
|
||||
notifications.DesktopNotifications(serverMessage)
|
||||
notifications.TerminalOutput(serverMessage)
|
||||
notifications.DesktopNotifications()
|
||||
notifications.TerminalOutput()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue