@@ -199,20 +199,23 @@ - (NSPredicate *)predicateForFetchRequest
199
199
NSPredicate *basePredicate = [NSPredicate predicateWithFormat: @" blog = %@ && original = nil" , self .blog];
200
200
[predicates addObject: basePredicate];
201
201
202
+ NSString *searchText = [self currentSearchTerm ];
202
203
NSPredicate *filterPredicate = [self currentPostListFilter ].predicateForFetchRequest ;
204
+
205
+ // If we have recently trashed posts, create an OR predicate to find posts matching the filter,
206
+ // or posts that were recently deleted.
207
+ if ([searchText length ] == 0 && [self .recentlyTrashedPostIDs count ] > 0 ) {
208
+ NSPredicate *trashedPredicate = [NSPredicate predicateWithFormat: @" postID IN %@" , self .recentlyTrashedPostIDs];
209
+ filterPredicate = [NSCompoundPredicate orPredicateWithSubpredicates: @[filterPredicate, trashedPredicate]];
210
+ }
203
211
[predicates addObject: filterPredicate];
204
212
205
- NSString *searchText = self.searchController .searchBar .text ;
206
213
if ([searchText length ] > 0 ) {
207
214
NSPredicate *searchPredicate = [NSPredicate predicateWithFormat: @" postTitle CONTAINS [cd] %@" , searchText];
208
215
[predicates addObject: searchPredicate];
209
216
}
210
217
211
218
NSPredicate *predicate = [NSCompoundPredicate andPredicateWithSubpredicates: predicates];
212
- if ([searchText length ] == 0 && [self .recentlyTrashedPostIDs count ] > 0 ) {
213
- NSPredicate *trashedPredicate = [NSPredicate predicateWithFormat: @" postID IN %@" , self .recentlyTrashedPostIDs];
214
- predicate = [NSCompoundPredicate orPredicateWithSubpredicates: @[predicate, trashedPredicate]];
215
- }
216
219
217
220
return predicate;
218
221
}
0 commit comments