diff --git a/harmonyqml/backend/client.py b/harmonyqml/backend/client.py
index f6d90060..5e33cb14 100644
--- a/harmonyqml/backend/client.py
+++ b/harmonyqml/backend/client.py
@@ -10,6 +10,7 @@ from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, pyqtSlot
import nio
import nio.responses as nr
+import nio.events as ne
from .network_manager import NetworkManager
from .pyqt_future import futurize
@@ -22,6 +23,7 @@ _POOLS: DefaultDict[str, ThreadPoolExecutor] = \
class Client(QObject):
roomInvited = pyqtSignal(str)
+ roomInvited = pyqtSignal(str, dict)
roomJoined = pyqtSignal(str)
roomLeft = pyqtSignal(str)
roomSyncPrevBatchTokenReceived = pyqtSignal(str, str)
@@ -117,7 +119,14 @@ class Client(QObject):
self.nio.receive_response(response)
for room_id, room_info in response.rooms.invite.items():
- self.roomInvited.emit(room_id)
+ for ev in room_info.invite_state:
+ member_event = isinstance(ev, ne.InviteMemberEvent)
+
+ if member_event and ev.content["membership"] == "join":
+ self.roomInvited.emit(room_id, ev.content)
+ break
+ else:
+ self.roomInvited.emit(room_id)
for room_id, room_info in response.rooms.join.items():
self.roomJoined.emit(room_id)
diff --git a/harmonyqml/backend/model/items.py b/harmonyqml/backend/model/items.py
index aaa3602b..1f5c5bfe 100644
--- a/harmonyqml/backend/model/items.py
+++ b/harmonyqml/backend/model/items.py
@@ -62,7 +62,8 @@ class User(ListItem):
class Room(ListItem):
- roles = ("roomId", "category", "displayName", "topic", "typingUsers")
+ roles = ("roomId", "category", "displayName", "topic", "typingUsers",
+ "inviter")
categoryChanged = pyqtSignal(str)
displayNameChanged = pyqtSignal("QVariant")
@@ -74,6 +75,7 @@ class Room(ListItem):
displayName = prop(str, "displayName", displayNameChanged)
topic = prop(str, "topic", topicChanged, "")
typingUsers = prop(list, "typingUsers", typingUsersChanged, [])
+ inviter = prop("QVariantMap", "inviter")
class RoomEvent(ListItem):
diff --git a/harmonyqml/backend/signal_manager.py b/harmonyqml/backend/signal_manager.py
index cf0172cb..76ad0ea0 100644
--- a/harmonyqml/backend/signal_manager.py
+++ b/harmonyqml/backend/signal_manager.py
@@ -13,6 +13,8 @@ from .backend import Backend
from .client import Client
from .model.items import Room, RoomEvent, User
+Inviter = Optional[Dict[str, str]]
+
class SignalManager(QObject):
_event_handling_lock: Lock = Lock()
@@ -54,16 +56,24 @@ class SignalManager(QObject):
attr.connect(onSignal)
- def onRoomInvited(self, client: Client, room_id: str) -> None:
- self._add_room(client, client.nio.invited_rooms[room_id], "Invites")
+ def onRoomInvited(self,
+ client: Client,
+ room_id: str,
+ inviter: Inviter = None) -> None:
+ self._add_room(
+ client, client.nio.invited_rooms[room_id], "Invites", inviter
+ )
def onRoomJoined(self, client: Client, room_id: str) -> None:
self._add_room(client, client.nio.rooms[room_id], "Rooms")
- def _add_room(self, client: Client, room: MatrixRoom, category: str
- ) -> None:
+ def _add_room(self,
+ client: Client,
+ room: MatrixRoom,
+ category: str,
+ inviter: Inviter = None) -> None:
model = self.backend.models.rooms[client.userId]
def group_name() -> Optional[str]:
@@ -75,6 +85,7 @@ class SignalManager(QObject):
category = category,
displayName = room.name or room.canonical_alias or group_name(),
topic = room.topic,
+ inviter = inviter,
)
model.updateOrAppendWhere("roomId", room.room_id, item)
diff --git a/harmonyqml/components/chat/InviteOffer.qml b/harmonyqml/components/chat/InviteOffer.qml
index a7701ee8..3a548198 100644
--- a/harmonyqml/components/chat/InviteOffer.qml
+++ b/harmonyqml/components/chat/InviteOffer.qml
@@ -9,20 +9,24 @@ Rectangle {
Layout.preferredHeight: 32
color: "#BBB"
+ property var inviter: null
+
Base.HRowLayout {
id: inviteRow
anchors.fill: parent
Base.Avatar {
id: inviteAvatar
- name: ""
+ name: inviter ? inviter.displayname : ""
dimmension: inviteOffer.Layout.preferredHeight
+ //imageSource: inviter ? inviter.avatar_url : ""
}
Base.HLabel {
id: inviteLabel
- text: "" + "Person" + " " +
- qsTr("invited you to join the room.")
+ text: (inviter ?
+ ("" + inviter.displayname + "") : qsTr("Someone")) +
+ " " + qsTr("invited you to join the room.")
textFormat: Text.StyledText
maximumLineCount: 1
elide: Text.ElideRight
diff --git a/harmonyqml/components/chat/Root.qml b/harmonyqml/components/chat/Root.qml
index 208d769d..cb75df4a 100644
--- a/harmonyqml/components/chat/Root.qml
+++ b/harmonyqml/components/chat/Root.qml
@@ -28,6 +28,7 @@ ColumnLayout {
InviteOffer {
visible: isInvite
+ inviter: roomInfo.inviter
}
SendBox {