|
@@ -147,27 +147,33 @@
|
147
|
147
|
-(void)openAndRemoveAndReloadWithIndex:(NSInteger)index Comments:(Boolean)comments Both:(Boolean)both {
|
148
|
148
|
RedditItem *rItem = [redditItems objectAtIndex:index];
|
149
|
149
|
NSString *url;
|
150
|
|
- if (comments)
|
|
150
|
+ if (comments) {
|
151
|
151
|
url = [rItem comments];
|
152
|
|
- else
|
|
152
|
+ [rItem setVisitedComments:TRUE];
|
|
153
|
+ } else {
|
153
|
154
|
url = [rItem link];
|
|
155
|
+ [rItem setVisitedLink:TRUE];
|
|
156
|
+ }
|
154
|
157
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
|
155
|
158
|
if (both) {
|
156
|
|
- if (!comments)
|
|
159
|
+ if (!comments) {
|
157
|
160
|
url = [rItem comments];
|
158
|
|
- else
|
|
161
|
+ [rItem setVisitedComments:TRUE];
|
|
162
|
+ } else {
|
159
|
163
|
url = [rItem link];
|
|
164
|
+ [rItem setVisitedLink:TRUE];
|
|
165
|
+ }
|
160
|
166
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
|
161
|
167
|
}
|
162
|
168
|
|
163
|
169
|
if (currentState.removeVisited) {
|
164
|
|
- // TODO remove selfpost, remove submenu if link & comments visited
|
165
|
|
- //[statusMenu removeItem:[menuItems objectAtIndex:i]];
|
166
|
|
-
|
167
|
|
- Boolean removed = TRUE;
|
168
|
|
- Boolean listNowEmpty = TRUE;
|
|
170
|
+ Boolean removed = FALSE;
|
|
171
|
+ if ((rItem.isSelf && (rItem.visitedLink || rItem.visitedComments)) || ((!rItem.isSelf) && rItem.visitedLink && rItem.visitedComments)) {
|
|
172
|
+ [statusMenu removeItem:[menuItems objectAtIndex:index]];
|
|
173
|
+ removed = TRUE;
|
|
174
|
+ }
|
169
|
175
|
|
170
|
|
- if (removed && listNowEmpty) {
|
|
176
|
+ if (removed && ([statusMenu numberOfItems] <= 10)) {
|
171
|
177
|
[self reloadNextList:nil];
|
172
|
178
|
} else {
|
173
|
179
|
if (removed && currentState.reloadAfterVisit) {
|
|
@@ -221,7 +227,9 @@
|
221
|
227
|
-(void)clearMenuItems {
|
222
|
228
|
if (menuItems != nil) {
|
223
|
229
|
for (NSUInteger i = 0; i < [menuItems count]; i++) {
|
224
|
|
- [statusMenu removeItem:[menuItems objectAtIndex:i]];
|
|
230
|
+ NSMenuItem *item = [menuItems objectAtIndex:i];
|
|
231
|
+ if ([statusMenu indexOfItem:item] != -1)
|
|
232
|
+ [statusMenu removeItem:item];
|
225
|
233
|
}
|
226
|
234
|
menuItems = nil;
|
227
|
235
|
}
|