Browse Source

Misc Reddit changes

master
lint 3 years ago
parent
commit
670398cf88
2 changed files with 69 additions and 5 deletions
  1. +3
    -1
      tweak/Reddit.h
  2. +66
    -4
      tweak/Reddit.xm

+ 3
- 1
tweak/Reddit.h View File

@end @end
@interface FeedPostTitleNode @interface FeedPostTitleNode
@property(strong, nonatomic) Post *post;
@property(strong, nonatomic) id delegate; @property(strong, nonatomic) id delegate;
- (void)configureNodes; - (void)configureNodes;
@end @end
/* -- Other Interfaces -- */ /* -- Other Interfaces -- */
@interface RichTextDisplayNode @interface RichTextDisplayNode
@property(strong, nonatomic) id attributedText;
@property(strong, nonatomic) NSAttributedString *attributedText;
- (void)configureDisplayNodes;
@end @end
@interface RUIActionSheetItem : NSObject @interface RUIActionSheetItem : NSObject

+ 66
- 4
tweak/Reddit.xm View File

static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
int firstVersionPart = 2020;
int firstVersionPart = 0;
int secondVersionPart = 0; int secondVersionPart = 0;
%group Reddit_v4_current %group Reddit_v4_current
%end %end
/*
%hook Post
- (id)previewTextWithTheme:(id)arg1 {
%log;
id orig = %orig;
HBLogDebug(@"previewTextWithTheme: orig: %@", orig);
return orig;
}
- (id)previewFeedPostTextString {
%log;
id orig = %orig;
HBLogDebug(@"previewFeedPostTextString orig: %@", orig);
return orig;
}
- (id)previewPostText:(id)arg1 {
%log;
id orig = %orig;
HBLogDebug(@"previewPostText: orig: %@", orig);
return orig;
}
%end
*/
%hook PostDetailViewController %hook PostDetailViewController
%property(strong,nonatomic) id feedPostTextWithThumbnailNode; %property(strong,nonatomic) id feedPostTextWithThumbnailNode;
} }
} }
/*
NSMutableAttributedString *bodyMutableAttributedText;
if ((firstVersionPart == 2020 && secondVersionPart <= 41) || firstVersionPart != 2020) {
bodyMutableAttributedText = [[post previewFeedPostTextString] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
} else {
bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
}
*/
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]]; NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
[bodyMutableAttributedText beginEditing]; [bodyMutableAttributedText beginEditing];
[post setSelfText:body]; [post setSelfText:body];
[post setAuthor:author]; [post setAuthor:author];
[post setSelfPostRichTextAttributed:bodyMutableAttributedText]; [post setSelfPostRichTextAttributed:bodyMutableAttributedText];
[post setPreviewFeedPostTextString:bodyMutableAttributedText];
FeedPostTitleNode *titleNode = [[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] titleNode];
Post *feedPost = [titleNode post];
[feedPost setAuthor:author];
if (firstVersionPart == 2020) { if (firstVersionPart == 2020) {
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
if (secondVersionPart >= 42) {
RichTextDisplayNode *selfTextNode = [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] selfTextNode];
[selfTextNode setAttributedText:bodyMutableAttributedText];
[selfTextNode configureDisplayNodes];
} else {
[post setPreviewFeedPostTextString:bodyMutableAttributedText];
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
}
if (secondVersionPart >= 41) {
[titleNode configureNodes];
}
} else { } else {
[post setPreviewFeedPostTextString:bodyMutableAttributedText];
if (secondVersionPart >= 44) { if (secondVersionPart >= 44) {
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode]; [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
} else if (secondVersionPart >= 38) { } else if (secondVersionPart >= 38) {
secondVersionPart = [redditVersion[1] intValue]; secondVersionPart = [redditVersion[1] intValue];
} }
@catch (NSException *exc) { @catch (NSException *exc) {
firstVersionPart = 2020;
firstVersionPart = 0;
secondVersionPart = 0; secondVersionPart = 0;
} }
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
/*
if (firstVersionPart == 4 || firstVersionPart == 2020) { if (firstVersionPart == 4 || firstVersionPart == 2020) {
if (secondVersionPart <= 32 && firstVersionPart != 2020) { if (secondVersionPart <= 32 && firstVersionPart != 2020) {
%init(Reddit_v4_ios10); %init(Reddit_v4_ios10);
} else if (firstVersionPart == 3) { } else if (firstVersionPart == 3) {
%init(Reddit_v3); %init(Reddit_v3);
} }
*/
if (firstVersionPart >= 2020 || (firstVersionPart == 4 && secondVersionPart > 32)) {
%init(Reddit_v4_current);
} else if (firstVersionPart == 4 && secondVersionPart <= 32) {
%init(Reddit_v4_ios10);
} else if (firstVersionPart == 3) {
%init(Reddit_v3);
}
} }
} }
} }

Loading…
Cancel
Save