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