feat: add post filter for holes and floors - #681
Conversation
This commit also introduced a `WithPostFilterBar` widget to wrap the page body and deduplicate the build logic.
|
Sorry for late reply. The idea LGTM, but maybe the search toolbar is too hard-core for average users? 🤔 I'm considering an "easy mode", which allows user to select filters (e.g., Also, you might want to support showing a dropdown filter history list in the text field, like the post searching page we have currently, so that user doesn't need to input the same filter again and again. |
Big Pickle did these when refactoring the boolean expr rows. I do not know the reason, but the UI for array and map would be designed again later.
Each slot is always bound to the parent group, which makes the expr it holds easy to operate with.
c3c91bc to
9571a0f
Compare
…tered This prevents scroll jitter when many pages are filtered out.
|
This PR is ready for review now. |
| final pagedListView = PagedListView<OTFloor>( | ||
| pagedController: _listViewController, | ||
| noneItem: OTFloor.dummy(), | ||
| noneItem: OTFloor.dummyPost, |
There was a problem hiding this comment.
Why use a constant here? I thought we've overridden equality = for the OTFloor?
There was a problem hiding this comment.
OTHole always uses such a constant OTHole.DUMMY_POST, so I added it to keep the two models similar.
DanXi/lib/page/subpage_bbs.dart
Lines 424 to 426 in 934533c
DanXi/lib/page/subpage_bbs.dart
Lines 261 to 263 in 934533c
If BBSPostDetailState._loadContent ever in the future needs to return [OTFloor.DUMMY_POST] as the non-ending empty list, it can then be written the same way ForumSubpageState was.
I will update them to DUMMY_POST instead of dummyPost.
| if (_postFilter.holeMatches(post)) post, | ||
| ]; | ||
| return filtered.isEmpty | ||
| ? [posts.last.copyWith(meta: PostFilterPlaceholderHint(posts.length))] |
There was a problem hiding this comment.
I got what you want to achieve here, but there's a gotcha: PagedListView will add Dismissible for all post items, so user can swipe the hint widget to hide an invisible (but real) post.
| }, | ||
| child: WithPostFilterBar( | ||
| filter: _postFilter, | ||
| onApply: (expr) => setState(() => _postFilter.apply(expr)), |
There was a problem hiding this comment.
Will setState(() => _postFilter.apply(expr)) trigger a refresh of the list view? Otherwises, the shown items on the screen will not be refiltered.
There was a problem hiding this comment.
No, it will not be refreshed. In the main "forum subpage" or the "hole detail" page the user can refresh to get the filtered view.
But in some other render models like "my replies", it does not support pull-down-refresh, so it would be a bug there that the filter never filters the posts. I will fix it.
There was a problem hiding this comment.
We use the current _listViewController.length() as the offset for next loading. So if you filter the post list data, maybe the offset will be wrong here.
There was a problem hiding this comment.
DanXi/lib/page/forum/hole_detail.dart
Lines 154 to 159 in 94f702a
This person filter that has already been existing could also generate wrong offsets with using _listViewController.length() as startFloor. I think the fix could be to replace some of these .length() occurrences with page * Constant.POST_COUNT_PER_PAGE like the Normal render model.
|
Sorry for not noticing the reviews recently, I will apply the commented changes as soon as possible. |
- Extract PostFilterPlaceholderHint into lib/util so hole and floor models do not depend on lib/widgets. - Replace untyped `Object? meta` with `PostFilterPlaceholderHint? pfHint` on OTHole and OTFloor.
…e pages not all posts in which are filtered out
… offset This avoids the mismatches of offset of content between the fetched and the list view controller stored made by filters
7512b4b to
f652644
Compare
|
Sorry for the laaaaaaate reply. I'm so busy recently, thus having no time to review it. I might get it done this week. |
|
I will try to implement the support for keyboard shortcuts like |




Close #680.