Securely handle table load more subtract logic to prevent attempt to subtract with overflow panic (#189)
This commit is contained in:
parent
b6ce44c349
commit
fd2f5e46f2
1 changed files with 13 additions and 8 deletions
|
|
@ -679,15 +679,20 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if visible_range.end >= self.delegate.rows_count() - self.delegate.load_more_threshold() {
|
let row_count = self.delegate.rows_count();
|
||||||
cx.spawn(|view, mut cx| async move {
|
let load_more_count = self.delegate.load_more_threshold();
|
||||||
cx.update(|cx| {
|
|
||||||
view.update(cx, |view, cx| {
|
// Securely handle subtract logic to prevent attempt to subtract with overflow
|
||||||
view.delegate.load_more(cx);
|
if row_count >= load_more_count {
|
||||||
|
if visible_range.end >= row_count - load_more_count {
|
||||||
|
cx.spawn(|view, mut cx| async move {
|
||||||
|
cx.update(|cx| {
|
||||||
|
view.update(cx, |view, cx| {
|
||||||
|
view.delegate.load_more(cx);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
}).detach()
|
||||||
})
|
}
|
||||||
.detach();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue