Fix several cases where the UI did not properly reflect model changes.
[enjoyable.git] / Classes / NJDevice.m
index b03898f..bf39251 100644 (file)
@@ -72,10 +72,17 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id parent) {
         _vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue];
         _productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)) intValue];
         self.children = InputsForElement(dev, self);
+        self.index = 1;
     }
     return self;
 }
 
+- (BOOL)isEqual:(id)object {
+    return [object isKindOfClass:NJDevice.class]
+        && [[(NJDevice *)object productName] isEqualToString:self.productName]
+        && [(NJDevice *)object index] == self.index;
+}
+
 - (NSString *)name {
     return [NSString stringWithFormat:@"%@ #%d", _productName, _index];
 }