Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

harshadsabne
Copy link

No description provided.

@@ -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 {
Copy link
Owner

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,
Copy link
Owner

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();
Copy link
Owner

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.

Copy link
Owner

@creativcoder creativcoder left a 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

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.

2 participants