Skip to content

Commit

Permalink
refactor: prepare for force radio discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNotGoodName committed Apr 26, 2022
1 parent 64b54ef commit def3cb9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/radio/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewHubService(createService CreateService) *HubServiceImpl {
}
}

func (hs *HubServiceImpl) Discover() (int, error) {
func (hs *HubServiceImpl) Discover(force bool) (int, error) {
resC := make(chan discoverResponse)
select {
case hs.discoverC <- resC:
Expand Down
2 changes: 1 addition & 1 deletion core/radio/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type (
HubService interface {
Discover() (int, error)
Discover(force bool) (int, error)
Get(uuid string) (Radio, error)
List() []Radio
}
Expand Down
5 changes: 4 additions & 1 deletion left/api/radio.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"log"
"net/http"
"strconv"

"github.com/ItsNotGoodName/reciva-web-remote/core"
"github.com/ItsNotGoodName/reciva-web-remote/core/radio"
Expand Down Expand Up @@ -67,8 +68,10 @@ func GetRadios(hub radio.HubService, radioService radio.RadioService) presenter.

func PostRadios(hub radio.HubService) presenter.Requester {
return func(r *http.Request) presenter.Response {
force, _ := strconv.ParseBool(r.URL.Query().Get("force"))

// Discover radios
count, err := hub.Discover()
count, err := hub.Discover(force)
if err != nil {
code := http.StatusInternalServerError
if err == core.ErrHubDiscovering {
Expand Down

0 comments on commit def3cb9

Please sign in to comment.