Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions headlines/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,20 @@ impl App for Headlines {
let news_tx_web = news_tx.clone();

#[cfg(not(target_arch = "wasm32"))]
thread::spawn(move || {
if !api_key.is_empty() {
fetch_news(&api_key, &mut news_tx);
} else {
loop {
match app_rx.recv() {
Ok(Msg::ApiKeySet(api_key)) => {
fetch_news(&api_key, &mut news_tx);
}
Ok(Msg::Refresh) => {
fetch_news(&api_key, &mut news_tx);
}
Err(e) => {
tracing::error!("failed receiving msg: {}", e);
}
if !api_key.is_empty() {
fetch_news(&api_key, &mut news_tx);
}

#[cfg(not(target_arch = "wasm32"))]
thread::spawn(move || loop {

if let Ok(rx) = app_rx.recv() {
match rx {
Msg::ApiKeySet(api_key) => {
fetch_news(&api_key, &mut news_tx);
}
Msg::Refresh => {
fetch_news(&api_key, &mut news_tx);
}
}
}
Expand Down