Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bbb9861ef | ||
|
|
645285019e | ||
|
|
49133b5f7a | ||
|
|
26b415667a |
41
src/gui.rs
41
src/gui.rs
@@ -109,10 +109,14 @@ impl Main {
|
||||
}
|
||||
|
||||
fn exchange_recv(&mut self) {
|
||||
match self.c.try_recv() {
|
||||
Ok(msg) => self.ntfy2 = msg,
|
||||
_ => {},
|
||||
};
|
||||
loop {
|
||||
match self.c.try_recv() {
|
||||
Ok(msg) => {
|
||||
self.ntfy2 = msg
|
||||
},
|
||||
_ => return,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn exchange_send(&mut self) {
|
||||
@@ -253,7 +257,7 @@ impl Application for Main {
|
||||
self.configuring = None;
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
};
|
||||
},
|
||||
Message::EventOccurred(event) => {
|
||||
match event {
|
||||
@@ -269,6 +273,7 @@ impl Application for Main {
|
||||
self.keys_newly_down.dedup();
|
||||
},
|
||||
};
|
||||
self.exchange();
|
||||
},
|
||||
iced::event::Event::Keyboard(keyboard::Event::KeyReleased{
|
||||
key_code,
|
||||
@@ -288,9 +293,10 @@ impl Application for Main {
|
||||
},
|
||||
None => {},
|
||||
};
|
||||
self.exchange();
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
};
|
||||
},
|
||||
_ => {
|
||||
self.configuring = Some(msg.clone());
|
||||
@@ -306,7 +312,7 @@ impl Application for Main {
|
||||
iced::Event::Keyboard(_) => Some(Message::EventOccurred(event)),
|
||||
_ => None,
|
||||
}),
|
||||
every(std::time::Duration::from_millis(5)).map(|_| Message::Tick),
|
||||
every(std::time::Duration::from_millis(5000)).map(|_| Message::Tick),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -341,7 +347,9 @@ impl Feedback {
|
||||
loop {
|
||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||
match self.read() {
|
||||
Some(msg) if msg.len() > 0 => self.write(msg),
|
||||
Some(msg) if msg.len() > 0 => {
|
||||
self.write(msg.clone());
|
||||
},
|
||||
_ => {},
|
||||
};
|
||||
}
|
||||
@@ -349,12 +357,17 @@ impl Feedback {
|
||||
|
||||
fn read(&mut self) -> Option<String> {
|
||||
return match &self.cfg.url {
|
||||
Some(url) => match reqwest::blocking::get(url) {
|
||||
Ok(resp) => match resp.text() {
|
||||
Ok(text) => Some(text),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
Some(url) => {
|
||||
match reqwest::blocking::get(url) {
|
||||
Ok(resp) => match resp.text() {
|
||||
Ok(text) => Some(text),
|
||||
_ => None,
|
||||
},
|
||||
Err(err) => {
|
||||
eprintln!("feedback.read: cannot fetch: {}", err);
|
||||
None
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user