remo superfluous structs from keyboard api.

This commit is contained in:
Miroslav Šedivý 2024-05-03 22:41:42 +02:00
parent b90eb87c22
commit d47302e2cd

View File

@ -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)
}
@ -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)
}