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