Revision: 26523
          http://sourceforge.net/p/bibdesk/svn/26523
Author:   hofman
Date:     2021-07-27 22:22:05 +0000 (Tue, 27 Jul 2021)
Log Message:
-----------
Set new shared groups directly on parent group, we can build the groups to 
remove when we build the new array of groups

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

Modified: trunk/bibdesk/BDSKGroupsArray.h
===================================================================
--- trunk/bibdesk/BDSKGroupsArray.h     2021-07-27 22:09:30 UTC (rev 26522)
+++ trunk/bibdesk/BDSKGroupsArray.h     2021-07-27 22:22:05 UTC (rev 26523)
@@ -73,8 +73,6 @@
 - (void)addCategoryParent:(BDSKCategoryParentGroup *)group;
 - (void)removeCategoryParent:(BDSKCategoryParentGroup *)group;
 
-- (void)setSharedGroups:(NSArray *)array;
-
 - (void)addChildGroup:(BDSKGroup *)group;
 - (void)removeChildGroup:(BDSKGroup *)group;
 

Modified: trunk/bibdesk/BDSKGroupsArray.m
===================================================================
--- trunk/bibdesk/BDSKGroupsArray.m     2021-07-27 22:09:30 UTC (rev 26522)
+++ trunk/bibdesk/BDSKGroupsArray.m     2021-07-27 22:22:05 UTC (rev 26523)
@@ -219,17 +219,6 @@
     [[self document] reloadParentGroup:parent];
 }
 
-- (void)setSharedGroups:(NSArray *)array{
-    NSMutableArray *removedGroups = [[self sharedGroups] mutableCopy];
-    [removedGroups removeObjectsInArray:array];
-    if ([removedGroups count])
-        [[NSNotificationCenter defaultCenter] 
postNotificationName:BDSKWillRemoveExternalGroupsNotification
-            object:[self document] userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:removedGroups, BDSKDocumentGroupsKey, nil]];
-    [removedGroups release];
-    [[self externalParent] setSharedGroups:array];
-    [[self document] reloadParentGroup:[self externalParent]];
-}
-
 - (void)addCategoryParent:(BDSKCategoryParentGroup *)group {
     [group setDocument:document];
     [groups addObject:group];

Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m  2021-07-27 22:09:30 UTC (rev 26522)
+++ trunk/bibdesk/BibDocument_Groups.m  2021-07-27 22:22:05 UTC (rev 26523)
@@ -334,7 +334,8 @@
 - (void)handleSharedGroupsChangedNotification:(NSNotification *)notification{
     NSMutableSet *clients = [[[BDSKSharingBrowser sharedBrowser] 
sharingClients] mutableCopy];
     NSMutableArray *sharedGroups = [[NSMutableArray alloc] init];
-    
+    NSMutableArray *groupsToRemove = [[NSMutableArray alloc] init];
+
     // get the groups to keep
     for (BDSKSharedGroup *group in [groups sharedGroups]) {
         BDSKSharingClient *client = [group client];
@@ -341,6 +342,8 @@
         if ([clients containsObject:client]) {
             [sharedGroups addObject:group];
             [clients removeObject:client];
+        } else {
+            [groupsToRemove addObject:group];
         }
     }
     // add grouos for remaining clients
@@ -349,10 +352,16 @@
         [sharedGroups addObject:group];
         [group release];
     }
+    [clients release];
     
-    [groups setSharedGroups:sharedGroups];
+    if ([groupsToRemove count])
+        [[NSNotificationCenter defaultCenter] 
postNotificationName:BDSKWillRemoveExternalGroupsNotification
+            object:self userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:groupsToRemove, BDSKDocumentGroupsKey, nil]];
     
-    [clients release];
+    [[groups externalParent] setSharedGroups:sharedGroups];
+    [self reloadParentGroup:[groups externalParent]];
+    
+    [groupsToRemove release];
     [sharedGroups release];
 }
 

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to