[FL-1803] Archive: fix update_offset logic #695

This commit is contained in:
its your bedtime 2021-09-10 20:06:34 +03:00 committed by GitHub
parent a0d2e4c6a4
commit a4dae290e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,6 @@ void archive_browser_set_callback(
void update_offset(ArchiveMainView* main_view) {
furi_assert(main_view);
with_view_model(
main_view->view, (ArchiveMainViewModel * model) {
size_t array_size = files_array_size(model->files);
@ -50,7 +49,7 @@ void update_offset(ArchiveMainView* main_view) {
if(array_size > 3 && model->idx >= array_size - 1) {
model->list_offset = model->idx - 3;
} else if(model->list_offset < model->idx - bounds) {
model->list_offset = CLAMP(model->list_offset + 1, array_size - bounds, 0);
model->list_offset = CLAMP(model->idx - 2, array_size - bounds, 0);
} else if(model->list_offset > model->idx - bounds) {
model->list_offset = CLAMP(model->idx - 1, array_size - bounds, 0);
}