Correctly update document state when group selection has changed

This commit is contained in:
Michael Starke
2018-11-14 10:28:59 +01:00
parent dc67de1ed1
commit b9de0fb2dd

View File

@@ -310,7 +310,15 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
- (void)outlineViewSelectionDidChange:(NSNotification *)notification {
MPDocument *document = self.windowController.document;
NSArray<KPKGroup *> *groups = [self currentTargetGroups];
/* only update state if binding is set up to prevent resetting on first show */
if(_bindingEstablished) {
NSUUID *oldValue = document.tree.metaData.lastSelectedGroup;
document.tree.metaData.lastSelectedGroup = (groups.count == 1 ? groups.firstObject.uuid : [NSUUID kpk_nullUUID]);
NSUUID *newVlaue = document.tree.metaData.lastSelectedGroup;
if(![oldValue isEqual:newVlaue]) {
[document updateChangeCount:NSChangeDone|NSChangeDiscardable];
}
}
document.selectedGroups = groups;
}