mirror of
https://github.com/sartoopjj/thefeed.git
synced 2026-05-19 10:04:36 +03:00
fix: ensure active resolver lists are updated correctly and broadcast changes to the UI
This commit is contained in:
@@ -315,12 +315,18 @@ func (s *Server) handleScannerApply(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := s.fetcherCtx
|
||||
s.mu.RUnlock()
|
||||
if fetcher != nil {
|
||||
// Pin pool to the list, active to the just-scanned set
|
||||
// (already verified by the scanner — no re-probe needed).
|
||||
// Pool AND active are the full saved list, not just the
|
||||
// freshly-scanned subset — append mode merges the new
|
||||
// resolvers into pre-existing list entries, and the user
|
||||
// expects all of them live (otherwise the Active panel
|
||||
// shows N while the tab badge shows N+M, which looks
|
||||
// like the apply lost the old ones).
|
||||
if target != nil && len(target.Resolvers) > 0 {
|
||||
fetcher.UpdateResolverPool(target.Resolvers)
|
||||
fetcher.SetActiveResolvers(target.Resolvers)
|
||||
} else {
|
||||
fetcher.SetActiveResolvers(resolvers)
|
||||
}
|
||||
fetcher.SetActiveResolvers(resolvers)
|
||||
s.saveLastScan(resolvers)
|
||||
}
|
||||
if checker != nil && ctx != nil {
|
||||
|
||||
+11
-3
@@ -1740,23 +1740,29 @@ func (s *Server) handleRemoveResolver(w http.ResponseWriter, r *http.Request) {
|
||||
// re-applies the on-disk list verbatim. Scope is intentionally narrow:
|
||||
// only the active list is touched — the bank and other named lists
|
||||
// keep the resolver until the user removes it from the bank.
|
||||
listChanged := false
|
||||
if pl, err := s.loadProfiles(); err == nil && pl != nil {
|
||||
if list := findList(pl, pl.SelectedList); list != nil {
|
||||
out := list.Resolvers[:0]
|
||||
changed := false
|
||||
for _, r := range list.Resolvers {
|
||||
if r == req.Addr {
|
||||
changed = true
|
||||
listChanged = true
|
||||
continue
|
||||
}
|
||||
out = append(out, r)
|
||||
}
|
||||
if changed {
|
||||
if listChanged {
|
||||
list.Resolvers = out
|
||||
_ = s.saveProfiles(pl)
|
||||
}
|
||||
}
|
||||
}
|
||||
if listChanged {
|
||||
// Push tab counts to any open Resolver Bank modal — without
|
||||
// this, the badge stays at the old count until the user
|
||||
// switches lists.
|
||||
s.broadcast("event: update\ndata: \"resolver-lists\"\n\n")
|
||||
}
|
||||
writeJSON(w, map[string]any{"ok": true})
|
||||
}
|
||||
|
||||
@@ -1931,6 +1937,7 @@ func (s *Server) handleResolverBank(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
s.broadcast("event: update\ndata: \"resolver-lists\"\n\n")
|
||||
writeJSON(w, map[string]any{"ok": true, "removed": removed, "remaining": len(pl.ResolverBank)})
|
||||
|
||||
default:
|
||||
@@ -2054,6 +2061,7 @@ func (s *Server) handleResolverBankCleanup(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
}
|
||||
}
|
||||
s.broadcast("event: update\ndata: \"resolver-lists\"\n\n")
|
||||
writeJSON(w, map[string]any{"ok": true, "removed": removed, "remaining": len(filtered)})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user