Update main.rs
The app should not render qr_code when data is empty
This commit is contained in:
parent
eb4fcba05f
commit
ccd02c525b
1 changed files with 7 additions and 5 deletions
|
|
@ -21,10 +21,7 @@ impl Sandbox for QRGenerator {
|
|||
type Message = Message;
|
||||
|
||||
fn new() -> Self {
|
||||
QRGenerator {
|
||||
qr_code: qr_code::State::new("").ok(),
|
||||
..Self::default()
|
||||
}
|
||||
QRGenerator::default()
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
|
|
@ -36,7 +33,12 @@ impl Sandbox for QRGenerator {
|
|||
Message::DataChanged(mut data) => {
|
||||
data.truncate(100);
|
||||
|
||||
self.qr_code = qr_code::State::new(&data).ok();
|
||||
self.qr_code = if data.is_empty() {
|
||||
None
|
||||
} else {
|
||||
qr_code::State::new(&data).ok()
|
||||
}
|
||||
|
||||
self.data = data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue