2024-10-27 09:41:31 +00:00
|
|
|
package frontend
|
|
|
|
|
|
|
|
import (
|
2024-10-29 19:13:39 +00:00
|
|
|
"github.com/eiannone/keyboard"
|
|
|
|
|
|
|
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/websocket"
|
2024-10-27 20:34:53 +00:00
|
|
|
|
2024-10-27 09:41:31 +00:00
|
|
|
ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models"
|
|
|
|
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
|
|
|
)
|
|
|
|
|
2024-10-30 07:54:58 +00:00
|
|
|
func UpdateLoop(client websocket.Client, config ChronoTomato.Config, channel <-chan GoTomato.ServerMessage) {
|
2024-10-27 20:47:05 +00:00
|
|
|
var message GoTomato.ServerMessage
|
|
|
|
|
2024-10-29 19:13:39 +00:00
|
|
|
keysEvents, _ := keyboard.GetKeys(1)
|
|
|
|
defer keyboard.Close()
|
2024-10-27 09:41:31 +00:00
|
|
|
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case message = <-channel:
|
|
|
|
desktopNotifications(message)
|
|
|
|
terminalOutput(message)
|
2024-10-29 19:13:39 +00:00
|
|
|
case keypress := <-keysEvents:
|
2024-10-30 07:28:22 +00:00
|
|
|
if !keyhandler(keypress, client, config, message) {
|
2024-10-29 19:13:39 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
case <-websocket.Done:
|
2024-10-27 09:41:31 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|