Skip to content

feat: add post filter for holes and floors - #681

Open
sseu-buhzzi wants to merge 94 commits into
DanXi-Dev:mainfrom
sseu-buhzzi:20260611/feat-post-filter
Open

feat: add post filter for holes and floors#681
sseu-buhzzi wants to merge 94 commits into
DanXi-Dev:mainfrom
sseu-buhzzi:20260611/feat-post-filter

Conversation

@sseu-buhzzi

Copy link
Copy Markdown
Contributor
image

Close #680.

@sseu-buhzzi sseu-buhzzi changed the title feat: add post filter feat: add post filter for holes and floors Jun 12, 2026
@sseu-buhzzi

Copy link
Copy Markdown
Contributor Author
image

One problem is that buttons are now too many in the forum page. I am not sure where this new filter button should go.

@sseu-buhzzi
sseu-buhzzi marked this pull request as ready for review June 16, 2026 03:55
@w568w

w568w commented Jun 17, 2026

Copy link
Copy Markdown
Member

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., Like: [✔Yes] [No] [Unspecified]) .

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.

@sseu-buhzzi
sseu-buhzzi force-pushed the 20260611/feat-post-filter branch from c3c91bc to 9571a0f Compare June 24, 2026 06:05
@sseu-buhzzi

Copy link
Copy Markdown
Contributor Author

User friendly UI selectors are like:
image
image

History and UI restoring are like:
image

@sseu-buhzzi

Copy link
Copy Markdown
Contributor Author

This PR is ready for review now.

Comment thread lib/model/forum/floor.dart Outdated
Comment thread lib/model/forum/hole.dart Outdated
Comment thread lib/model/forum/hole.dart Outdated
Comment thread lib/page/forum/hole_detail.dart Outdated
final pagedListView = PagedListView<OTFloor>(
pagedController: _listViewController,
noneItem: OTFloor.dummy(),
noneItem: OTFloor.dummyPost,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a constant here? I thought we've overridden equality = for the OTFloor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTHole always uses such a constant OTHole.DUMMY_POST, so I added it to keep the two models similar.

child: PagedListView<BBSPost>(
noneItem: BBSPost.DUMMY_POST,
pagedController: _listViewController,

// About this line, see [PagedListView].
return loadedPost.isEmpty ? [BBSPost.DUMMY_POST] : loadedPost;
}

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.

Comment thread lib/page/subpage_forum.dart Outdated
if (_postFilter.holeMatches(post)) post,
];
return filtered.isEmpty
? [posts.last.copyWith(meta: PostFilterPlaceholderHint(posts.length))]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/page/forum/hole_detail.dart Outdated
},
child: WithPostFilterBar(
filter: _postFilter,
onApply: (expr) => setState(() => _postFilter.apply(expr)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will setState(() => _postFilter.apply(expr)) trigger a refresh of the list view? Otherwises, the shown items on the screen will not be refiltered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/page/forum/hole_detail.dart Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MyReplies() => (await ForumRepository.getInstance()
.loadUserFloors(startFloor: _listViewController.length()))
// Filter manually hidden floors
.filter((element) => !SettingsProvider.getInstance()
.hiddenMyReplies
.contains(element.floor_id)),

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.

Comment thread lib/page/forum/hole_detail.dart Outdated
Comment thread lib/page/subpage_forum.dart
@sseu-buhzzi

Copy link
Copy Markdown
Contributor Author

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
@sseu-buhzzi
sseu-buhzzi force-pushed the 20260611/feat-post-filter branch from 7512b4b to f652644 Compare August 2, 2026 13:01
@sseu-buhzzi
sseu-buhzzi requested a review from w568w August 2, 2026 14:14
@w568w

w568w commented Aug 17, 2026

Copy link
Copy Markdown
Member

Sorry for the laaaaaaate reply. I'm so busy recently, thus having no time to review it. I might get it done this week.

@sseu-buhzzi

Copy link
Copy Markdown
Contributor Author

I will try to implement the support for keyboard shortcuts like <C-F> and / next weekend. I would be busy in the coming workdays too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] 内置搜索列以筛选贴子 [Feature Request]楼层添加对键盘上Home,Pgup,Pgdn,End等键的支持,添加搜索功能

2 participants