Revision: 21861
          http://sourceforge.net/p/bibdesk/svn/21861
Author:   hofman
Date:     2018-02-09 23:12:43 +0000 (Fri, 09 Feb 2018)
Log Message:
-----------
simplify updating shared groups

Modified Paths:
--------------
    trunk/bibdesk/BibDocument_Groups.m

Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m  2018-02-09 22:47:30 UTC (rev 21860)
+++ trunk/bibdesk/BibDocument_Groups.m  2018-02-09 23:12:43 UTC (rev 21861)
@@ -338,28 +338,28 @@
     [groupOutlineView setDelegate:nil];
        NSArray *selectedGroups = [self selectedGroups];
        
-    NSMutableSet *clientsToAdd = [[[BDSKSharingBrowser sharedBrowser] 
sharingClients] mutableCopy];
-    NSMutableArray *currentGroups = [[groups sharedGroups] mutableCopy];
-    NSArray *currentClients = [currentGroups valueForKey:@"client"];
-    NSSet *currentClientsSet = [NSSet setWithArray:currentClients];
-    NSMutableSet *clientsToRemove = [currentClientsSet mutableCopy];
+    NSMutableSet *clients = [[[BDSKSharingBrowser sharedBrowser] 
sharingClients] mutableCopy];
+    NSMutableArray *sharedGroups = [[NSMutableArray alloc] init];
     
-    [clientsToRemove minusSet:clientsToAdd];
-    [clientsToAdd minusSet:currentClientsSet];
-    
-    [currentGroups removeObjectsAtIndexes:[currentClients 
indexesOfObjects:[clientsToRemove allObjects]]];
-    
-    for (BDSKSharingClient *client in clientsToAdd) {
+    // get the groups to keep
+    for (BDSKSharedGroup *group in [groups sharedGroups]) {
+        BDSKSharingClient *client = [group client];
+        if ([clients containsObject:client]) {
+            [sharedGroups addObject:group];
+            [clients removeObject:client];
+        }
+    }
+    // add grouos for remaining clients
+    for (BDSKSharingClient *client in clients) {
         BDSKSharedGroup *group = [(BDSKSharedGroup *)[BDSKSharedGroup alloc] 
initWithClient:client];
-        [currentGroups addObject:group];
+        [sharedGroups addObject:group];
         [group release];
     }
     
-    [groups setSharedGroups:currentGroups];
+    [groups setSharedGroups:sharedGroups];
     
-    [clientsToRemove release];
-    [clientsToAdd release];
-    [currentGroups release];
+    [clients release];
+    [sharedGroups release];
     
     [self removeSpinnersFromSuperview];
     [groupOutlineView reloadData];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to