From 3a63c563bb9980f9a8faf17b6ad77246ded209cf Mon Sep 17 00:00:00 2001 From: Philip Witty Date: Tue, 12 Oct 2021 20:54:49 +0200 Subject: [PATCH 1/2] delete unreachable code --- here_now_request.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/here_now_request.go b/here_now_request.go index 90970654..1751dd6e 100644 --- a/here_now_request.go +++ b/here_now_request.go @@ -269,18 +269,6 @@ func newHereNowResponse(jsonBytes []byte, channelNames []string, resp.Channels = channels - return resp, status, nil - } else if len(val) == 1 { - resp.TotalChannels = 1 - - if totalOcc, ok := parsedPayload["total_occupancy"].(float64); ok { - resp.TotalOccupancy = int(totalOcc) - } - - resp.Channels = append(resp.Channels, HereNowChannelData{ - channelNames[0], 1, []HereNowOccupantsData{}, - }) - return resp, status, nil } else { if totalCh, ok := parsedValue["total_channels"].(float64); ok { From fd4eb25c6addd6c744b2b7e5bf3de59cda141177 Mon Sep 17 00:00:00 2001 From: Philip Witty Date: Tue, 12 Oct 2021 20:56:38 +0200 Subject: [PATCH 2/2] clean up some duplication --- here_now_request.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/here_now_request.go b/here_now_request.go index 1751dd6e..035796e6 100644 --- a/here_now_request.go +++ b/here_now_request.go @@ -374,27 +374,19 @@ func parseChannelData(channelName string, rawData interface{}) HereNowChannelDat for _, user := range parsedUUIDs { if u, ok := user.(map[string]interface{}); ok { if len(u) > 0 { - if _, ok := u["state"]; ok { - occData := HereNowOccupantsData{} + occData := HereNowOccupantsData{} - if uuid, ok := u["uuid"].(string); ok { - occData.UUID = uuid - } + if uuid, ok := u["uuid"].(string); ok { + occData.UUID = uuid + } + if _, ok := u["state"]; ok { if state, ok := u["state"].(map[string]interface{}); ok { occData.State = state } - - occupants = append(occupants, occData) - } else { - occData := HereNowOccupantsData{} - - if uuid, ok := u["uuid"].(string); ok { - occData.UUID = uuid - } - - occupants = append(occupants, occData) } + + occupants = append(occupants, occData) } } else { empty := make(map[string]interface{})