mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-16 16:20:59 +00:00
fix(node): stop the offline-sync toast firing on saves to online nodes
IsNodePending fed the user-facing "saved locally, node offline, will sync on reconnect" toast off three conditions, one of which was the node's config_dirty flag. But every node-backed client/inbound edit marks the node dirty unconditionally inside its write transaction — it is the reconcile self-heal marker, set even for edits pushed live to a healthy online node. The controller reads that freshly-set flag right after the save, so the warning fired on every save to a node-backed inbound regardless of the node actually being online. Drop the dirty term so the predicate reflects only what the message claims: the node being unreachable (offline or disabled). Offline and disabled nodes still mark dirty and still surface the toast. Add regression tests: online+dirty must not be pending; offline and disabled must be.
This commit is contained in:
@@ -780,12 +780,19 @@ func (s *NodeService) NodeSyncState(id int) (enabled bool, status string, dirty
|
||||
return row.Enable, row.Status, row.ConfigDirty, row.ConfigDirtyAt, nil
|
||||
}
|
||||
|
||||
// IsNodePending reports whether a save targeting this node was deferred because
|
||||
// the node is unreachable right now — offline or disabled — so the edit only
|
||||
// reaches it on the next reconcile. It deliberately ignores config_dirty: that
|
||||
// flag is set on EVERY node-backed edit as the reconcile self-heal marker,
|
||||
// including edits pushed live to an online node, so keying the user-facing
|
||||
// "saved, node offline, will sync" toast off it fired the warning on every save
|
||||
// to a perfectly healthy online node.
|
||||
func (s *NodeService) IsNodePending(id int) bool {
|
||||
enabled, status, dirty, _, err := s.NodeSyncState(id)
|
||||
enabled, status, _, _, err := s.NodeSyncState(id)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return !enabled || status != "online" || dirty
|
||||
return !enabled || status != "online"
|
||||
}
|
||||
|
||||
func nodeMetricKey(id int, metric string) string {
|
||||
|
||||
Reference in New Issue
Block a user