fix(@desktop/chat) members' status circle is not always right

fixed to display online status only if is the current user and
if they have been active in the last 7 minutes. Respective color
is shown depending on if they are in "do not disturb" mode or they
have been active more than 5 minutes ago

Closes #3282
This commit is contained in:
Alexandra Betouni 2021-08-27 15:48:53 +03:00 committed by Iuri Matias
parent c11267c13d
commit 8f1ffd96a1
2 changed files with 33 additions and 29 deletions

View File

@ -6,14 +6,20 @@ import "../../../../imports"
import "../components" import "../components"
Item { Item {
id: wrapper
anchors.right: parent.right
anchors.top: applicationWindow.top
anchors.left: parent.left
height: rectangle.height + 4
property string publicKey: "" property string publicKey: ""
property string name: "channelName" property string name: "channelName"
property string lastSeen: "" property string lastSeen: ""
property string identicon property string identicon
property int statusType: Constants.statusType_Online property int statusType: -1
property color offlineColor: Style.current.darkGrey
property bool hovered: false property bool hovered: false
property bool enableMouseArea: true property bool enableMouseArea: true
property bool isOnline: chatsModel.isOnline
property var currentTime property var currentTime
property color color: { property color color: {
if (wrapper.hovered) { if (wrapper.hovered) {
@ -21,16 +27,15 @@ Item {
} }
return Style.current.transparent return Style.current.transparent
} }
property string profileImage: appMain.getProfileImage(publicKey) || "" property string profileImage: appMain.getProfileImage(publicKey) || ""
property bool isCurrentUser: publicKey === profileModel.profile.pubKey property bool isCurrentUser: publicKey === profileModel.profile.pubKey
id: wrapper
anchors.right: parent.right
anchors.top: applicationWindow.top
anchors.left: parent.left
height: rectangle.height + 4
Rectangle { Rectangle {
id: rectangle
width: parent.width
height: 40
radius: 8
color: wrapper.color
Connections { Connections {
target: profileModel.contacts.list target: profileModel.contacts.list
onContactChanged: { onContactChanged: {
@ -40,12 +45,6 @@ Item {
} }
} }
id: rectangle
color: wrapper.color
radius: 8
height: 40
width: parent.width
StatusIdenticon { StatusIdenticon {
id: contactImage id: contactImage
height: 28 height: 28
@ -74,25 +73,29 @@ Item {
} }
Rectangle { Rectangle {
width: 10
height: 10
radius: (width/2)
anchors.left: contactImage.right anchors.left: contactImage.right
anchors.leftMargin: -Style.current.smallPadding anchors.leftMargin: -Style.current.smallPadding
anchors.bottom: contactImage.bottom anchors.bottom: contactImage.bottom
height: 10 visible: wrapper.isOnline
width: 10
radius: 20
color: { color: {
let lastSeenMinutesAgo = (currentTime/1000 - parseInt(lastSeen)) / 60 if (visible) {
if (!chatsModel.isOnline) { var lastSeenMinutesAgo = ((currentTime/1000 - parseInt(lastSeen)) / 60);
return offlineColor if (statusType === Constants.statusType_DoNotDisturb) {
return Style.current.red;
} else if (isCurrentUser || (lastSeenMinutesAgo < 5.5)) {
return Style.current.green;
} else if (((statusType !== -1) && (lastSeenMinutesAgo > 5.5)) ||
((statusType === -1) && (lastSeenMinutesAgo < 7))) {
return Style.current.orange;
} else if ((statusType === -1) && (lastSeenMinutesAgo > 7)) {
return "transparent";
}
} else {
return "transparent";
} }
if (isCurrentUser || lastSeenMinutesAgo < 5.5){
return statusType == Constants.statusType_DoNotDisturb ? Style.current.red : Style.current.green;
} else if (lastSeenMinutesAgo < 7) {
return statusType == Constants.statusType_DoNotDisturb ? Style.current.red : Style.current.orange;
}
return offlineColor
} }
} }

View File

@ -60,6 +60,7 @@ Item {
StyledText { StyledText {
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: Style.current.padding anchors.leftMargin: Style.current.padding
verticalAlignment: Text.AlignVCenter
font.pixelSize: Style.current.additionalTextSize font.pixelSize: Style.current.additionalTextSize
color: Style.current.darkGrey color: Style.current.darkGrey
text: section === 'true' ? qsTr("Online") : qsTr("Offline") text: section === 'true' ? qsTr("Online") : qsTr("Offline")
@ -83,7 +84,7 @@ Item {
lastSeen: model.lastSeen lastSeen: model.lastSeen
statusType: model.statusType statusType: model.statusType
currentTime: root.currentTime currentTime: root.currentTime
offlineColor: "transparent" isOnline: model.online
} }
} }
} }