Fix several cases where the UI did not properly reflect model changes.
[enjoyable.git] / Classes / NJDeviceViewController.m
index f9ff141..5d0bf6a 100644 (file)
     [self expandRecursive:[self.delegate deviceViewController:self elementForUID:uid]];
 }
 
+- (void)beginUpdates {
+    [self.inputsTree beginUpdates];
+}
+
+- (void)endUpdates {
+    [self.inputsTree endUpdates];
+}
+
 - (void)reexpandAll {
     for (NSString *uid in [_expanded copy])
         [self expandRecursiveByUID:uid];
 }
 
 - (void)addedDevice:(NJDevice *)device atIndex:(NSUInteger)idx {
-    [self.inputsTree beginUpdates];
     [self.inputsTree insertItemsAtIndexes:[[NSIndexSet alloc] initWithIndex:idx]
                                   inParent:nil
                              withAnimation:NSTableViewAnimationEffectFade];
     [self reexpandAll];
-    [self.inputsTree endUpdates];
     self.noDevicesNotice.hidden = YES;
 }
 
 - (void)removedDevice:(NJDevice *)device atIndex:(NSUInteger)idx {
     BOOL anyDevices = !![self.delegate numberOfDevicesInDeviceList:self];
-    [self.inputsTree beginUpdates];
     [self.inputsTree removeItemsAtIndexes:[[NSIndexSet alloc] initWithIndex:idx]
                                   inParent:nil
                              withAnimation:NSTableViewAnimationEffectFade];
-    [self.inputsTree endUpdates];
     self.noDevicesNotice.hidden = anyDevices || !self.hidStoppedNotice.isHidden;
 }