Avoid warnings in ui package
Remove unused variables and improve JSON decoding in saveEnclosureProgression()
This commit is contained in:
parent
309fdbb9fc
commit
f6f63b5282
2 changed files with 8 additions and 17 deletions
|
@ -4,8 +4,7 @@
|
|||
package ui // import "miniflux.app/v2/internal/ui"
|
||||
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
"io"
|
||||
json_parser "encoding/json"
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/v2/internal/http/request"
|
||||
|
@ -30,21 +29,13 @@ func (h *handler) saveEnclosureProgression(w http.ResponseWriter, r *http.Reques
|
|||
}
|
||||
|
||||
var postData enclosurePositionSaveRequest
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
json2.Unmarshal(body, &postData)
|
||||
if err != nil {
|
||||
if err := json_parser.NewDecoder(r.Body).Decode(&postData); err != nil {
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
enclosure.MediaProgression = postData.Progression
|
||||
|
||||
err = h.store.UpdateEnclosure(enclosure)
|
||||
if err != nil {
|
||||
if err := h.store.UpdateEnclosure(enclosure); err != nil {
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func (u WebAuthnUser) WebAuthnCredentials() []webauthn.Credential {
|
|||
return creds
|
||||
}
|
||||
|
||||
func newWebAuthn(h *handler) (*webauthn.WebAuthn, error) {
|
||||
func newWebAuthn() (*webauthn.WebAuthn, error) {
|
||||
url, err := url.Parse(config.Opts.BaseURL())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -70,7 +70,7 @@ func newWebAuthn(h *handler) (*webauthn.WebAuthn, error) {
|
|||
}
|
||||
|
||||
func (h *handler) beginRegistration(w http.ResponseWriter, r *http.Request) {
|
||||
web, err := newWebAuthn(h)
|
||||
web, err := newWebAuthn()
|
||||
if err != nil {
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
|
@ -117,7 +117,7 @@ func (h *handler) beginRegistration(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (h *handler) finishRegistration(w http.ResponseWriter, r *http.Request) {
|
||||
web, err := newWebAuthn(h)
|
||||
web, err := newWebAuthn()
|
||||
if err != nil {
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
|
@ -152,7 +152,7 @@ func (h *handler) finishRegistration(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (h *handler) beginLogin(w http.ResponseWriter, r *http.Request) {
|
||||
web, err := newWebAuthn(h)
|
||||
web, err := newWebAuthn()
|
||||
if err != nil {
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
|
@ -195,7 +195,7 @@ func (h *handler) beginLogin(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (h *handler) finishLogin(w http.ResponseWriter, r *http.Request) {
|
||||
web, err := newWebAuthn(h)
|
||||
web, err := newWebAuthn()
|
||||
if err != nil {
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue