From 963b022f3d876a5b242275a0d83cac002a57866d Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 8 Jul 2020 17:26:52 -0400 Subject: [PATCH] Reload member device list when they change --- TODO.md | 1 - src/backend/nio_callbacks.py | 3 +++ src/backend/pyotherside_events.py | 7 +++++++ src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml | 9 +++++++++ src/gui/PythonBridge/EventHandlers.qml | 8 ++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index b6ae6d44..6b1355c3 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,5 @@ # TODO -- reload devices when needed - get devices for members with no shared E2E room? - keyboard controls - remove useless Base imports in Base components diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index 7f3a5515..dcf7c276 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -12,6 +12,7 @@ import nio from .html_markdown import HTML_PROCESSOR from .models.items import TypeSpecifier +from .pyotherside_events import DevicesUpdated from .utils import classes_defined_in, plain2html if TYPE_CHECKING: @@ -123,6 +124,8 @@ class NioCallbacks: else: await self.client.register_nio_room(room) + DevicesUpdated(self.user_id) + # Room events, invite events and misc events callbacks diff --git a/src/backend/pyotherside_events.py b/src/backend/pyotherside_events.py index 7384103e..7e9daa3d 100644 --- a/src/backend/pyotherside_events.py +++ b/src/backend/pyotherside_events.py @@ -90,3 +90,10 @@ class ModelItemDeleted(ModelEvent): @dataclass class ModelCleared(ModelEvent): """Indicate that a `Backend` `Model` was cleared.""" + + +@dataclass +class DevicesUpdated(PyOtherSideEvent): + """Indicate changes in devices for us or users we share a room with.""" + + our_user_id: str = field() diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml b/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml index c9ae034a..8ca24557 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml @@ -132,4 +132,13 @@ HListView { Component.onCompleted: loadDevices() Keys.onEscapePressed: stackView.pop() + + + Connections { + target: py.eventHandlers + + function onDeviceUpdateSignal(forAccount) { + if (forAccount === profile.userId) profile.loadDevices() + } + } } diff --git a/src/gui/PythonBridge/EventHandlers.qml b/src/gui/PythonBridge/EventHandlers.qml index 5c9f3902..162d9e18 100644 --- a/src/gui/PythonBridge/EventHandlers.qml +++ b/src/gui/PythonBridge/EventHandlers.qml @@ -5,6 +5,9 @@ import ".." import "../.." QtObject { + signal deviceUpdateSignal(string forAccount) + + function onExitRequested(exitCode) { Qt.exit(exitCode) } @@ -82,4 +85,9 @@ QtObject { // print("clear", syncId) ModelStore.get(syncId).clear() } + + + function onDevicesUpdated(forAccount) { + deviceUpdateSignal(forAccount) + } }