Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ./preserved_properties
import ./urls_model
import ../../../../../../app/modules/shared_models/link_preview_model as link_preview_model
import ../../../../../../app/modules/shared_models/payment_request_model as payment_request_model
import ../../../../../../app/modules/shared_models/default_emoji_reactions_model as default_emoji_reactions_model

QtObject:
type
Expand All @@ -20,8 +19,6 @@ QtObject:
urlsModelVariant: QVariant
sendingInProgress: bool
askToEnableLinkPreview: bool
defaultEmojiReactionsModel: default_emoji_reactions_model.Model
defaultEmojiReactionsModelVariant: QVariant

proc setSendingInProgress*(self: View, value: bool)

Expand All @@ -39,8 +36,6 @@ QtObject:
result.urlsModel = newUrlsModel()
result.urlsModelVariant = newQVariant(result.urlsModel)
result.askToEnableLinkPreview = false
result.defaultEmojiReactionsModel = newDefaultEmojiReactionsModel()
result.defaultEmojiReactionsModelVariant = newQVariant(result.defaultEmojiReactionsModel)

proc load*(self: View) =
self.delegate.viewDidLoad()
Expand Down
82 changes: 0 additions & 82 deletions src/app/modules/shared_models/default_emoji_reactions_model.nim

This file was deleted.

8 changes: 0 additions & 8 deletions src/app/modules/shared_models/message_item.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ../../../app_service/service/message/dto/link_preview
import ../../../app_service/service/message/dto/payment_request
import ./link_preview_model as link_preview_model
import ./payment_request_model as payment_request_model
import ./default_emoji_reactions_model as default_emoji_reactions_model

export types.ContentType
import message_reaction_model, message_transaction_parameters_item
Expand Down Expand Up @@ -53,7 +52,6 @@ type
deletedByContactDetails: ContactDetails
links: seq[string]
linkPreviewModel: link_preview_model.Model
defaultEmojiReactionsModel: default_emoji_reactions_model.Model
transactionParameters: TransactionParametersItem
mentionedUsersPks: seq[string]
senderTrustStatus: TrustStatus
Expand Down Expand Up @@ -172,7 +170,6 @@ proc initMessageItem*(
result.pinned = true
result.links = links
result.linkPreviewModel = newLinkPreviewModel(linkPreviews)
result.defaultEmojiReactionsModel = newDefaultEmojiReactionsModel()
result.transactionParameters = transactionParameters
result.mentionedUsersPks = mentionedUsersPks
result.gapFrom = 0
Expand Down Expand Up @@ -515,11 +512,9 @@ proc getReactionId*(self: Item, emoji: string, userPublicKey: string): string =
proc addReaction*(self: Item, emoji: string, didIReactWithThisEmoji: bool, userPublicKey: string,
userDisplayName: string, reactionId: string) =
self.reactionsModel.addReaction(emoji, didIReactWithThisEmoji, userPublicKey, userDisplayName, reactionId)
self.defaultEmojiReactionsModel.setItemDidIReactWithThisEmoji(emoji, didIReactWithThisEmoji)

proc removeReaction*(self: Item, emoji: string, reactionId: string, didIRemoveThisReaction: bool) =
self.reactionsModel.removeReaction(emoji, reactionId, didIRemoveThisReaction)
self.defaultEmojiReactionsModel.setItemDidIReactWithThisEmoji(emoji, not didIRemoveThisReaction)

proc messageAttachments*(self: Item): seq[string] {.inline.} =
self.messageAttachments
Expand All @@ -536,9 +531,6 @@ proc linkPreviewModel*(self: Item): link_preview_model.Model {.inline.} =
proc paymentRequestModel*(self: Item): payment_request_model.Model {.inline.} =
return self.paymentRequestModel

proc defaultEmojiReactionsModel*(self: Item): default_emoji_reactions_model.Model {.inline.} =
return self.defaultEmojiReactionsModel

proc mentionedUsersPks*(self: Item): seq[string] {.inline.} =
self.mentionedUsersPks

Expand Down
4 changes: 0 additions & 4 deletions src/app/modules/shared_models/message_model.nim
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ type
DeletedByContactIcon
Links
LinkPreviewModel
DefaultEmojiReactionsModel
TransactionParameters
MentionedUsersPks
SenderTrustStatus
Expand Down Expand Up @@ -161,7 +160,6 @@ QtObject:
ModelRole.DeletedByContactIcon.int: "deletedByContactIcon",
ModelRole.Links.int: "links",
ModelRole.LinkPreviewModel.int: "linkPreviewModel",
ModelRole.DefaultEmojiReactionsModel.int: "defaultEmojiReactionsModel",
ModelRole.TransactionParameters.int: "transactionParameters",
ModelRole.MentionedUsersPks.int: "mentionedUsersPks",
ModelRole.SenderTrustStatus.int: "senderTrustStatus",
Expand Down Expand Up @@ -331,8 +329,6 @@ QtObject:
result = newQVariant(item.links.join(" "))
of ModelRole.LinkPreviewModel:
result = newQVariant(item.linkPreviewModel)
of ModelRole.DefaultEmojiReactionsModel:
result = newQVariant(item.defaultEmojiReactionsModel)
of ModelRole.TransactionParameters:
result = newQVariant($(%*{
"id": item.transactionParameters.id,
Expand Down
40 changes: 5 additions & 35 deletions storybook/pages/MessageContextMenuViewPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts

import StatusQ.Core.Theme
import StatusQ.Core.Utils as StatusQUtils

import Storybook

Expand All @@ -14,40 +15,6 @@ SplitView {

Logs { id: logs }

ListModel {
id: defaultEmojiReactionsModel
ListElement {
emoji: "❤️"
filename: "emojiReactions/heart"
didIReactWithThisEmoji: false
}
ListElement {
emoji: "👍"
filename: "emojiReactions/thumbsUp"
didIReactWithThisEmoji: false
}
ListElement {
emoji: "👎"
filename: "emojiReactions/thumbsDown"
didIReactWithThisEmoji: false
}
ListElement {
emoji: "😂"
filename: "emojiReactions/laughing"
didIReactWithThisEmoji: false
}
ListElement {
emoji: "😢"
filename: "emojiReactions/sad"
didIReactWithThisEmoji: false
}
ListElement {
emoji: "😡"
filename: "emojiReactions/angry"
didIReactWithThisEmoji: false
}
}

SplitView {
orientation: Qt.Vertical
SplitView.fillWidth: true
Expand All @@ -70,7 +37,10 @@ SplitView {
closePolicy: Popup.NoAutoClose

messageId: "Oxdeadbeef"
defaultEmojiReactionsModel: defaultEmojiReactionsModel
emojiModel: StatusQUtils.Emoji.emojiModel
// Should still show only 5 emojis even if more are provided
recentEmojis: ["1f9de", "1f6fa", "1f44d", "1f44e", "1f602", "1f622", "1f621"]
skinColor: ""
messageContentType: Constants.messageContentType.messageType
chatType: Constants.chatType.oneToOne
isDebugEnabled: isDebugEnabledCheckBox.checked
Expand Down
3 changes: 2 additions & 1 deletion storybook/pages/StatusEmojiPopupPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ SplitView {
height: 440
visible: true
modal: false
settings: settings
recentEmojis: settings.recentEmojis
skinColor: settings.skinColor
emojiModel: StatusQUtils.Emoji.emojiModel
onEmojiSelected: function(emoji, atCu, hexcode) {
logs.logEvent("onEmojiSelected", ["emoji", "atCu", "hexcode"], arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def test_1x1_chat_add_contact_in_settings(multiple_instances):
local_picture = configs.testpath.TEST_IMAGES / 'comm_logo.jpeg'
picture = BASE_64_IMAGE_JPEG

EMOJI_PATHES = ["❤️", "👍", "👎", "😂", "😢", "😡"]
# First five emojis in the reactions before there are custom ones
EMOJI_PATHES = ["😀", "😃", "😄", "😁", "😆"]

with (multiple_instances(user_data=None) as aut_one, multiple_instances(user_data=None) as aut_two):
with step(f'Launch multiple instances with authorized users {user_one.name} and {user_two.name}'):
Expand Down Expand Up @@ -186,7 +187,7 @@ def test_1x1_chat_add_contact_in_settings(multiple_instances):
f"Last message does not have reply corner"

with step(f'User {user_one.name}, add reaction to the last message and verify it was added'):
occurrence = random.randint(1, 6)
occurrence = random.randint(1, 5)
message.open_context_menu_for_message().add_reaction_to_message(occurrence)
assert driver.waitFor(lambda: EMOJI_PATHES[occurrence - 1] in str(message.get_emoji_reactions_pathes()[0]),
timeout), \
Expand Down
2 changes: 0 additions & 2 deletions ui/app/AppLayouts/Chat/stores/RootStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ QtObject {

property MessageStore messageStore: MessageStore { }

property var defaultEmojiReactionsModel

property var globalUtilsInst: globalUtils

property var mainModuleInst: mainModule
Expand Down
1 change: 0 additions & 1 deletion ui/app/AppLayouts/Chat/views/ChatMessagesView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ Item {
pinnedMessage: model.pinned
messagePinnedBy: model.pinnedBy
reactionsModel: model.reactions
defaultEmojiReactionsModel: model.defaultEmojiReactionsModel
sticker: model.sticker
stickerPack: model.stickerPack
editModeOn: model.editMode
Expand Down
10 changes: 4 additions & 6 deletions ui/app/mainui/AppMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ Item {
contactsStore: appMain.contactsStore
currencyStore: appMain.currencyStore
communityTokensStore: appMain.communityTokensStore
defaultEmojiReactionsModel: appMain.rootStore.defaultEmojiReactionsModel
openCreateChat: createChatView.opened
networkConnectionStore: appMain.networkConnectionStore
}
Expand Down Expand Up @@ -1180,8 +1179,11 @@ Item {
sourceComponent: StatusEmojiPopup {
directParent: appMain.Window.window.contentItem
height: 440
settings: appMainLocalSettings
recentEmojis: appMainLocalSettings.recentEmojis
skinColor: appMainLocalSettings.skinColor
emojiModel: SQUtils.Emoji.emojiModel
onSetSkinColor: color => appMainLocalSettings.skinColor = color
onSetRecentEmojis: recentEmojis => appMainLocalSettings.recentEmojis = recentEmojis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be cleaner to actually have a small Settings {} inside the popup and encapsulate the skinColor and recentEmojis entirely inside the popup. I'd consider that way cleaner than it is now; some of those settigns are handled inside the popup (in the opened/closed handlers), and some outside here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the opposite side - externalizing gives better flexibility, reusability and it's easier/cleaner to test. API is then big wider, but it's what actually the component needs.

}
}

Expand Down Expand Up @@ -1909,7 +1911,6 @@ Item {
contactsStore: appMain.contactsStore
currencyStore: appMain.currencyStore
communityTokensStore: appMain.communityTokensStore
defaultEmojiReactionsModel: appMain.rootStore.defaultEmojiReactionsModel
openCreateChat: createChatView.opened
networkConnectionStore: appMain.networkConnectionStore
isChatSectionModule: true
Expand Down Expand Up @@ -2242,7 +2243,6 @@ Item {
contactsStore: appMain.contactsStore
currencyStore: appMain.currencyStore
communityTokensStore: appMain.communityTokensStore
defaultEmojiReactionsModel: appMain.rootStore.defaultEmojiReactionsModel
openCreateChat: createChatView.opened
walletStore: WalletStores.RootStore
isChatSectionModule: true
Expand Down Expand Up @@ -2320,7 +2320,6 @@ Item {
contactsStore: appMain.contactsStore
currencyStore: appMain.currencyStore
communityTokensStore: appMain.communityTokensStore
defaultEmojiReactionsModel: appMain.rootStore.defaultEmojiReactionsModel
openCreateChat: createChatView.opened
isChatSectionModule: false
communityId: model.id
Expand Down Expand Up @@ -2392,7 +2391,6 @@ Item {
contactsStore: appMain.contactsStore
currencyStore: appMain.currencyStore
communityTokensStore: appMain.communityTokensStore
defaultEmojiReactionsModel: appMain.rootStore.defaultEmojiReactionsModel
openCreateChat: createChatView.opened
isChatSectionModule: true
}
Expand Down
21 changes: 10 additions & 11 deletions ui/imports/shared/controls/chat/EmojiReaction.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ import QtQuick

import StatusQ.Core
import StatusQ.Core.Theme
import StatusQ.Components

import utils
import shared
import shared.panels

Rectangle {
property alias source: reactionImage.source
property string emoji
required property string emojiId
property bool reactedByUser: false
property bool isHovered: false
signal closeModal()
signal toggleReaction()

id: root
width: reactionImage.width + Theme.halfPadding
width: statusEmoji.width + Theme.halfPadding
height: width
color: reactedByUser ? Theme.palette.secondaryBackground :
(isHovered ? Theme.palette.backgroundHover : Theme.palette.transparent)
border.width: reactedByUser ? 1 : 0
border.color: Theme.palette.primaryColor1
radius: Theme.radius

SVGImage {
id: reactionImage
width: 32
fillMode: Image.PreserveAspectFit
StatusEmoji {
id: statusEmoji
anchors.centerIn: parent
width: 20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a fixed size or something dynamic for the times coming? ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the design, but you're right, the design was for Desktop only. What do you suggest to make it more dynamic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed value is far from ideal but the question is what should be the base for that size. Maybe it could be derived from some font size (from Theme of), done using FontMentrics?

height: 20
emojiId: root.emojiId
}

StatusMouseArea {
Expand All @@ -36,8 +37,6 @@ Rectangle {
hoverEnabled: !reactedByUser
onEntered: root.isHovered = true
onExited: root.isHovered = false
onClicked: {
root.closeModal();
}
onClicked: root.toggleReaction()
}
}
Loading