conversation: add ended banner

Change-Id: I4e58f8da33a2776b6f2cdc15b4f8f11ad8f88482
This commit is contained in:
Kateryna Kostiuk
2025-08-26 14:01:49 -04:00
committed by Adrien Béraud
parent d8f548261d
commit faba758254
2 changed files with 72 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ Rectangle {
color: JamiTheme.chatviewBgColor
property var mapPositions: PositionManager.mapStatus
property bool isConversationEndedFlag: false
// The purpose of this alias is to make the message bar
// accessible to the EmojiPicker
@@ -85,6 +86,32 @@ Rectangle {
}
}
function isConversationEnded() {
if (!CurrentConversation.isSwarm)
return false;
var myRole = UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, CurrentAccount.uri);
var info = ConversationsAdapter.getConvInfoMap(CurrentConversation.id);
var peers = info && info.uris ? info.uris : [];
peers = peers.filter(function(u) { return u !== CurrentAccount.uri; });
for (var i = 0; i < peers.length; i++) {
var role = UtilsAdapter.getParticipantRole(CurrentAccount.id, CurrentConversation.id, peers[i]);
if (!(role === Member.Role.LEFT || role === Member.Role.BANNED)) {
return false;
}
}
if (CurrentConversation.isCoreDialog) {
return true
}
return myRole !== Member.Role.ADMIN;
}
function updateConversationEndedFlag() {
var newVal = isConversationEnded();
if (isConversationEndedFlag !== newVal) {
isConversationEndedFlag = newVal;
}
}
// Used externally to switch to a extras panel.
function switchToPanel(panel, toggle = true) {
extrasPanel.switchToPanel(panel, toggle);
@@ -102,16 +129,33 @@ Rectangle {
}
}
Connections {
target: LRCInstance
function onConversationUpdated(convId, accountId) {
if (convId === CurrentConversation.id) {
updateConversationEndedFlag();
}
}
}
Connections {
target: CurrentConversation.members
function onCountChanged() {
updateConversationEndedFlag();
}
}
Connections {
target: CurrentConversation
function onIdChanged() {
MessagesAdapter.loadMoreMessages();
updateConversationEndedFlag();
}
}
onVisibleChanged: {
if (visible) {
chatViewSplitView.resolvePanes(true);
Qt.callLater(updateConversationEndedFlag);
}
}
@@ -196,6 +240,29 @@ Rectangle {
visible: false
}
Control {
id: conversationEndedBanner
Layout.fillWidth: true
visible: isConversationEndedFlag
padding: 10
background: Rectangle {
color: JamiTheme.infoRectangleColor
radius: 5
}
contentItem: RowLayout {
spacing: 8
Label {
text: JamiStrings.conversationEnded
color: JamiTheme.textColor
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
}
}
}
NotificationArea {
id: notificationArea
Layout.fillWidth: true
@@ -333,6 +400,8 @@ Rectangle {
return false;
else if (CurrentConversation.isRequest)
return false;
else if (isConversationEndedFlag)
return false;
return CurrentConversation.isSwarm || CurrentConversation.isTemporary;
}

View File

@@ -368,6 +368,9 @@ Item {
property string deletedMedia: qsTr("%1 deleted a media")
property string returnToCall: qsTr("Return to call")
// Conversation ended banner
property string conversationEnded: qsTr("This conversation has ended.")
// MessagesResearch
property string jumpTo: qsTr("Jump to")
property string messages: qsTr("Messages")