mirror of
https://github.com/lint/TFDidThatSay
synced 2025-07-05 00:46:45 +00:00
Fix Apollo author labels
This commit is contained in:
@ -26,6 +26,9 @@
|
|||||||
@property(assign,nonatomic) NSString *author;
|
@property(assign,nonatomic) NSString *author;
|
||||||
@property(assign,nonatomic) NSString *fullName;
|
@property(assign,nonatomic) NSString *fullName;
|
||||||
-(BOOL) isSelfPost;
|
-(BOOL) isSelfPost;
|
||||||
|
|
||||||
|
//custom elements
|
||||||
|
@property(strong, nonatomic) NSString *undeleteAuthor;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CommentsHeaderCellNode
|
@interface CommentsHeaderCellNode
|
||||||
@ -68,10 +71,12 @@
|
|||||||
|
|
||||||
@interface ASTextNode
|
@interface ASTextNode
|
||||||
@property(assign,nonatomic) CGRect frame;
|
@property(assign,nonatomic) CGRect frame;
|
||||||
@property(assign,nonatomic) id attributedString;
|
@property(assign,nonatomic) NSAttributedString *attributedString;
|
||||||
@property(assign,nonatomic) id attributedText;
|
@property(assign,nonatomic) NSAttributedString *attributedText;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface ApolloButtonNode
|
@interface ApolloButtonNode
|
||||||
@property(assign,nonatomic) NSArray *subnodes;
|
@property(assign,nonatomic) ASTextNode *titleNode;
|
||||||
|
-(void) setAttributedTitle:(id) arg1 forState:(NSInteger) arg2;
|
||||||
|
-(id) attributedTitleForState:(NSInteger) arg1;
|
||||||
@end
|
@end
|
||||||
|
@ -33,6 +33,21 @@ id apolloCommentController;
|
|||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
|
%hook RKLink
|
||||||
|
%property(strong, nonatomic) NSString *undeleteAuthor;
|
||||||
|
|
||||||
|
-(id) author{
|
||||||
|
|
||||||
|
if ([self undeleteAuthor]){
|
||||||
|
return [self undeleteAuthor];
|
||||||
|
} else {
|
||||||
|
return %orig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%end
|
||||||
|
|
||||||
|
|
||||||
%hook MarkdownRenderer
|
%hook MarkdownRenderer
|
||||||
|
|
||||||
+(id) attributedStringFromHTML:(id)arg1 attributes:(id) arg2 compact:(BOOL) arg3{
|
+(id) attributedStringFromHTML:(id)arg1 attributes:(id) arg2 compact:(BOOL) arg3{
|
||||||
@ -123,7 +138,7 @@ id apolloCommentController;
|
|||||||
|
|
||||||
-(void) moreOptionsTappedWithSender:(id) arg1{
|
-(void) moreOptionsTappedWithSender:(id) arg1{
|
||||||
|
|
||||||
id commentBody = [MSHookIvar<id>(self, "comment") body];
|
NSString *commentBody = [MSHookIvar<RKComment *>(self, "comment") body];
|
||||||
|
|
||||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||||
shouldAddUndeleteCell = YES;
|
shouldAddUndeleteCell = YES;
|
||||||
@ -136,7 +151,7 @@ id apolloCommentController;
|
|||||||
|
|
||||||
-(void) longPressedWithGestureRecognizer:(id) arg1{
|
-(void) longPressedWithGestureRecognizer:(id) arg1{
|
||||||
|
|
||||||
id commentBody = [MSHookIvar<id>(self, "comment") body];
|
NSString *commentBody = [MSHookIvar<RKComment *>(self, "comment") body];
|
||||||
|
|
||||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||||
shouldAddUndeleteCell = YES;
|
shouldAddUndeleteCell = YES;
|
||||||
@ -150,7 +165,7 @@ id apolloCommentController;
|
|||||||
%new
|
%new
|
||||||
-(void) undeleteCellWasSelected{
|
-(void) undeleteCellWasSelected{
|
||||||
|
|
||||||
id comment = MSHookIvar<id>(self, "comment");
|
RKComment *comment = MSHookIvar<RKComment *>(self, "comment");
|
||||||
|
|
||||||
[%c(TFHelper) getUndeleteDataWithID:[[comment fullName] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
|
[%c(TFHelper) getUndeleteDataWithID:[[comment fullName] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
|
||||||
}
|
}
|
||||||
@ -158,25 +173,22 @@ id apolloCommentController;
|
|||||||
%new
|
%new
|
||||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||||
|
|
||||||
id comment = MSHookIvar<id>(self, "comment");
|
RKComment *comment = MSHookIvar<RKComment *>(self, "comment");
|
||||||
id bodyNode = MSHookIvar<id>(self, "bodyNode");
|
id bodyNode = MSHookIvar<id>(self, "bodyNode");
|
||||||
id authorNode = MSHookIvar<id>(self, "authorNode");
|
id authorNode = MSHookIvar<id>(self, "authorNode");
|
||||||
id authorTextNode = [authorNode subnodes][0];
|
|
||||||
|
|
||||||
NSString *author = data[@"author"];
|
NSString *author = data[@"author"];
|
||||||
NSString *body = data[@"body"];
|
NSString *body = data[@"body"];
|
||||||
|
|
||||||
id prevAuthorAttributedString = [authorTextNode attributedString];
|
[comment setAuthor:author];
|
||||||
|
[comment setBody:body];
|
||||||
|
|
||||||
|
NSAttributedString *prevAuthorAttributedString = [authorNode attributedTitleForState:UIControlStateNormal];
|
||||||
NSDictionary *authorStringAttributes = [prevAuthorAttributedString attributesAtIndex:0 longestEffectiveRange:nil inRange:NSMakeRange(0, [prevAuthorAttributedString length])];
|
NSDictionary *authorStringAttributes = [prevAuthorAttributedString attributesAtIndex:0 longestEffectiveRange:nil inRange:NSMakeRange(0, [prevAuthorAttributedString length])];
|
||||||
NSAttributedString *newAuthorAttributedString = [[NSAttributedString alloc] initWithString:author attributes:authorStringAttributes];
|
NSAttributedString *newAuthorAttributedString = [[NSAttributedString alloc] initWithString:author attributes:authorStringAttributes];
|
||||||
|
|
||||||
[authorTextNode setAttributedText:newAuthorAttributedString];
|
[authorNode setAttributedTitle:newAuthorAttributedString forState:UIControlStateNormal];
|
||||||
[authorTextNode setAttributedString:newAuthorAttributedString];
|
|
||||||
|
|
||||||
[bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]];
|
[bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]];
|
||||||
|
|
||||||
[comment setAuthor:author];
|
|
||||||
[comment setBody:body];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%end
|
%end
|
||||||
@ -204,7 +216,7 @@ id apolloCommentController;
|
|||||||
%new
|
%new
|
||||||
-(void) undeleteCellWasSelected{
|
-(void) undeleteCellWasSelected{
|
||||||
|
|
||||||
id post = MSHookIvar<id>(self, "link");
|
RKLink *post = MSHookIvar<RKLink *>(self, "link");
|
||||||
|
|
||||||
[%c(TFHelper) getUndeleteDataWithID:[[post fullName] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
|
[%c(TFHelper) getUndeleteDataWithID:[[post fullName] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
|
||||||
}
|
}
|
||||||
@ -212,28 +224,26 @@ id apolloCommentController;
|
|||||||
%new
|
%new
|
||||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||||
|
|
||||||
|
RKLink *post = MSHookIvar<RKLink *>(self, "link");
|
||||||
|
|
||||||
id headerCellNode = [self headerCellNode];
|
id headerCellNode = [self headerCellNode];
|
||||||
id bodyNode = MSHookIvar<id>(headerCellNode, "bodyNode");
|
id bodyNode = MSHookIvar<id>(headerCellNode, "bodyNode");
|
||||||
id postInfoNode = MSHookIvar<id>(headerCellNode, "postInfoNode");
|
id postInfoNode = MSHookIvar<id>(headerCellNode, "postInfoNode");
|
||||||
id authorNode = MSHookIvar<id>(postInfoNode, "authorButtonNode");
|
id authorNode = MSHookIvar<id>(postInfoNode, "authorButtonNode");
|
||||||
id authorTextNode = [authorNode subnodes][0];
|
|
||||||
|
|
||||||
NSString *author = data[@"author"];
|
NSString *author = data[@"author"];
|
||||||
NSString *authorTextString = [NSString stringWithFormat:@"by %@", author];
|
NSString *authorTextString = [NSString stringWithFormat:@"by %@", author];
|
||||||
NSString *body = data[@"body"];
|
NSString *body = data[@"body"];
|
||||||
|
|
||||||
id post = MSHookIvar<id>(self, "link");
|
[post setUndeleteAuthor:author];
|
||||||
//MSHookIvar<NSString*>(post, "_author") = author; //Crashes when clicking on author name. You will have to search the author name to go find the profile.
|
[post setSelfText:body];
|
||||||
|
|
||||||
id prevAuthorAttributedString = [authorTextNode attributedString];
|
NSAttributedString *prevAuthorAttributedString = [authorNode attributedTitleForState:UIControlStateNormal];
|
||||||
NSDictionary *authorStringAttributes = [prevAuthorAttributedString attributesAtIndex:0 longestEffectiveRange:nil inRange:NSMakeRange(0, [prevAuthorAttributedString length])];
|
NSDictionary *authorStringAttributes = [prevAuthorAttributedString attributesAtIndex:0 longestEffectiveRange:nil inRange:NSMakeRange(0, [prevAuthorAttributedString length])];
|
||||||
NSAttributedString* newAuthorAttributedString = [[NSAttributedString alloc] initWithString:authorTextString attributes:authorStringAttributes];
|
NSAttributedString* newAuthorAttributedString = [[NSAttributedString alloc] initWithString:authorTextString attributes:authorStringAttributes];
|
||||||
|
|
||||||
[authorTextNode setAttributedText:newAuthorAttributedString];
|
[authorNode setAttributedTitle:newAuthorAttributedString forState:UIControlStateNormal];
|
||||||
[authorTextNode setAttributedString:newAuthorAttributedString];
|
|
||||||
|
|
||||||
[bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]];
|
[bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]];
|
||||||
[post setSelfText:body];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%end
|
%end
|
||||||
|
Reference in New Issue
Block a user