diff --git a/app.go b/app.go index 0b2a085..9fa7113 100644 --- a/app.go +++ b/app.go @@ -41,3 +41,13 @@ func (a *App) getOwner(r *http.Request) (*tailcfg.Node, error) { return who.Node, nil } + +func (a *App) removeWatch(id int) { + newWatches := WatchResults{} + for _, w := range *a.watches { + if w.ID != int64(id) { + newWatches = append(newWatches, w) + } + } + a.watches = &newWatches +} diff --git a/handlers.go b/handlers.go index 334863d..a5ce186 100644 --- a/handlers.go +++ b/handlers.go @@ -147,6 +147,7 @@ func watchitemDELETE(w http.ResponseWriter, r *http.Request) { if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } + app.removeWatch(watchID) } func watchitemPOST(w http.ResponseWriter, r *http.Request) { diff --git a/watches.go b/watches.go index be79e29..76b44d3 100644 --- a/watches.go +++ b/watches.go @@ -133,6 +133,7 @@ func UpdateWatches(ghToken string) (*WatchResults, error) { wr.OwnerID = watch.OwnerID wr.Name = watch.Name wr.Repo = watch.Repo + wr.ID = watch.ID for _, dr := range wr.Data.Search.Edges { wr.Results = append(wr.Results, dr.Node) } @@ -150,6 +151,7 @@ func UpdateWatches(ghToken string) (*WatchResults, error) { } type WatchResult struct { + ID int64 `json:"id"` Data Data `json:"data"` OwnerID int64 `json:"owner_id"` Name string `json:"name"`