From 592a9fe8e7c2d343bbc2e7a17af697f2628234dc Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 2 May 2020 13:03:44 -0400 Subject: [PATCH] Have id field on ModelItem base class --- TODO.md | 9 ++++----- src/backend/models/model_item.py | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index c9d0941b..d0e60bc2 100644 --- a/TODO.md +++ b/TODO.md @@ -3,6 +3,7 @@ - add account number binds - rename goto*account → scrollto*account +- fix opacity - fix python error - fix back/front buttons in small window - fix message delegate too tall @@ -17,6 +18,9 @@ - if last room event is a membership change, it won't be visible in timeline - use uiState instead of open_room +- clicking on a room with unread counter to see it move right away is weird +- rooms without messages on first sync +- avatar loading performance problem? ## Refactoring @@ -35,8 +39,6 @@ - Drag-scrolling in room pane a tiny bit activates the delegates -- When zooming in enough, "Mirage " label overflows - - Catch server 5xx errors when sending message and retry - Popups and room settings can't be scrolled when not enough height to show all @@ -44,9 +46,6 @@ - Handle cases where a known account's access token is invalid - If an account is gone from the user's config, discard UI state last page -- First sent message in E2E room is sometimes undecryptable - (can be fixed by logging out and in again) (still valid?) - - After forgetting a room, it comes back because of the "you left" event - `code` and links in quote ("> http://example.com") aren't properly colored diff --git a/src/backend/models/model_item.py b/src/backend/models/model_item.py index b3e5ab57..8789e80d 100644 --- a/src/backend/models/model_item.py +++ b/src/backend/models/model_item.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: LGPL-3.0-or-later +from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, Dict from ..pyotherside_events import ModelItemSet @@ -10,6 +11,7 @@ if TYPE_CHECKING: from .model import Model +@dataclass class ModelItem: """Base class for items stored inside a `Model`. @@ -21,6 +23,9 @@ class ModelItem: and thus allow a `Model` to keep its data sorted. """ + id: Any = field() + + def __new__(cls, *_args, **_kwargs) -> "ModelItem": cls.parent_models: Dict[SyncId, Model] = {} return super().__new__(cls)