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;
|
||||
}
|
||||
|
||||
if visible_range.end >= self.delegate.rows_count() - self.delegate.load_more_threshold() {
|
||||
cx.spawn(|view, mut cx| async move {
|
||||
cx.update(|cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.delegate.load_more(cx);
|
||||
let row_count = self.delegate.rows_count();
|
||||
let load_more_count = self.delegate.load_more_threshold();
|
||||
|
||||
// Securely handle subtract logic to prevent attempt to subtract with overflow
|
||||
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