Skip to content

Commit 3bdea9a

Browse files
author
cht
committed
use result to none
1 parent 8b71c3e commit 3bdea9a

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/subscribe/appsub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct AppSub {
3636
// subscribes's information
3737
pub informations: Vec<Vec<spider::Information>>,
3838
pub subscription: Vec<String>,
39-
pub receiver: Option<Receiver<Vec<Vec<String>>>>,
39+
pub receiver: Option<Receiver<reqwest::Result<Vec<Vec<String>>>>>,
4040
pub popinfomation: String,
4141
}
4242
impl AppSub {

src/subscribe/state.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::{env, io, process::Command};
77
use tui::widgets::ListState;
88
pub(super) async fn subscribe_state(app: &mut AppSub) -> io::Result<IFEXIT> {
99
if app.receiver.is_some() {
10-
if let Ok(list) = app.receiver.as_mut().unwrap().try_recv() {
11-
if !list.is_empty() {
10+
if let Ok(get_list) = app.receiver.as_mut().unwrap().try_recv() {
11+
if let Ok(list) = get_list {
1212
let mut storge: String = "[\n\n".to_string();
1313
let mut subs: Vec<Vec<String>> = Vec::new();
1414
let mut information: Vec<Vec<spider::Information>> = Vec::new();
@@ -168,17 +168,13 @@ pub(super) async fn subscribe_state(app: &mut AppSub) -> io::Result<IFEXIT> {
168168
.unwrap_or_else(|err| panic!("{}", err));
169169
// .collect();
170170
let (sync_io_tx, sync_io_rx) =
171-
tokio::sync::mpsc::channel::<Vec<Vec<String>>>(100);
171+
tokio::sync::mpsc::channel::<reqwest::Result<Vec<Vec<String>>>>(100);
172172
app.receiver = Some(sync_io_rx);
173173
let input = app.subscription.clone();
174174
app.popinfomation = "Waiting for a moment".to_string();
175175
tokio::spawn(async move {
176176
let get_list = spider::get_the_key(input).await;
177-
if let Ok(list) = get_list {
178-
sync_io_tx.send(list).await.unwrap();
179-
} else {
180-
sync_io_tx.send(vec![]).await.unwrap();
181-
}
177+
sync_io_tx.send(get_list).await.unwrap();
182178
});
183179
}
184180
_ => {}

0 commit comments

Comments
 (0)