Handle room invites

Add them to the roomList, and have separate sections:
Invites and Rooms.
This commit is contained in:
miruka 2019-04-21 06:56:59 -04:00
parent 21ca38117d
commit 2c5dc7bd4f
6 changed files with 35 additions and 6 deletions

View File

@ -15,6 +15,8 @@
- ![A picture](https://picsum.photos/256/256) not clickable?
- UI
- One line label componant
- Collapsible roomList sections, + button
- Reorganize SidePane
- Proper theme, with components taking their colors from theme settings
- Settings page

View File

@ -116,7 +116,7 @@ class Client(QObject):
def _on_sync(self, response: nr.SyncResponse) -> None:
self.nio.receive_response(response)
for room_id in response.rooms.invite:
for room_id, room_info in response.rooms.invite.items():
self.roomInvited.emit(room_id)
for room_id, room_info in response.rooms.join.items():

View File

@ -62,13 +62,15 @@ class User(ListItem):
class Room(ListItem):
roles = ("roomId", "displayName", "topic", "typingUsers")
roles = ("roomId", "category", "displayName", "topic", "typingUsers")
categoryChanged = pyqtSignal(str)
displayNameChanged = pyqtSignal("QVariant")
topicChanged = pyqtSignal(str)
typingUsersChanged = pyqtSignal("QVariantList")
roomId = prop(str, "roomId")
category = prop(str, "category")
displayName = prop(str, "displayName", displayNameChanged)
topic = prop(str, "topic", topicChanged, "")
typingUsers = prop(list, "typingUsers", typingUsersChanged, [])

View File

@ -7,6 +7,7 @@ from typing import Any, Deque, Dict, List, Optional
from PyQt5.QtCore import QDateTime, QObject, pyqtBoundSignal
import nio
from nio.rooms import MatrixRoom
from .backend import Backend
from .client import Client
@ -54,24 +55,29 @@ class SignalManager(QObject):
def onRoomInvited(self, client: Client, room_id: str) -> None:
pass # TODO
self._add_room(client, client.nio.invited_rooms[room_id], "Invites")
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:
model = self.backend.models.rooms[client.userId]
room = client.nio.rooms[room_id]
def group_name() -> Optional[str]:
name = room.group_name()
return None if name == "Empty room?" else name
item = Room(
roomId = room_id,
roomId = room.room_id,
category = category,
displayName = room.name or room.canonical_alias or group_name(),
topic = room.topic,
)
model.updateOrAppendWhere("roomId", room_id, item)
model.updateOrAppendWhere("roomId", room.room_id, item)
def onRoomLeft(self, client: Client, room_id: str) -> None:

View File

@ -0,0 +1,16 @@
import QtQuick 2.7
import "../base" as Base
Base.HLabel {
width: roomList.width
height: text.height
// topPadding is provided by the roomList spacing
bottomPadding: roomList.spacing
text: section
elide: Text.ElideRight
maximumLineCount: 1
font.bold: true
}

View File

@ -18,4 +18,7 @@ ListView {
spacing: 8
model: Backend.models.rooms.get(forUserId)
delegate: RoomDelegate {}
section.property: "category"
section.delegate: RoomCategoryDelegate {}
}