-
Notifications
You must be signed in to change notification settings - Fork 45
Add reply and repost counts to note action bar #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Display counts next to the reply and repost icons in the note action bar. The counts are queried from nostrdb and only shown when greater than zero. Spacing is minimal (2px) between icons and counts for a clean appearance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds reply and repost count displays to the note action bar. The counts are fetched from nostrdb and displayed next to their respective icons when greater than zero.
Key Changes:
- Added
count_note_replies
andcount_note_reposts
functions to query nostrdb for counts - Modified
reply_button
andquote_repost_button
to display counts with minimal spacing - Updated
render_note_actionbar
signature to accept and pass count parameters
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
let reply_count = count_note_replies(self.note_context.ndb, txn, self.note.id()); | ||
let repost_count = count_note_reposts(self.note_context.ndb, txn, self.note.id()); |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These queries are executed for every note rendered. Consider caching the counts or batching queries to avoid repeated database lookups, especially when rendering large lists of notes.
Copilot uses AI. Check for mistakes.
ndb.query(txn, &[filter], 500) | ||
.map(|results| results.len()) | ||
.unwrap_or(0) |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query fetches up to 500 results just to count them. Use a count-specific query method if available in nostrdb, or limit the results to a smaller number since only the count is needed.
Copilot uses AI. Check for mistakes.
ndb.query(txn, &[filter], 500) | ||
.map(|results| results.len()) | ||
.unwrap_or(0) |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query fetches up to 500 results just to count them. Use a count-specific query method if available in nostrdb, or limit the results to a smaller number since only the count is needed.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This queries every frame and even with small queries I've seen it's not performant to do this. You may have seen the unseen notification indicator impl, when ndb::query occurs it leads to >5ms many times
|
||
if reply_count > 0 { | ||
ui.add_space(2.0); | ||
ui.label(egui::RichText::new(format!("{}", reply_count)).size(13.0)); |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 13.0 for font size is duplicated in both reply and repost buttons. Consider extracting this to a named constant for consistency and easier maintenance.
Copilot uses AI. Check for mistakes.
let combined_resp = resp.union(put_resp); | ||
|
||
if reply_count > 0 { | ||
ui.add_space(2.0); |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 2.0 for spacing is duplicated in both reply and repost buttons. Consider extracting this to a named constant for consistency and easier maintenance.
Copilot uses AI. Check for mistakes.
Display counts next to the reply and repost icons in the note action bar. The counts are queried from nostrdb and only shown when greater than zero. Spacing is minimal (2px) between icons and counts for a clean appearance.