forked from lint/TFDidThatSay
		
	Add helper method
This commit is contained in:
		@ -22,7 +22,7 @@ static CGFloat pushshiftRequestTimeoutValue;
 | 
			
		||||
		body = [[(CommentNode *)arg1 comment] body];
 | 
			
		||||
	} 
 | 
			
		||||
	
 | 
			
		||||
	if ((isTFDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
 | 
			
		||||
	if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:body isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
	
 | 
			
		||||
		CGSize refSize = [[self buttons][0] frame].size;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ id tfAntennaCommentCell;
 | 
			
		||||
	
 | 
			
		||||
	NSString *commentBody = [[[arg1 comment] commentText] body];
 | 
			
		||||
	
 | 
			
		||||
	if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
	if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
		tfAntennaController = self;
 | 
			
		||||
		tfAntennaCommentCell = arg1;
 | 
			
		||||
		shouldHaveAntennaUndeleteAction = YES;
 | 
			
		||||
@ -115,7 +115,7 @@ id tfAntennaCommentCell;
 | 
			
		||||
	NSString *postBody = [[post selfCommentText] body];
 | 
			
		||||
	
 | 
			
		||||
	if ([post isSelfPost]){
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
			isAbleToUndeletePost = YES;
 | 
			
		||||
			
 | 
			
		||||
			NSMutableArray *barButtons = [self defaultHeaderButtons];
 | 
			
		||||
 | 
			
		||||
@ -44,7 +44,7 @@ NSDictionary* apolloBodyAttributes = nil;
 | 
			
		||||
	
 | 
			
		||||
	id commentBody = [MSHookIvar<id>(self, "comment") body];
 | 
			
		||||
	
 | 
			
		||||
	if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
 | 
			
		||||
	if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
	
 | 
			
		||||
		CGFloat imageSize = 20.0f;
 | 
			
		||||
 | 
			
		||||
@ -126,7 +126,7 @@ NSDictionary* apolloBodyAttributes = nil;
 | 
			
		||||
	id postBody = [post selfText];
 | 
			
		||||
 | 
			
		||||
	if ([post isSelfPost]){
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
 | 
			
		||||
			CGFloat imageSize = 20.0f;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -94,7 +94,7 @@ id tfStoryController;
 | 
			
		||||
	
 | 
			
		||||
	NSString *commentBody = [[arg1 comment] body];
 | 
			
		||||
	
 | 
			
		||||
	if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
 | 
			
		||||
	if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
		shouldHaveBRUndeleteAction = YES;
 | 
			
		||||
		tfCommentCellView = arg1;
 | 
			
		||||
		tfStoryController = self;
 | 
			
		||||
@ -111,7 +111,7 @@ id tfStoryController;
 | 
			
		||||
	if ([[self story] is_selfValue]){
 | 
			
		||||
		NSString *postBody = [[self story] selftext];
 | 
			
		||||
		
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
			shouldHaveBRUndeleteAction = YES;
 | 
			
		||||
			tfCommentCellView = nil;
 | 
			
		||||
			tfStoryController = self;
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ static CGFloat pushshiftRequestTimeoutValue;
 | 
			
		||||
		
 | 
			
		||||
		NSString *commentBody = [[self comment] content];
 | 
			
		||||
	
 | 
			
		||||
		if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
			
 | 
			
		||||
			CGFloat authorTextHeight = [[self authorButton] frame].size.height;
 | 
			
		||||
			
 | 
			
		||||
@ -114,7 +114,7 @@ static CGFloat pushshiftRequestTimeoutValue;
 | 
			
		||||
		
 | 
			
		||||
		NSString *postBody = [[self post] content];
 | 
			
		||||
		
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
		
 | 
			
		||||
			id moreButton = MSHookIvar<id>(self, "moreButton");
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
@ -49,7 +49,7 @@ void getUndeleteCommentData(id controller, id comment){
 | 
			
		||||
			
 | 
			
		||||
			NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
 | 
			
		||||
			
 | 
			
		||||
			if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
			if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
				tfComment = [arg1 comment];
 | 
			
		||||
				tfController = self;
 | 
			
		||||
				shouldHaveUndeleteAction = YES;
 | 
			
		||||
@ -68,7 +68,7 @@ void getUndeleteCommentData(id controller, id comment){
 | 
			
		||||
		
 | 
			
		||||
		NSString *postBody = [[self link] selfText];
 | 
			
		||||
		
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
			tfController = self;
 | 
			
		||||
			tfComment = nil;
 | 
			
		||||
			shouldHaveUndeleteAction = YES;
 | 
			
		||||
@ -127,7 +127,7 @@ void getUndeleteCommentData(id controller, id comment){
 | 
			
		||||
			
 | 
			
		||||
			NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
 | 
			
		||||
			
 | 
			
		||||
			if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
			if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
				tfComment = [arg1 comment];
 | 
			
		||||
				tfController = self;
 | 
			
		||||
				shouldHaveUndeleteAction = YES;
 | 
			
		||||
 | 
			
		||||
@ -66,7 +66,7 @@ int getRedditVersionPart(int index){
 | 
			
		||||
	
 | 
			
		||||
	NSString *commentBody = [[self comment] bodyText];
 | 
			
		||||
	
 | 
			
		||||
	if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
	if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
 | 
			
		||||
		UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
 | 
			
		||||
 | 
			
		||||
@ -193,7 +193,7 @@ int getRedditVersionPart(int index){
 | 
			
		||||
	NSString *postBody = [post selfText];
 | 
			
		||||
	
 | 
			
		||||
	if ([post isSelfPost]){
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
 | 
			
		||||
			UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
 | 
			
		||||
 | 
			
		||||
@ -334,7 +334,7 @@ int getRedditVersionPart(int index){
 | 
			
		||||
	
 | 
			
		||||
	NSString *commentBody = [[self comment] bodyText];
 | 
			
		||||
	
 | 
			
		||||
	if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
	if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
 | 
			
		||||
		UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
 | 
			
		||||
 | 
			
		||||
@ -419,7 +419,7 @@ int getRedditVersionPart(int index){
 | 
			
		||||
	NSString *postBody = [post selfText];
 | 
			
		||||
	
 | 
			
		||||
	if ([post isSelfPost]){
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
 | 
			
		||||
			UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -264,9 +264,9 @@ static UIButton *createUndeleteButton(){
 | 
			
		||||
%new 
 | 
			
		||||
-(void) addUndeleteButtonToMenu{
 | 
			
		||||
	
 | 
			
		||||
	NSString *body = [MSHookIvar<id>(self, "comment") body];
 | 
			
		||||
	
 | 
			
		||||
	if ((isTFDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
	NSString *commentBody = [MSHookIvar<id>(self, "comment") body];
 | 
			
		||||
 | 
			
		||||
	if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
	
 | 
			
		||||
		id controller = MSHookIvar<id>(self, "parent");
 | 
			
		||||
		
 | 
			
		||||
@ -465,7 +465,7 @@ static UIButton *createUndeleteButton(){
 | 
			
		||||
		
 | 
			
		||||
		NSString *postBody = [post body];
 | 
			
		||||
		
 | 
			
		||||
		if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
 | 
			
		||||
		if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
 | 
			
		||||
			return YES;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -2,5 +2,6 @@
 | 
			
		||||
@interface TFHelper : NSObject
 | 
			
		||||
 | 
			
		||||
+(void) getUndeleteDataWithID:(NSString *) ident isComment:(BOOL) isComment timeout:(CGFloat) timeout extraData:(NSDictionary *) extra completionTarget:(id) target completionSelector:(SEL) sel;
 | 
			
		||||
+(BOOL) shouldShowUndeleteButtonWithInfo:(NSString *) content isDeletedOnly:(BOOL) isDeletedOnly;
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
 | 
			
		||||
@ -47,4 +47,19 @@
 | 
			
		||||
	}];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
+(BOOL) shouldShowUndeleteButtonWithInfo:(NSString *) content isDeletedOnly:(BOOL) isDeletedOnly{
 | 
			
		||||
	
 | 
			
		||||
	if (!isDeletedOnly){
 | 
			
		||||
		return YES;
 | 
			
		||||
	} else {
 | 
			
		||||
		if ([content isEqualToString:@"[deleted]"] || [content isEqualToString:@"[removed]"]){
 | 
			
		||||
			return YES;
 | 
			
		||||
		} else if ([content hasPrefix:@"[pushshift"] || [content hasPrefix:@"[an error occured"]){
 | 
			
		||||
			return YES;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	return NO;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user