Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
remo superfluous structs from keyboard api.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed May 3, 2024
1 parent b90eb87 commit d47302e
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions internal/api/room/keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ import (
"github.com/demodesk/neko/pkg/utils"
)

type KeyboardMapData struct {
types.KeyboardMap
}

type KeyboardModifiersData struct {
types.KeyboardModifiers
}

func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) error {
data := &KeyboardMapData{}
if err := utils.HttpJsonRequest(w, r, data); err != nil {
keyboardMap := types.KeyboardMap{}
if err := utils.HttpJsonRequest(w, r, &keyboardMap); err != nil {
return err
}

err := h.desktop.SetKeyboardMap(data.KeyboardMap)
err := h.desktop.SetKeyboardMap(keyboardMap)
if err != nil {
return utils.HttpInternalServerError().WithInternalErr(err)
}
Expand All @@ -30,28 +22,26 @@ func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) err
}

func (h *RoomHandler) keyboardMapGet(w http.ResponseWriter, r *http.Request) error {
data, err := h.desktop.GetKeyboardMap()
keyboardMap, err := h.desktop.GetKeyboardMap()
if err != nil {
return utils.HttpInternalServerError().WithInternalErr(err)
}

return utils.HttpSuccess(w, KeyboardMapData{
KeyboardMap: *data,
})
return utils.HttpSuccess(w, keyboardMap)
}

func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) error {
data := &KeyboardModifiersData{}
if err := utils.HttpJsonRequest(w, r, data); err != nil {
keyboardModifiers := types.KeyboardModifiers{}
if err := utils.HttpJsonRequest(w, r, &keyboardModifiers); err != nil {
return err
}

h.desktop.SetKeyboardModifiers(data.KeyboardModifiers)
h.desktop.SetKeyboardModifiers(keyboardModifiers)
return utils.HttpSuccess(w)
}

func (h *RoomHandler) keyboardModifiersGet(w http.ResponseWriter, r *http.Request) error {
return utils.HttpSuccess(w, KeyboardModifiersData{
KeyboardModifiers: h.desktop.GetKeyboardModifiers(),
})
keyboardModifiers := h.desktop.GetKeyboardModifiers()

return utils.HttpSuccess(w, keyboardModifiers)
}

0 comments on commit d47302e

Please sign in to comment.