mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Do not notify when a device's vendor is first deduced
Treat an empty->non-empty vendor transition as not a change, so first deducing a vendor for a device that previously had none no longer raises a "vendor changed" notification. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
561fbdb548
commit
ef420ad360
@@ -26,9 +26,10 @@ fn display_name(device: &Device) -> &str {
|
||||
|
||||
// Whether a re-sighting represents a real vendor change. A scanner that cannot deduce a vendor
|
||||
// reports an empty string; that is not a change (db::devices::update keeps the known vendor), so
|
||||
// it must not raise a "vendor changed" notification either.
|
||||
// it must not raise a "vendor changed" notification either. Likewise, first deducing a vendor for a
|
||||
// device that previously had none is not a change worth notifying about.
|
||||
fn vendor_changed(existing: &str, new: &str) -> bool {
|
||||
!new.is_empty() && existing != new
|
||||
!existing.is_empty() && !new.is_empty() && existing != new
|
||||
}
|
||||
|
||||
// Private helper function to deliver messages
|
||||
@@ -216,7 +217,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newly_deduced_vendor_from_empty_is_a_change() {
|
||||
assert!(vendor_changed("", "Apple, Inc."));
|
||||
fn newly_deduced_vendor_from_empty_is_not_a_change() {
|
||||
assert!(!vendor_changed("", "Apple, Inc."));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user