Simplify default and support custom notifications for nodes.
[pithos-macos] / pithos-macos / PithosContainerNode.m
index 47d9a07..b061899 100644 (file)
@@ -67,7 +67,6 @@ static NSImage *sharedIcon = nil;
         self.pithosContainer = aPithosContainer;
         prefix = nil;
         self.icon = anIcon;
-        self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosContainerNodeChildrenUpdated"];
     }
     return self;
 }
@@ -294,6 +293,7 @@ static NSImage *sharedIcon = nil;
                                 node.parent = self;
                                 node.shared = shared;
                                 node.sharingAccount = sharingAccount;
+                                node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
                                 if (children) {
                                     NSUInteger oldIndex = [children indexOfObject:node];
                                     if (oldIndex != NSNotFound) {
@@ -316,6 +316,7 @@ static NSImage *sharedIcon = nil;
                             node.parent = self;
                             node.shared = shared;
                             node.sharingAccount = sharingAccount;
+                            node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
                             if (children) {
                                 NSUInteger oldIndex = [children indexOfObject:node];
                                 if (oldIndex != NSNotFound) {
@@ -335,6 +336,7 @@ static NSImage *sharedIcon = nil;
                             node.parent = self;
                             node.shared = shared;
                             node.sharingAccount = sharingAccount;
+                            node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
                             if (children) {
                                 NSUInteger oldIndex = [children indexOfObject:node];
                                 if (oldIndex != NSNotFound) {
@@ -366,10 +368,7 @@ static NSImage *sharedIcon = nil;
             @synchronized(self) {
                 freshness = PithosNodeStateRefreshFinished;
             }
-            if (childrenUpdatedNotificationName) {
-                // Notify observers that children are updated
-                [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
-            }
+            [self postChildrenUpdatedNotificationName];
         } else {
             [containerRequest release];
             // Do an additional request to fetch more objects
@@ -408,10 +407,7 @@ static NSImage *sharedIcon = nil;
         @synchronized(self) {
             freshness = PithosNodeStateRefreshFinished;
         }
-        if (childrenUpdatedNotificationName) {
-            // Notify observers that children are updated
-            [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
-        }
+        [self postChildrenUpdatedNotificationName];
     } else {
         [self containerRequestFailed:containerRequest];
     }