feat: refactor shared.Message to a channel
- remove `shared` package and shared.Message - rename `notifications` package to `frontend` - introduce a channel send the received ServerMessages to the frontend handler(s) - move keyhandler to goroutine - simplify password handling in Start function - update import names when importing from GoTomoto
This commit is contained in:
parent
cc24dd6775
commit
bbc9977f1c
10 changed files with 108 additions and 82 deletions
|
@ -2,12 +2,12 @@ package websocket
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
func sendClientCommand(conn *websocket.Conn, msg models.ClientCommand) {
|
||||
func sendClientCommand(conn *websocket.Conn, msg GoTomato.ClientCommand) {
|
||||
messageBytes, err := json.Marshal(msg)
|
||||
|
||||
if err != nil {
|
||||
|
@ -23,7 +23,7 @@ func sendClientCommand(conn *websocket.Conn, msg models.ClientCommand) {
|
|||
}
|
||||
|
||||
func SendCmd(conn *websocket.Conn, pwd string, cmd string) {
|
||||
message := models.ClientCommand{
|
||||
message := GoTomato.ClientCommand{
|
||||
Command: cmd,
|
||||
Password: pwd,
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ func SendCmd(conn *websocket.Conn, pwd string, cmd string) {
|
|||
sendClientCommand(conn, message)
|
||||
}
|
||||
|
||||
func Send_updateSettings(conn *websocket.Conn, pwd string, settings models.GoTomatoPomodoroConfig) {
|
||||
message := models.ClientCommand{
|
||||
func Send_updateSettings(conn *websocket.Conn, pwd string, settings GoTomato.GoTomatoPomodoroConfig) {
|
||||
message := GoTomato.ClientCommand{
|
||||
Command: "updateSettings",
|
||||
Password: pwd,
|
||||
PomodoroSettings: settings,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue