make watch item removal more instant
This commit is contained in:
parent
e4cce0b093
commit
22b5492f43
10
app.go
10
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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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"`
|
||||
|
Loading…
Reference in New Issue
Block a user