-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix #1 - Implement refresh button event handler #2
base: main
Are you sure you want to change the base?
Conversation
@@ -85,6 +87,22 @@ impl Headlines { | |||
} | |||
|
|||
pub fn render_news_cards(&self, ui: &mut eframe::egui::Ui) { | |||
if self.config.refresh_news_data{ | |||
let default_loading_msg = NewsCardData { |
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.
We could do this, but this seems unnecessary. Reason: We're needlessly adding dummy data, only to render a loading state.
@@ -24,13 +24,15 @@ pub enum Msg { | |||
pub struct HeadlinesConfig { | |||
pub dark_mode: bool, | |||
pub api_key: String, | |||
pub refresh_news_data: bool, |
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 need not be part of HeadlinesConfig
as it's a state that is applicable while the app is running.
if self.config.refresh_news_data{ | ||
self.config.refresh_news_data = false; | ||
// tracing::error!("Refresh event triggered."); | ||
let (mut news_tx, _news_rx) = channel(); |
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.
We're also creating a fresh channel pair in update method, which isn't ideal.
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.
Great, that's one way to approach it :) But I believe this can be done more succinctly. Can you think of using the existing app_tx, app_rx pair to make this work?
PS: I'll be describing how I approached it in the next video
No description provided.