fix: code review

This commit is contained in:
Richard Ramos 2020-07-20 13:34:20 -04:00 committed by Iuri Matias
parent 5351fb62dc
commit a31610742c
9 changed files with 34 additions and 17 deletions

View File

@ -5,7 +5,7 @@ import ../status/libstatus/settings as status_settings
import ../status/libstatus/types as status_types
import ../status/chat/[chat, message]
import ../status/profile/[profile, devices]
import types
import types
proc toMessage*(jsonMsg: JsonNode): Message

View File

@ -26,9 +26,10 @@ Item {
property bool isEmoji: contentType === Constants.emojiType
property bool isImage: contentType === Constants.imageType
property bool isMessage: contentType === Constants.messageType || contentType === Constants.stickerType
property bool isStatusMessage: contentType === Constants.systemMessagePrivateGroupType
property bool isSticker: contentType === Constants.stickerType
property bool isText: contentType === Constants.messageType
property bool isMessage: isEmoji || isImage || isSticker || isText
property bool isExpired: (outgoingStatus == "sending" && (Math.floor(timestamp) + 180000) < Date.now())

View File

@ -10,7 +10,7 @@ Rectangle {
color: Style.current.lightBlue
visible: responseTo != "" && replyMessageIndex > -1
// childrenRect.height shows a binding loop for soem reason, so we use heights instead
height: this.visible ? lblReplyAuthor.height + ((repliedMessageType == Constants.imageType ? imgReplyImage.height : lblReplyMessage.height) + 5 + 8) : 0
height: this.visible ? lblReplyAuthor.height + ((repliedMessageType === Constants.imageType ? imgReplyImage.height : lblReplyMessage.height) + 5 + 8) : 0
StyledTextEdit {
id: lblReplyAuthor

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
StyledTextEdit {
id: chatTime
visible: (isEmoji || isMessage || isSticker || isImage)
visible: isMessage
color: Style.current.darkGrey
text: {
let messageDate = new Date(Math.floor(timestamp))

View File

@ -57,13 +57,21 @@ Item {
anchors.rightMargin: chatTextItem.chatHorizontalPadding
}
ChatImage {
Loader {
id: chatImageContent
imageWidth: 200
imageSource: image
active: isImage
sourceComponent: chatImageComponent
anchors.left: chatImage.right
}
Component {
id: chatImageComponent
ChatImage {
imageSource: image
imageWidth: 200
}
}
Rectangle {
id: stickerContainer
visible: contentType === Constants.stickerType

View File

@ -18,7 +18,7 @@ Item {
UserImage {
id: chatImage
visible: (isMessage || isEmoji || isImage) && authorCurrentMsg != authorPrevMsg && !isCurrentUser
visible: isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
@ -27,7 +27,7 @@ Item {
UsernameLabel {
id: chatName
visible: (isMessage || isEmoji || isImage) && authorCurrentMsg != authorPrevMsg && !isCurrentUser
visible: isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
text: userName
anchors.leftMargin: 20
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
@ -83,7 +83,7 @@ Item {
anchors.rightMargin: !isCurrentUser ? 0 : Style.current.padding
anchors.top: authorCurrentMsg != authorPrevMsg && !isCurrentUser ? chatImage.top : (dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top)
anchors.topMargin: 0
visible: isMessage || isEmoji || isImage
visible: isMessage
ChatReply {
id: chatReply
@ -110,12 +110,20 @@ Item {
color: !isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor
}
ChatImage {
Loader {
id: chatImageContent
imageWidth: 250
imageSource: image
active: isImage
sourceComponent: chatImageComponent
}
Component {
id: chatImageComponent
ChatImage {
imageSource: image
imageWidth: 250
}
}
Sticker {
id: stickerId
anchors.left: parent.left
@ -130,7 +138,7 @@ Item {
RectangleCorner {
// TODO find a way to show the corner for stickers since they have a border
visible: isMessage || isEmoji
visible: isMessage
}
}

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
StyledText {
id: sentMessage
visible: isCurrentUser && !timeout && (isEmoji || isMessage || isSticker || isImage)
visible: isCurrentUser && !timeout && isMessage
color: Style.current.darkGrey
text: outgoingStatus == "sent" ?
//% "Sent"

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
Rectangle {
id: chatImage
visible: (isMessage || isEmoji) && authorCurrentMsg != authorPrevMsg
visible: isMessage && authorCurrentMsg != authorPrevMsg
width: identiconImage.width
height: identiconImage.height
border.width: 1

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
StyledTextEdit {
id: chatName
visible: (isMessage || isEmoji) && authorCurrentMsg != authorPrevMsg
visible: isMessage && authorCurrentMsg != authorPrevMsg
height: this.visible ? 18 : 0
//% "You"
text: !isCurrentUser ? userName : qsTrId("You")