mirror of
https://github.com/lint/TFDidThatSay
synced 2025-06-30 23:16:47 +00:00
Fix Apollo bug, add prefs, update Narwhal menu
This commit is contained in:
6
Makefile
6
Makefile
@ -8,7 +8,11 @@ tweak/Narwhal.xm_CFLAGS = -fobjc-arc
|
||||
|
||||
include $(THEOS_MAKE_PATH)/tweak.mk
|
||||
|
||||
SUBPROJECTS += prefs
|
||||
include $(THEOS_MAKE_PATH)/aggregate.mk
|
||||
|
||||
|
||||
after-install::
|
||||
install.exec "killall -9 Reddit"
|
||||
install.exec "killall -9 Apollo"
|
||||
install.exec "killall -9 narwhal"
|
||||
install.exec "killall -9 narwhal"
|
||||
|
2
control
2
control
@ -1,7 +1,7 @@
|
||||
Package: com.lint.undelete
|
||||
Name: TFDidThatSay?
|
||||
Depends: mobilesubstrate
|
||||
Version: 1.2.2
|
||||
Version: 1.2.3
|
||||
Architecture: iphoneos-arm
|
||||
Description: See "[deleted]" comments and posts without leaving Reddit!
|
||||
Maintainer: lint <apieceoflint@protonmail.com>
|
||||
|
17
prefs/Makefile
Normal file
17
prefs/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
include $(THEOS)/makefiles/common.mk
|
||||
|
||||
ARCHS = arm64 arm64e
|
||||
|
||||
BUNDLE_NAME = TFDidThatSayPrefs
|
||||
|
||||
TFDidThatSayPrefs_FILES = TFDTSRootListController.m
|
||||
TFDidThatSayPrefs_INSTALL_PATH = /Library/PreferenceBundles
|
||||
TFDidThatSayPrefs_FRAMEWORKS = UIKit
|
||||
TFDidThatSayPrefs_PRIVATE_FRAMEWORKS = Preferences
|
||||
TFDidThatSayPrefs_CFLAGS = -fobjc-arc
|
||||
|
||||
include $(THEOS_MAKE_PATH)/bundle.mk
|
||||
|
||||
internal-stage::
|
||||
$(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)
|
||||
$(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/TFDidThatSayPrefs.plist$(ECHO_END)
|
24
prefs/Resources/Info.plist
Normal file
24
prefs/Resources/Info.plist
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>TFDidThatSayPrefs</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.lint.undelete.prefs</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>TFDTSRootListController</string>
|
||||
</dict>
|
||||
</plist>
|
29
prefs/Resources/Root.plist
Normal file
29
prefs/Resources/Root.plist
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>items</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSGroupCell</string>
|
||||
<key>label</key>
|
||||
<string>Apollo </string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSSwitchCell</string>
|
||||
<key>default</key>
|
||||
<true/>
|
||||
<key>defaults</key>
|
||||
<string>com.lint.undelete.prefs</string>
|
||||
<key>key</key>
|
||||
<string>isApolloDeletedCommentsOnly</string>
|
||||
<key>label</key>
|
||||
<string>Only display eye on deleted comments</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>title</key>
|
||||
<string>TFDidThatSay?</string>
|
||||
</dict>
|
||||
</plist>
|
BIN
prefs/Resources/icon.png
Normal file
BIN
prefs/Resources/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
prefs/Resources/icon@2x.png
Normal file
BIN
prefs/Resources/icon@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
prefs/Resources/icon@3x.png
Normal file
BIN
prefs/Resources/icon@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
5
prefs/TFDTSRootListController.h
Normal file
5
prefs/TFDTSRootListController.h
Normal file
@ -0,0 +1,5 @@
|
||||
#import <Preferences/PSListController.h>
|
||||
|
||||
@interface TFDTSRootListController : PSListController
|
||||
|
||||
@end
|
13
prefs/TFDTSRootListController.m
Normal file
13
prefs/TFDTSRootListController.m
Normal file
@ -0,0 +1,13 @@
|
||||
#include "TFDTSRootListController.h"
|
||||
|
||||
@implementation TFDTSRootListController
|
||||
|
||||
- (NSArray *)specifiers {
|
||||
if (!_specifiers) {
|
||||
_specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
|
||||
}
|
||||
|
||||
return _specifiers;
|
||||
}
|
||||
|
||||
@end
|
21
prefs/entry.plist
Normal file
21
prefs/entry.plist
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>entry</key>
|
||||
<dict>
|
||||
<key>bundle</key>
|
||||
<string>TFDidThatSayPrefs</string>
|
||||
<key>cell</key>
|
||||
<string>PSLinkCell</string>
|
||||
<key>detail</key>
|
||||
<string>TFDTSRootListController</string>
|
||||
<key>icon</key>
|
||||
<string>icon.png</string>
|
||||
<key>isController</key>
|
||||
<true/>
|
||||
<key>label</key>
|
||||
<string>TFDidThatSay?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
@ -16,8 +16,7 @@
|
||||
-(void) calculatedLayoutDidChange;
|
||||
|
||||
//custom element
|
||||
@property(assign,nonatomic) id undeleteButton;
|
||||
|
||||
@property(strong,nonatomic) id undeleteButton;
|
||||
@end
|
||||
|
||||
/* -- Post Interfaces -- */
|
||||
@ -31,7 +30,7 @@
|
||||
@end
|
||||
|
||||
@interface ApolloCommentsHeaderCellNode
|
||||
@property(assign, nonatomic) id undeleteButton;
|
||||
@property(strong, nonatomic) id undeleteButton;
|
||||
@end
|
||||
|
||||
/* -- Other Interfaces -- */
|
||||
|
@ -3,18 +3,22 @@
|
||||
|
||||
%group Apollo
|
||||
|
||||
%hook ApolloApolloButtonNode
|
||||
%end
|
||||
|
||||
const NSDictionary* settings = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
NSDictionary* apolloBodyAttributes = nil;
|
||||
|
||||
%hook ApolloApolloButtonNode
|
||||
%end
|
||||
|
||||
%hook RKComment
|
||||
|
||||
-(BOOL) isDeleted{
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(BOOL) isModeratorRemoved{
|
||||
return NO;
|
||||
}
|
||||
%end
|
||||
|
||||
|
||||
@ -30,10 +34,12 @@ NSDictionary* apolloBodyAttributes = nil;
|
||||
|
||||
|
||||
%hook ApolloCommentCellNode
|
||||
%property(assign,nonatomic) id undeleteButton;
|
||||
%property(strong,nonatomic) id undeleteButton;
|
||||
|
||||
%new
|
||||
-(void) didTapUndeleteButton{
|
||||
-(void) didTapUndeleteButton:(id) sender{
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
id bodyNode = MSHookIvar<id>(self, "bodyNode");
|
||||
id authorNode = MSHookIvar<id>(self, "authorNode");
|
||||
@ -77,48 +83,64 @@ NSDictionary* apolloBodyAttributes = nil;
|
||||
|
||||
[bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]];
|
||||
|
||||
[sender setEnabled:YES];
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void) didLoad {
|
||||
%orig;
|
||||
|
||||
CGFloat imageSize = 20.0f;
|
||||
|
||||
UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[undeleteButton addTarget:self action:@selector(didTapUndeleteButton) forControlEvents:UIControlEventTouchUpInside];
|
||||
undeleteButton.frame = CGRectMake(0, 0, imageSize, imageSize);
|
||||
id commentBody = [MSHookIvar<id>(self, "comment") body];
|
||||
|
||||
UIImage* undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
[undeleteButton setImage:undeleteImage forState:UIControlStateNormal];
|
||||
id isDeletedOnly = [settings valueForKey:@"isApolloDeletedCommentsOnly"];
|
||||
|
||||
if (([isDeletedOnly isEqual:@1] && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || [isDeletedOnly isEqual:@0] ) {
|
||||
|
||||
CGFloat imageSize = 20.0f;
|
||||
|
||||
[[self view] addSubview:undeleteButton];
|
||||
[self setUndeleteButton:undeleteButton];
|
||||
UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[undeleteButton addTarget:self action:@selector(didTapUndeleteButton:) forControlEvents:UIControlEventTouchUpInside];
|
||||
undeleteButton.frame = CGRectMake(0, 0, imageSize, imageSize);
|
||||
|
||||
UIImage* undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
[undeleteButton setImage:undeleteImage forState:UIControlStateNormal];
|
||||
|
||||
[[self view] addSubview:undeleteButton];
|
||||
[self setUndeleteButton:undeleteButton];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
-(void) _layoutSublayouts{
|
||||
%orig;
|
||||
|
||||
CGFloat imageSize = 20.0f;
|
||||
if ([self undeleteButton]){
|
||||
|
||||
CGFloat imageSize = 20.0f;
|
||||
|
||||
id moreNode = MSHookIvar<id>(self, "moreOptionsNode");
|
||||
id ageNode = MSHookIvar<id>(self, "ageNode");
|
||||
id moreNode = MSHookIvar<id>(self, "moreOptionsNode");
|
||||
id ageNode = MSHookIvar<id>(self, "ageNode");
|
||||
|
||||
CGRect nodeFrame = [moreNode frame];
|
||||
CGFloat centerHeight = (nodeFrame.size.height + nodeFrame.origin.y * 2) / 2.0f;
|
||||
CGFloat nodeSpacing =[ageNode frame].origin.x - nodeFrame.origin.x - nodeFrame.size.width;
|
||||
CGRect nodeFrame = [moreNode frame];
|
||||
CGFloat centerHeight = (nodeFrame.size.height + nodeFrame.origin.y * 2) / 2.0f;
|
||||
CGFloat nodeSpacing =[ageNode frame].origin.x - nodeFrame.origin.x - nodeFrame.size.width;
|
||||
|
||||
[[self undeleteButton] setFrame:CGRectMake(nodeFrame.origin.x - imageSize - nodeSpacing, centerHeight - (imageSize / 2), imageSize, imageSize)];
|
||||
[[self undeleteButton] setFrame:CGRectMake(nodeFrame.origin.x - imageSize - nodeSpacing, centerHeight - (imageSize / 2), imageSize, imageSize)];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
%end
|
||||
|
||||
|
||||
%hook ApolloCommentsHeaderCellNode
|
||||
%property(assign, nonatomic) id undeleteButton;
|
||||
%property(strong, nonatomic) id undeleteButton;
|
||||
|
||||
%new
|
||||
-(void) didTapUndeleteButton{
|
||||
-(void) didTapUndeleteButton:(id) sender{
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
id bodyNode = MSHookIvar<id>(self, "bodyNode");
|
||||
id postInfoNode = MSHookIvar<id>(self, "postInfoNode");
|
||||
@ -165,6 +187,8 @@ NSDictionary* apolloBodyAttributes = nil;
|
||||
|
||||
[bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]];
|
||||
|
||||
[sender setEnabled:YES];
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
@ -177,7 +201,7 @@ NSDictionary* apolloBodyAttributes = nil;
|
||||
CGFloat imageSize = 20.0f;
|
||||
|
||||
UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[undeleteButton addTarget:self action:@selector(didTapUndeleteButton) forControlEvents:UIControlEventTouchUpInside];
|
||||
[undeleteButton addTarget:self action:@selector(didTapUndeleteButton:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
UIImage* undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
[undeleteButton setImage:undeleteImage forState:UIControlStateNormal];
|
||||
@ -201,7 +225,6 @@ NSDictionary* apolloBodyAttributes = nil;
|
||||
CGFloat centerHeight = [postInfoNode frame].origin.y + ([ageNode frame].size.height + [ageNode frame].origin.y * 2) / 2.0f;
|
||||
CGFloat buttonXPos = [postInfoNode frame].origin.x + [postInfoNode frame].size.width - imageSize;
|
||||
|
||||
//Compiling with DEBUG=0 causes this to break the app, I have no idea why.
|
||||
[[self undeleteButton] setFrame:CGRectMake(buttonXPos, centerHeight - (imageSize / 2), imageSize, imageSize)];
|
||||
}
|
||||
}
|
||||
@ -211,10 +234,10 @@ NSDictionary* apolloBodyAttributes = nil;
|
||||
|
||||
|
||||
%ctor {
|
||||
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"Apollo"]){
|
||||
%init(Apollo, ApolloCommentsHeaderCellNode = objc_getClass("Apollo.CommentsHeaderCellNode"), ApolloCommentCellNode = objc_getClass("Apollo.CommentCellNode"), ApolloApolloButtonNode = objc_getClass("Apollo.ApolloButtonNode"));
|
||||
}
|
||||
}
|
||||
|
||||
|
177
tweak/Narwhal.xm
177
tweak/Narwhal.xm
@ -3,52 +3,9 @@
|
||||
|
||||
%group Narwhal
|
||||
|
||||
UIAlertController* recreateActionSheet(id controller, id comment, NSInteger commentIndex){
|
||||
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:nil];
|
||||
|
||||
UIAlertAction* pmAction = [UIAlertAction actionWithTitle:[NSString stringWithFormat:@"private message %@", [comment author]] style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetPrivateMessage:comment];}];
|
||||
UIAlertAction* viewProfileAction = [UIAlertAction actionWithTitle:@"view profile" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetViewProfile:comment];}];
|
||||
UIAlertAction* shareAction = [UIAlertAction actionWithTitle:@"share comment" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetShareComment:comment];}];
|
||||
UIAlertAction* copyAction = [UIAlertAction actionWithTitle:@"copy text" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetCopyCommentText:comment];}];
|
||||
UIAlertAction* reportAction = [UIAlertAction actionWithTitle:@"report comment" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetReportComment:comment];}];
|
||||
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
|
||||
|
||||
[alert addAction:pmAction];
|
||||
[alert addAction:viewProfileAction];
|
||||
[alert addAction:shareAction];
|
||||
[alert addAction:copyAction];
|
||||
|
||||
if ([comment isSaved]){
|
||||
UIAlertAction* unsaveAction = [UIAlertAction actionWithTitle:@"unsave comment" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetUnsaveComment:comment index:commentIndex];}];
|
||||
[alert addAction:unsaveAction];
|
||||
|
||||
} else {
|
||||
UIAlertAction* saveAction = [UIAlertAction actionWithTitle:@"save comment" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetSaveComment:comment index:commentIndex];}];
|
||||
[alert addAction:saveAction];
|
||||
}
|
||||
|
||||
if ([[[comment parentID] componentsSeparatedByString:@"_"][0] isEqualToString:@"t1"]){
|
||||
UIAlertAction* viewParentAction = [UIAlertAction actionWithTitle:@"view parent" style: nil handler:^(UIAlertAction* action){[controller _handleActionSheetViewParent:comment];}];
|
||||
[alert addAction:viewParentAction];
|
||||
}
|
||||
|
||||
if ([[comment author] isEqualToString:[[%c(NRTAuthManager) sharedManager] currentUsername]]) {
|
||||
UIAlertAction* editAction = [UIAlertAction actionWithTitle:@"edit comment" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetEditComment:comment];}];
|
||||
UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:@"delete comment" style:nil handler:^(UIAlertAction* action){[controller _handleActionSheetDeleteComment:comment];}];
|
||||
|
||||
[alert addAction:editAction];
|
||||
[alert addAction:deleteAction];
|
||||
}
|
||||
|
||||
[alert addAction:reportAction];
|
||||
[alert addAction:cancelAction];
|
||||
|
||||
UIAlertAction* undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:nil handler:^(UIAlertAction* action){[controller handleUndeleteCommentAction:comment];}];
|
||||
[alert addAction:undeleteAction];
|
||||
|
||||
return alert;
|
||||
}
|
||||
BOOL shouldHaveUndeleteAction = NO;
|
||||
id tfComment;
|
||||
id tfController;
|
||||
|
||||
void getUndeleteCommentData(id controller, id comment){
|
||||
|
||||
@ -71,12 +28,6 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
if ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"]){
|
||||
body = @"[pushshift was unable to archive this]";
|
||||
}
|
||||
if (!body){
|
||||
body = @"[wtf]";
|
||||
}
|
||||
if (!author){
|
||||
author = @"[wtf]";
|
||||
}
|
||||
} else {
|
||||
body = @"[pushshift has not archived this yet]";
|
||||
}
|
||||
@ -87,7 +38,34 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
[controller performSelectorOnMainThread:@selector(completeUndeleteComment:) withObject:@{@"body":body, @"author":author, @"comment":comment} waitUntilDone:NO];
|
||||
}];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
%hook UIViewController
|
||||
|
||||
-(void) presentViewController:(id) arg1 animated:(BOOL) arg2 completion:(id) arg3{
|
||||
|
||||
if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveUndeleteAction){
|
||||
|
||||
UIAlertAction* undeleteAction;
|
||||
|
||||
if (tfComment){
|
||||
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:nil handler:^(UIAlertAction* action){getUndeleteCommentData(tfController, tfComment);}];
|
||||
} else {
|
||||
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:nil handler:^(UIAlertAction* action){[tfController handleUndeletePostAction];}];
|
||||
}
|
||||
|
||||
[arg1 addAction:undeleteAction];
|
||||
|
||||
}
|
||||
|
||||
%orig;
|
||||
}
|
||||
|
||||
%end
|
||||
|
||||
|
||||
|
||||
|
||||
%hook NRTLinkViewController
|
||||
@ -119,11 +97,6 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
[[self tableView] reloadData];
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeleteCommentAction:(id) comment{
|
||||
getUndeleteCommentData(self, comment);
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeletePostAction{
|
||||
|
||||
@ -158,8 +131,6 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
[self performSelectorOnMainThread:@selector(completeUndeletePost:) withObject:@{@"body":body, @"author":author, @"post":post} waitUntilDone:NO];
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void) swipeCell:(id) arg1 didEndDragWithState:(NSUInteger) arg2{
|
||||
@ -168,66 +139,32 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
|
||||
if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) {
|
||||
|
||||
id comment = [arg1 comment];
|
||||
NSInteger commentIndex = [[[self commentsManager] comments] indexOfObject:comment];
|
||||
tfComment = [arg1 comment];
|
||||
tfController = self;
|
||||
shouldHaveUndeleteAction = YES;
|
||||
|
||||
UIAlertController* alert = recreateActionSheet(self, comment, commentIndex);
|
||||
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
|
||||
} else {
|
||||
%orig;
|
||||
}
|
||||
} else {
|
||||
%orig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%orig;
|
||||
|
||||
shouldHaveUndeleteAction = NO;
|
||||
}
|
||||
|
||||
|
||||
-(void) _dotsButtonTouched:(id) arg1{
|
||||
|
||||
id post = [self link];
|
||||
BOOL shouldHaveUndeleteAction = NO;
|
||||
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:nil];
|
||||
|
||||
UIAlertAction* undeletePostAction;
|
||||
|
||||
UIAlertAction* sharePostAction = [UIAlertAction actionWithTitle:@"share reddit post" style:nil handler:^(UIAlertAction* action){[self _handleActionSheetSharePost];}];
|
||||
UIAlertAction* sortCommentsAction = [UIAlertAction actionWithTitle:@"sort comments" style:nil handler:^(UIAlertAction* action){[self _handleActionSheetSortComments];}];
|
||||
UIAlertAction* refreshCommentsAction = [UIAlertAction actionWithTitle:@"refresh comments" style:nil handler:^(UIAlertAction* action){[self _handleActionSheetRefreshComments];}];
|
||||
UIAlertAction* reportPostAction = [UIAlertAction actionWithTitle:@"report post" style:nil handler:^(UIAlertAction* action){[self _handleActionSheetReportPost];}];
|
||||
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
|
||||
|
||||
[alert addAction:sharePostAction];
|
||||
[alert addAction:sortCommentsAction];
|
||||
[alert addAction:refreshCommentsAction];
|
||||
|
||||
if ([self linkTextOffscreenCell]){
|
||||
UIAlertAction* refreshPostAction = [UIAlertAction actionWithTitle:@"refresh post" style:nil handler:^(UIAlertAction* action){[self _handleActionSheetRefreshPost];}];
|
||||
[alert addAction:refreshPostAction];
|
||||
|
||||
undeletePostAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:nil handler:^(UIAlertAction* action){[self handleUndeletePostAction];}];
|
||||
tfController = self;
|
||||
tfComment = nil;
|
||||
shouldHaveUndeleteAction = YES;
|
||||
}
|
||||
|
||||
if ([[post author] isEqualToString:[[%c(NRTAuthManager) sharedManager] currentUsername]]){
|
||||
UIAlertAction* editPostAction = [UIAlertAction actionWithTitle:@"edit post" style:nil handler:^(UIAlertAction* action){[self _handleActionSheetEditPost];}];
|
||||
UIAlertAction* deletePostAction = [UIAlertAction actionWithTitle:@"delete post" style:nil handler:^(UIAlertAction* action){[self _handleActionSheetDeletePost];}];
|
||||
|
||||
[alert addAction:editPostAction];
|
||||
[alert addAction:deletePostAction];
|
||||
}
|
||||
|
||||
[alert addAction:reportPostAction];
|
||||
[alert addAction:cancelAction];
|
||||
|
||||
if (shouldHaveUndeleteAction){
|
||||
[alert addAction:undeletePostAction];
|
||||
}
|
||||
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
%orig;
|
||||
|
||||
shouldHaveUndeleteAction = NO;
|
||||
}
|
||||
|
||||
%end
|
||||
@ -249,30 +186,22 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
}
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeleteCommentAction:(id) comment{
|
||||
getUndeleteCommentData(self, comment);
|
||||
}
|
||||
|
||||
-(void) swipeCell:(id) arg1 didEndDragWithState:(NSUInteger) arg2{
|
||||
|
||||
if (arg2 == 2){
|
||||
|
||||
if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) {
|
||||
|
||||
id comment = [arg1 comment];
|
||||
NSInteger commentIndex = [[[self commentsManager] comments] indexOfObject:comment];
|
||||
|
||||
UIAlertController* alert = recreateActionSheet(self, comment, commentIndex);
|
||||
|
||||
[[self parentController] presentViewController:alert animated:YES completion:nil];
|
||||
tfComment = [arg1 comment];
|
||||
tfController = self;
|
||||
shouldHaveUndeleteAction = YES;
|
||||
|
||||
} else {
|
||||
%orig;
|
||||
}
|
||||
} else {
|
||||
%orig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%orig;
|
||||
|
||||
shouldHaveUndeleteAction = NO;
|
||||
}
|
||||
|
||||
%end
|
||||
|
Reference in New Issue
Block a user