Permalink
Browse files

Allow for removing groups from contact view

  • Loading branch information...
1 parent 307dc83 commit 01f5a4c0b4efa30f334caa1a99f2410e7ec3589c @benlangfeld committed Nov 8, 2010
Showing with 8 additions and 16 deletions.
  1. +1 −1 AppController.j
  2. +7 −15 Controllers/AccountsController.j
View
@@ -51,7 +51,7 @@
[plusButton setTarget:[AccountsController sharedController]];
[plusButton setAction:@selector(promptForNewContact:)];
[minusButton setTarget:[AccountsController sharedController]];
- [minusButton setAction:@selector(removeContact:)];
+ [minusButton setAction:@selector(rosterMinusWasClicked:)];
var manageAccountsItem = [[CPMenuItem alloc] initWithTitle:@"Manage Accounts" action:@selector(manageAccounts:) keyEquivalent:nil];
[manageAccountsItem setTarget:[AccountsController sharedController]];
@@ -340,22 +340,14 @@ var SharedController = nil;
[controller showWindow:aSender];
}
-- (@action)removeContact:(id)aSender
+- (@action)rosterMinusWasClicked:(id)aSender
{
- CPLog.debug("Removing a contact");
- var contact = [self selectedItem];
- if ([contact isKindOfClass:[TNStropheContact class]])
- [[[self accountForContact:contact] roster] removeContact:contact];
-}
-
-- (Account)accountForContact:(TNStropheContact)aContact
-{
- for (var i = 0; i < [accounts count]; i++)
- {
- var account = [accounts objectAtIndex:i];
- if ([[account roster] containsJID:[aContact JID]])
- return account;
- }
+ CPLog.debug("Removing something!");
+ var selected = [self selectedItem];
+ if ([selected isKindOfClass:[TNStropheContact class]])
+ [[[rosterView parentForItem:[rosterView parentForItem:selected]] roster] removeContact:selected];
+ else if ([selected isKindOfClass:[TNStropheGroup class]])
+ [[[rosterView parentForItem:selected] roster] removeGroup:selected];
}

0 comments on commit 01f5a4c

Please sign in to comment.