From b3b12014ee8fc0e1380e766e06c21257ef7cafee Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 22 May 2020 07:31:00 -0400 Subject: [PATCH] Workaround collapsing large account ListView bug --- TODO.md | 1 + src/backend/models/model.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/TODO.md b/TODO.md index 9506c8da..57803aa9 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,6 @@ # TODO +- timer fix thing - highlight messages being responded to - highlight messages with mention - add room members loading indicator diff --git a/src/backend/models/model.py b/src/backend/models/model.py index e1422789..a7d08127 100644 --- a/src/backend/models/model.py +++ b/src/backend/models/model.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import itertools +import time from bisect import bisect from contextlib import contextmanager from threading import RLock @@ -193,8 +194,21 @@ class Model(MutableMapping): finally: indice = self._active_batch_remove_indice groups = [list(group) for item, group in itertools.groupby(indice)] + last = None + + if groups: + last = groups[-1].pop() + if not groups[-1]: + del groups[-1] for grp in groups: ModelItemDeleted(self.sync_id, index=grp[0], count=len(grp)) + # Seems QML ListView has an horrible bug where removing a large + # amount of items at once will result in a corrupted empty display, + # this dumb workaround is the only way I've found + if last: + time.sleep(0.2) + ModelItemDeleted(self.sync_id, index=last, count=1) + self._active_batch_remove_indice = None