Browse Source

Can fetch subreddits instead of subscriptions…

Thomas Buck 11 years ago
parent
commit
7d83e4c389
3 changed files with 17 additions and 4 deletions
  1. 1
    1
      RedditBar/Base.lproj/Prefs.xib
  2. 15
    2
      RedditBar/Reddit.m
  3. 1
    1
      RedditBar/RedditBar-Info.plist

+ 1
- 1
RedditBar/Base.lproj/Prefs.xib View File

@@ -143,7 +143,7 @@ Gw
143 143
                     <button id="XZM-90-hQ8">
144 144
                         <rect key="frame" x="118" y="234" width="204" height="18"/>
145 145
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
146
-                        <buttonCell key="cell" type="check" title="Subscriptions" bezelStyle="regularSquare" imagePosition="overlaps" alignment="right" enabled="NO" state="on" inset="2" id="vW5-Cp-Bm1">
146
+                        <buttonCell key="cell" type="check" title="Subscriptions" bezelStyle="regularSquare" imagePosition="overlaps" alignment="right" state="on" inset="2" id="vW5-Cp-Bm1">
147 147
                             <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
148 148
                             <font key="font" metaFont="system"/>
149 149
                         </buttonCell>

+ 15
- 2
RedditBar/Reddit.m View File

@@ -119,8 +119,21 @@ NSString *replaceTextForTitle = @"...";
119 119
 }
120 120
 
121 121
 -(void)readSubreddits:(id)parent {
122
-    // TODO read subreddits (as multireddit?)
123
-    // TODO if implemented, enable checkbox in prefs
122
+    NSMutableString *subs = [NSMutableString stringWithString:@"r/"];
123
+    for (NSUInteger i = 0; i < [subreddits count]; i++) {
124
+        [subs appendString:[subreddits objectAtIndex:i]];
125
+        if (i < ([subreddits count] - 1)) {
126
+            [subs appendString:@"+"];
127
+        }
128
+    }
129
+    NSString *url = [NSString stringWithFormat:@"%@/hot.json?limit=%ld", subs, (long)length];
130
+    NSHTTPURLResponse *response;
131
+    NSData *data = [self queryAPI:url withResponse:&response];
132
+    if ((data == nil) || ([response statusCode] != 200)) {
133
+        [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:nil waitUntilDone:false];
134
+    } else {
135
+        [parent performSelectorOnMainThread:@selector(reloadListHasSubredditsCallback:) withObject:[self convertJSONToItemArray:data] waitUntilDone:false];
136
+    }
124 137
 }
125 138
 
126 139
 -(void)isAuthenticatedNewModhash:(id)parent {

+ 1
- 1
RedditBar/RedditBar-Info.plist View File

@@ -21,7 +21,7 @@
21 21
 	<key>CFBundleSignature</key>
22 22
 	<string>????</string>
23 23
 	<key>CFBundleVersion</key>
24
-	<string>152</string>
24
+	<string>153</string>
25 25
 	<key>LSApplicationCategoryType</key>
26 26
 	<string>public.app-category.utilities</string>
27 27
 	<key>LSMinimumSystemVersion</key>

Loading…
Cancel
Save