Permalink
Browse files

When replying to a repost, mention both the original poster and the r…

…eposter
  • Loading branch information...
brentdax committed Oct 19, 2012
1 parent fa36e58 commit 40deb82bcb333e6bf6715cea1d1b0da9efd5acc7
Showing with 23 additions and 19 deletions.
  1. +23 −19 ANPost.m
View
@@ -78,46 +78,50 @@ - (ANDraft*)draftCopy {
return draft;
}
-- (ANDraft*)draftReply {
- ANDraft * draft = [self.user draftMention];
+- (NSMutableOrderedSet*)mentionsForDirectReply {
+ NSMutableOrderedSet * mentions = self.repostOf ? [self.repostOf mentionsForDirectReply] : [NSMutableOrderedSet new];
- draft.replyTo = self.originalID;
+ [mentions addObject:self.user.username.appNetUsernameString];
- return draft;
+ return mentions;
}
-- (ANDraft*)draftReplyToAllExceptUser:(ANUser*)user {
- NSMutableOrderedSet * usernames = [NSMutableOrderedSet orderedSetWithObject:self.user.username.appNetUsernameString];
- for(ANEntity * mention in self.entities.mentions) {
- if(mention.userID != user.ID) {
- [usernames addObject:mention.name.appNetUsernameString];
- }
- }
-
+- (ANDraft*)draftReply {
ANDraft * draft = [ANDraft new];
- draft.text = [[usernames.array componentsJoinedByString:@" "] stringByAppendingString:@" "];
+ draft.text = [[self.mentionsForDirectReply.array componentsJoinedByString:@" "] stringByAppendingString:@" "];
draft.replyTo = self.originalID;
return draft;
}
-- (ANDraft*)draftReplyToAllExceptUsername:(NSString*)username {
- NSMutableOrderedSet * usernames = [NSMutableOrderedSet orderedSetWithObject:self.user.username.appNetUsernameString];
+- (ANDraft*)draftReplyToAllExcept:(BOOL (^)(ANEntity * mention))rejectionBlock {
+ ANDraft * draft = [self draftReply];
+
+ NSMutableOrderedSet * usernames = self.mentionsForDirectReply;
for(ANEntity * mention in self.entities.mentions) {
- if(![mention.name isEqualToString:username]) {
+ if(!rejectionBlock(mention)) {
[usernames addObject:mention.name.appNetUsernameString];
}
}
- ANDraft * draft = [ANDraft new];
-
draft.text = [[usernames.array componentsJoinedByString:@" "] stringByAppendingString:@" "];
- draft.replyTo = self.originalID;
return draft;
}
+- (ANDraft*)draftReplyToAllExceptUser:(ANUser*)user {
+ return [self draftReplyToAllExcept:^BOOL(ANEntity *mention) {
+ return mention.userID == user.ID;
+ }];
+}
+
+- (ANDraft*)draftReplyToAllExceptUsername:(NSString*)username {
+ return [self draftReplyToAllExcept:^BOOL(ANEntity *mention) {
+ return [mention.name isEqualToString:username];
+ }];
+}
+
- (void)postRepliedToWithCompletion:(ANPostRequestCompletion)completion {
[self.session postWithID:self.originalPost.replyTo completion:completion];
}

0 comments on commit 40deb82

Please sign in to comment.