Skip to content

Commit

Permalink
Merge pull request #1665 from Jedsek/patch-2
Browse files Browse the repository at this point in the history
Minor update: `example/qr_code`
  • Loading branch information
hecrj authored Feb 17, 2023
2 parents c2a5f05 + ac19454 commit 27ba0be
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/qr_code/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 27ba0be

Please sign in to comment.