1
0
mirror of https://github.com/lint/TFDidThatSay synced 2025-07-01 15:36:46 +00:00

Style and prefs loading improvements

This commit is contained in:
lint
2020-06-02 16:37:49 -04:00
parent 942ec27c11
commit a7b11813d0
18 changed files with 915 additions and 1025 deletions

View File

@ -1,7 +1,9 @@
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
@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;
+ (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

View File

@ -3,22 +3,22 @@
@implementation TFHelper
+(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 {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
if (isComment){
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body", ident]]];
} else {
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext", ident]]];
}
[request setHTTPMethod:@"GET"];
[request setTimeoutInterval:timeout];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSString *author = @"[author]";
NSString *body = @"[body]";
@ -36,19 +36,19 @@
} else if (error != nil || data == nil){
body = [NSString stringWithFormat:@"[an error occured while attempting to contact pushshift api (%@)]", [error localizedDescription]];
}
NSMutableDictionary *result = [@{@"author" : author, @"body" : body} mutableCopy];
if (extra){
[result addEntriesFromDictionary:extra];
}
[target performSelectorOnMainThread:sel withObject:result waitUntilDone:NO];
}];
}
+(BOOL) shouldShowUndeleteButtonWithInfo:(NSString *) content isDeletedOnly:(BOOL) isDeletedOnly{
if (!isDeletedOnly){
return YES;
} else {
@ -58,7 +58,7 @@
return YES;
}
}
return NO;
}