Show LeftBanner with a generic left text
This commit is contained in:
parent
3ff0e1bd70
commit
03d9079d63
2
TODO.md
2
TODO.md
|
@ -1,3 +1,4 @@
|
|||
- "rejoin" leftbanner button if room is public
|
||||
- daybreak color
|
||||
- html links color
|
||||
- invite/leave/forget backend funcs
|
||||
|
@ -82,6 +83,7 @@ OLD
|
|||
- `org.matrix.room.preview_urls` event
|
||||
- `m.room.aliases` event
|
||||
- Support "Empty room (was ...)" after peer left
|
||||
- Previewing room without joining
|
||||
|
||||
- Distribution
|
||||
- List dependencies
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from datetime import datetime
|
||||
from enum import auto
|
||||
from typing import Dict, List, Optional, Sequence, Type, Union
|
||||
from typing import List, Sequence, Type, Union
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
@ -19,9 +19,7 @@ class RoomUpdated(Event):
|
|||
avatar_url: str = ""
|
||||
topic: str = ""
|
||||
typing_members: Sequence[str] = ()
|
||||
|
||||
inviter_id: str = ""
|
||||
left_event: Optional[nio.RoomMemberEvent] = None
|
||||
inviter_id: str = ""
|
||||
|
||||
|
||||
@classmethod
|
||||
|
@ -29,8 +27,7 @@ class RoomUpdated(Event):
|
|||
user_id: str,
|
||||
category: str,
|
||||
room: MatrixRoom,
|
||||
info: nio.RoomInfo,
|
||||
**fields) -> "RoomUpdated":
|
||||
info: nio.RoomInfo) -> "RoomUpdated":
|
||||
|
||||
typing: List[str] = []
|
||||
|
||||
|
@ -54,7 +51,6 @@ class RoomUpdated(Event):
|
|||
topic = room.topic or "",
|
||||
inviter_id = getattr(room, "inviter", "") or "",
|
||||
typing_members = typing,
|
||||
**fields
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -198,15 +198,17 @@ class MatrixClient(nio.AsyncClient):
|
|||
up(self.user_id, "Rooms", self.rooms[room_id], info)
|
||||
|
||||
for room_id, info in resp.rooms.leave.items():
|
||||
lev = None
|
||||
# TODO: handle in nio, these are rooms that were left before
|
||||
# starting the client.
|
||||
if room_id not in self.rooms:
|
||||
continue
|
||||
|
||||
# TODO: handle left events in nio async client
|
||||
for ev in info.timeline.events:
|
||||
is_member_ev = isinstance(ev, nio.RoomMemberEvent)
|
||||
if isinstance(ev, nio.RoomMemberEvent):
|
||||
await self.onRoomMemberEvent(self.rooms[room_id], ev)
|
||||
|
||||
if is_member_ev and ev.membership in ("leave", "ban"):
|
||||
lev = ev
|
||||
|
||||
up(self.user_id, "Left", self.rooms[room_id], info, left_event=lev)
|
||||
up(self.user_id, "Left", self.rooms[room_id], info)
|
||||
|
||||
|
||||
async def onErrorResponse(self, resp: nio.ErrorResponse) -> None:
|
||||
|
@ -273,7 +275,7 @@ class MatrixClient(nio.AsyncClient):
|
|||
TimelineEventReceived.from_nio(room, ev, content=co)
|
||||
|
||||
|
||||
async def _get_room_member_event_content(self, ev) -> Optional[str]:
|
||||
async def get_room_member_event_content(self, ev) -> Optional[str]:
|
||||
prev = ev.prev_content
|
||||
now = ev.content
|
||||
membership = ev.membership
|
||||
|
@ -345,7 +347,7 @@ class MatrixClient(nio.AsyncClient):
|
|||
status_message = "", # TODO
|
||||
)
|
||||
|
||||
co = await self._get_room_member_event_content(ev)
|
||||
co = await self.get_room_member_event_content(ev)
|
||||
|
||||
if co is not None:
|
||||
TimelineEventReceived.from_nio(room, ev, content=co)
|
||||
|
|
|
@ -30,9 +30,10 @@ Rectangle {
|
|||
HImage {
|
||||
z: 2
|
||||
anchors.fill: parent
|
||||
visible: ! hidden && imageUrl
|
||||
//visible: ! hidden && imageUrl
|
||||
visible: false
|
||||
|
||||
Component.onCompleted: if (imageUrl) { source = imageUrl }
|
||||
//Component.onCompleted: if (imageUrl) { source = imageUrl }
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
sourceSize.width: dimension
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ Banner {
|
|||
|
||||
color: theme.chat.inviteBanner.background
|
||||
|
||||
avatar.name: inviterId ? inviterInfo.displayName : ""
|
||||
avatar.name: inviterId ? (inviterInfo.displayName ||
|
||||
Utils.stripUserId(inviterId)) : ""
|
||||
avatar.imageUrl: inviterId ? inviterInfo.avatarUrl : ""
|
||||
|
||||
labelText: qsTr("%1 invited you to join the room.").arg(
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
import QtQuick 2.7
|
||||
import "../../Base"
|
||||
import "../utils.js" as ChatJS
|
||||
import "../../utils.js" as Utils
|
||||
|
||||
Banner {
|
||||
property var leftEvent: null
|
||||
property string userId: ""
|
||||
readonly property var userInfo: users.getUser(userId)
|
||||
|
||||
color: theme.chat.leftBanner.background
|
||||
|
||||
avatar.name: ChatJS.getLeftBannerAvatarName(leftEvent, chatPage.userId)
|
||||
labelText: ChatJS.getLeftBannerText(leftEvent)
|
||||
// TODO: avatar func auto
|
||||
avatar.name: userInfo.displayName || Utils.stripUserId(userId)
|
||||
avatar.imageUrl: users.getUser(userId).avatarUrl
|
||||
labelText: qsTr("You are not part of this room anymore.")
|
||||
|
||||
buttonModel: [
|
||||
{
|
||||
|
@ -21,8 +24,13 @@ Banner {
|
|||
buttonCallbacks: {
|
||||
"forget": function(button) {
|
||||
button.loading = true
|
||||
Backend.clients.get(chatPage.userId).forgetRoom(chatPage.roomId)
|
||||
pageStack.clear()
|
||||
py.callClientCoro(
|
||||
chatPage.userId, "room_forget", [chatPage.roomId], {},
|
||||
function() {
|
||||
button.loading = false
|
||||
pageStack.clear()
|
||||
}
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ HColumnLayout {
|
|||
{"userId": userId, "roomId": roomId, "category": category}, 1
|
||||
)[0]
|
||||
|
||||
readonly property var sender:
|
||||
users.getWhere({"userId": userId}, 1)[0]
|
||||
readonly property var sender: //TODO: info$
|
||||
users.getUser(userId)
|
||||
|
||||
readonly property bool hasUnknownDevices: false
|
||||
//category == "Rooms" ?
|
||||
|
@ -73,10 +73,10 @@ HColumnLayout {
|
|||
visible: category == "Rooms" && ! hasUnknownDevices
|
||||
}
|
||||
|
||||
//LeftBanner {
|
||||
//visible: category == "Left"
|
||||
//leftEvent: roomInfo.leftEvent
|
||||
//}
|
||||
LeftBanner {
|
||||
visible: category == "Left"
|
||||
userId: chatPage.userId
|
||||
}
|
||||
}
|
||||
|
||||
// RoomSidePane {
|
||||
|
|
|
@ -25,7 +25,7 @@ function typingTextFor(members, our_user_id) {
|
|||
|
||||
function onRoomUpdated(
|
||||
user_id, category, room_id, display_name, avatar_url, topic,
|
||||
typing_members, inviter_id, left_event
|
||||
typing_members, inviter_id
|
||||
) {
|
||||
roomCategories.upsert({"userId": user_id, "name": category}, {
|
||||
"userId": user_id,
|
||||
|
@ -50,8 +50,7 @@ function onRoomUpdated(
|
|||
"avatarUrl": avatar_url,
|
||||
"topic": topic,
|
||||
"typingText": typingTextFor(typing_members, user_id),
|
||||
"inviterId": inviter_id,
|
||||
"leftEvent": left_event ? py.getattr(left_event, "__dict__") : {},
|
||||
"inviterId": inviter_id
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user