From c8f3a4937ca74c66b16696a5dd35f73dde52fc57 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 22 May 2020 16:47:15 -0400 Subject: [PATCH] Fix potential exceptions on AllRooms model __init__ Calling super().__init__ may result in source model items being added, which needs the self.account and self._collapsed attributes to already exist. --- src/backend/models/special_models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backend/models/special_models.py b/src/backend/models/special_models.py index 582582cb..5eb24374 100644 --- a/src/backend/models/special_models.py +++ b/src/backend/models/special_models.py @@ -13,13 +13,12 @@ class AllRooms(FieldSubstringFilter): """Flat filtered list of all accounts and their rooms.""" def __init__(self, accounts: Model) -> None: + self.accounts = accounts + self._collapsed: Set[str] = set() + super().__init__(sync_id="all_rooms", fields=("display_name",)) self.items_changed_callbacks.append(self.refilter_accounts) - self.accounts = accounts - - self._collapsed: Set[str] = set() - def set_account_collapse(self, user_id: str, collapsed: bool) -> None: """Set whether the rooms for an account should be filtered out."""