Skip to content

Commit ae62801

Browse files
Check for valid data before inflating slot metas for search (#81)
1 parent 5151130 commit ae62801

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/app.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,13 @@ impl Summary {
399399
self.tiles.clear();
400400
}
401401

402+
fn validate(&mut self, cx: &Context) {
403+
if self.last_view_interval != Some(cx.view_interval) {
404+
self.clear();
405+
}
406+
self.last_view_interval = Some(cx.view_interval);
407+
}
408+
402409
fn inflate(&mut self, config: &mut Config, cx: &mut Context) {
403410
for tile_id in config.request_tiles(cx.view_interval, false) {
404411
config
@@ -473,10 +480,7 @@ impl Entry for Summary {
473480
let response = ui.allocate_rect(rect, egui::Sense::hover());
474481
let hover_pos = response.hover_pos(); // where is the mouse hovering?
475482

476-
if self.last_view_interval != Some(cx.view_interval) {
477-
self.clear();
478-
}
479-
self.last_view_interval = Some(cx.view_interval);
483+
self.validate(cx);
480484
if self.tiles.is_empty() {
481485
self.inflate(config, cx);
482486
}
@@ -637,6 +641,13 @@ impl Slot {
637641
self.tile_metas_full.clear();
638642
}
639643

644+
fn validate(&mut self, cx: &Context) {
645+
if self.last_view_interval != Some(cx.view_interval) {
646+
self.clear();
647+
}
648+
self.last_view_interval = Some(cx.view_interval);
649+
}
650+
640651
fn inflate(&mut self, config: &mut Config, cx: &mut Context) {
641652
for tile_id in config.request_tiles(cx.view_interval, false) {
642653
config
@@ -908,6 +919,7 @@ impl Entry for Slot {
908919
}
909920

910921
fn inflate_meta(&mut self, config: &mut Config, cx: &mut Context) {
922+
self.validate(cx);
911923
for tile_id in config.request_tiles(cx.view_interval, true) {
912924
self.fetch_meta_tile(tile_id, config, true);
913925
}
@@ -951,10 +963,7 @@ impl Entry for Slot {
951963
let mut hover_pos = response.hover_pos(); // where is the mouse hovering?
952964

953965
if self.expanded {
954-
if self.last_view_interval != Some(cx.view_interval) {
955-
self.clear();
956-
}
957-
self.last_view_interval = Some(cx.view_interval);
966+
self.validate(cx);
958967
if self.tiles.is_empty() {
959968
self.inflate(config, cx);
960969
}

0 commit comments

Comments
 (0)