refactor(chat): refactor send messages to work

This commit is contained in:
Jonathan Rainville 2021-12-22 09:55:13 -05:00 committed by Sale Djenic
parent 807039ad61
commit 710236f51a
21 changed files with 196 additions and 122 deletions

View File

@ -109,4 +109,7 @@ QtObject:
result = &"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 {size + border * 2} {size + border * 2}\" stroke=\"none\"><rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/><path d=\"{partsStr}\" fill=\"#000000\"/></svg>"
proc qrCode*(self: Utils, text:string): string {.slot.} =
result = "data:image/svg+xml;utf8," & self.generateQRCodeSVG(text, 2)
result = "data:image/svg+xml;utf8," & self.generateQRCodeSVG(text, 2)
proc plainText*(self: Utils, text: string): string {.slot.} =
result = plain_text(text)

View File

@ -65,7 +65,7 @@ method convertToItems*[T](
result = activityCenterNotifications.map(
proc(n: ActivityCenterNotificationDto): Item =
var messageItem = MessageItem()
if (n.message.id == ""):
if (n.message.id != ""):
# If there is a message in the Notification, transfer it to a MessageItem (QObject)
let contactDetails = self.controller.getContactDetails(n.message.`from`)
messageItem = message_item_qobject.newMessageItem(initItem(

View File

@ -9,6 +9,7 @@ export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
sectionId: string
chatId: string
belongsToCommunity: bool
communityService: community_service.Service
@ -16,6 +17,7 @@ type
proc newController*(
delegate: io_interface.AccessInterface,
sectionId: string,
chatId: string,
belongsToCommunity: bool,
chatService: chat_service.Service,
@ -23,6 +25,7 @@ proc newController*(
): Controller =
result = Controller()
result.delegate = delegate
result.sectionId = chatId
result.chatId = chatId
result.belongsToCommunity = belongsToCommunity
result.chatService = chatService
@ -43,11 +46,23 @@ method belongsToCommunity*(self: Controller): bool =
method sendImages*(self: Controller, imagePathsJson: string): string =
self.chatService.sendImages(self.chatId, imagePathsJson)
method requestAddressForTransaction*(self: Controller, chatId: string, fromAddress: string, amount: string, tokenAddress: string) =
self.chatService.requestAddressForTransaction(chatId, fromAddress, amount, tokenAddress)
method sendChatMessage*(
self: Controller,
msg: string,
replyTo: string,
contentType: int,
preferredUsername: string = "") =
var communityId = ""
if self.belongsToCommunity:
communityId = self.sectionId
method requestTransaction*(self: Controller, chatId: string, fromAddress: string, amount: string, tokenAddress: string) =
self.chatService.requestAddressForTransaction(chatId, fromAddress, amount, tokenAddress)
self.chatService.sendChatMessage(self.chatId, msg, replyTo, contentType, preferredUsername, communityId)
method requestAddressForTransaction*(self: Controller, fromAddress: string, amount: string, tokenAddress: string) =
self.chatService.requestAddressForTransaction(self.chatId, fromAddress, amount, tokenAddress)
method requestTransaction*(self: Controller, fromAddress: string, amount: string, tokenAddress: string) =
self.chatService.requestAddressForTransaction(self.chatId, fromAddress, amount, tokenAddress)
method declineRequestTransaction*(self: Controller, messageId: string) =
self.chatService.declineRequestTransaction(messageId)

View File

@ -18,10 +18,13 @@ method belongsToCommunity*(self: AccessInterface): bool {.base.} =
method sendImages*(self: AccessInterface, imagePathsJson: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method requestAddressForTransaction*(self: AccessInterface, chatId: string, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
method sendChatMessage*(self: AccessInterface, msg: string, replyTo: string, contentType: int, preferredUsername: string = "") {.base.} =
raise newException(ValueError, "No implementation available")
method requestTransaction*(self: AccessInterface, chatId: string, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
method requestAddressForTransaction*(self: AccessInterface, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
raise newException(ValueError, "No implementation available")
method requestTransaction*(self: AccessInterface, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
raise newException(ValueError, "No implementation available")
method declineRequestTransaction*(self: AccessInterface, messageId: string) {.base.} =

View File

@ -19,6 +19,7 @@ type
proc newModule*(
delegate: delegate_interface.AccessInterface,
sectionId: string,
chatId: string,
belongsToCommunity: bool,
chatService: chat_service.Service,
@ -29,7 +30,7 @@ proc newModule*(
result.delegate = delegate
result.view = view.newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, chatId, belongsToCommunity, chatService, communityService)
result.controller = controller.newController(result, sectionId, chatId, belongsToCommunity, chatService, communityService)
result.moduleLoaded = false
method delete*(self: Module) =
@ -57,11 +58,19 @@ method getChatId*(self: Module): string =
method sendImages*(self: Module, imagePathsJson: string): string =
self.controller.sendImages(imagePathsJson)
method requestAddressForTransaction*(self: Module, chatId: string, fromAddress: string, amount: string, tokenAddress: string) =
self.controller.requestAddressForTransaction(chatId, fromAddress, amount, tokenAddress)
method sendChatMessage*(
self: Module,
msg: string,
replyTo: string,
contentType: int) =
self.controller.sendChatMessage(msg, replyTo, contentType,
singletonInstance.userProfile.getEnsName())
method requestTransaction*(self: Module, chatId: string, fromAddress: string, amount: string, tokenAddress: string) =
self.controller.requestTransaction(chatId, fromAddress, amount, tokenAddress)
method requestAddressForTransaction*(self: Module, fromAddress: string, amount: string, tokenAddress: string) =
self.controller.requestAddressForTransaction(fromAddress, amount, tokenAddress)
method requestTransaction*(self: Module, fromAddress: string, amount: string, tokenAddress: string) =
self.controller.requestTransaction(fromAddress, amount, tokenAddress)
method declineRequestTransaction*(self: Module, messageId: string) =
self.controller.declineRequestTransaction(messageId)

View File

@ -12,13 +12,16 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
raise newException(ValueError, "No implementation available")
method sendChatMessage*(self: AccessInterface, msg: string, replyTo: string, contentType: int) {.base.} =
raise newException(ValueError, "No implementation available")
method sendImages*(self: AccessInterface, imagePathsJson: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method requestAddressForTransaction*(self: AccessInterface, chatId: string, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
method requestAddressForTransaction*(self: AccessInterface, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
raise newException(ValueError, "No implementation available")
method requestTransaction*(self: AccessInterface, chatId: string, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
method requestTransaction*(self: AccessInterface, fromAddress: string, amount: string, tokenAddress: string) {.base.} =
raise newException(ValueError, "No implementation available")
method declineRequestTransaction*(self: AccessInterface, messageId: string) {.base.} =

View File

@ -21,6 +21,13 @@ QtObject:
proc load*(self: View) =
self.delegate.viewDidLoad()
proc sendMessage*(
self: View,
msg: string,
replyTo: string,
contentType: int) {.slot.} =
self.delegate.sendChatMessage(msg, replyTo, contentType)
proc sendImages*(self: View, sendImages: string): string {.slot.} =
self.delegate.sendImages(sendImages)
@ -30,11 +37,11 @@ QtObject:
proc declineAddressRequest*(self: View, messageId: string) {.slot.} =
self.delegate.declineRequestAddressForTransaction(messageId)
proc requestAddress*(self: View, chatId: string, fromAddress: string, amount: string, tokenAddress: string) {.slot.} =
self.delegate.requestAddressForTransaction(chatId, fromAddress, amount, tokenAddress)
proc requestAddress*(self: View, fromAddress: string, amount: string, tokenAddress: string) {.slot.} =
self.delegate.requestAddressForTransaction(fromAddress, amount, tokenAddress)
proc request*(self: View, chatId: string, fromAddress: string, amount: string, tokenAddress: string) {.slot.} =
self.delegate.requestTransaction(chatId, fromAddress, amount, tokenAddress)
proc request*(self: View, fromAddress: string, amount: string, tokenAddress: string) {.slot.} =
self.delegate.requestTransaction(fromAddress, amount, tokenAddress)
proc declineRequest*(self: View, messageId: string) {.slot.} =
self.delegate.declineRequestTransaction(messageId)

View File

@ -52,6 +52,12 @@ method init*(self: Controller) =
return
self.delegate.newMessagesLoaded(args.messages, args.reactions, args.pinnedMessages)
self.events.on(SIGNAL_SENDING_SUCCESS) do(e:Args):
let args = MessageSendingSuccess(e)
if(self.chatId != args.chat.id):
return
self.delegate.newMessagesLoaded(@[args.message], @[], @[])
self.events.on(SIGNAL_MESSAGE_PINNED) do(e:Args):
let args = MessagePinUnpinArgs(e)
if(self.chatId != args.chatId):

View File

@ -48,7 +48,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
isUsersListAvailable, settingsService, contactService, chatService, communityService, messageService)
result.moduleLoaded = false
result.inputAreaModule = input_area_module.newModule(result, chatId, belongsToCommunity, chatService, communityService)
result.inputAreaModule = input_area_module.newModule(result, sectionId, chatId, belongsToCommunity, chatService, communityService)
result.messagesModule = messages_module.newModule(result, events, sectionId, chatId, belongsToCommunity,
contactService, communityService, chatService, messageService)
result.usersModule = users_module.newModule(result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable,

View File

@ -87,8 +87,13 @@ method uninstallStickerPack*[T](self: Controller[T], packId: int) =
method removeRecentStickers*[T](self: Controller[T], packId: int) =
self.stickerService.removeRecentStickers(packId)
method sendSticker*[T](self: Controller[T], channelId: string, replyTo: string, sticker: StickerDto) =
self.stickerService.sendSticker(channelId, replyTo, sticker)
method sendSticker*[T](
self: Controller[T],
channelId: string,
replyTo: string,
sticker: StickerDto,
preferredUsername: string) =
self.stickerService.sendSticker(channelId, replyTo, sticker, preferredUsername)
method decodeContentHash*[T](self: Controller[T], hash: string): string =
eth_utils.decodeContentHash(hash)

View File

@ -44,7 +44,7 @@ method decodeContentHash*(self: AccessInterface, hash: string): string {.base.}
method wei2Eth*(self: AccessInterface, price: Stuint[256]): string {.base.} =
raise newException(ValueError, "No implementation available")
method sendSticker*(self: AccessInterface, channelId: string, replyTo: string, sticker: StickerDto) {.base.} =
method sendSticker*(self: AccessInterface, channelId: string, replyTo: string, sticker: StickerDto, preferredUsername: string) {.base.} =
raise newException(ValueError, "No implementation available")
type

View File

@ -75,7 +75,11 @@ method wei2Eth*[T](self: Module[T], price: Stuint[256]): string =
method sendSticker*[T](self: Module[T], channelId: string, replyTo: string, sticker: Item) =
let stickerDto = StickerDto(hash: sticker.getHash, packId: sticker.getPackId)
self.controller.sendSticker(channelId, replyTo, stickerDto)
self.controller.sendSticker(
channelId,
replyTo,
stickerDto,
singletonInstance.userProfile.getEnsName())
method estimate*[T](self: Module[T], packId: int, address: string, price: string, uuid: string) =
self.controller.estimate(packId, address, price, uuid)

View File

@ -1,24 +1,9 @@
import json, strformat
import Tables, json, strformat
import ../../../app_service/common/types
export types.ContentType
import message_reaction_model, message_reaction_item
type
ContentType* {.pure.} = enum
FetchMoreMessagesButton = -2
ChatIdentifier = -1
Unknown = 0
Message = 1
Sticker = 2
Status = 3
Emoji = 4
Transaction = 5
Group = 6
Image = 7
Audio = 8
Community = 9
Gap = 10
Edit = 11
type
Item* = ref object
id: string

View File

@ -0,0 +1,16 @@
type
ContentType* {.pure.} = enum
FetchMoreMessagesButton = -2
ChatIdentifier = -1
Unknown = 0
Message = 1
Sticker = 2
Status = 3
Emoji = 4
Transaction = 5
Group = 6
Image = 7
Audio = 8
Community = 9
Gap = 10
Edit = 11

View File

@ -175,7 +175,7 @@ QtObject:
try:
let response = status_activity_center.acceptActivityCenterNotifications(notificationIds)
let (chats, messages) = self.chatService.parseChatResponse2(response)
let (chats, messages) = self.chatService.parseChatResponse(response)
self.events.emit(chat_service.SIGNAL_CHAT_UPDATE,
ChatUpdateArgsNew(messages: messages, chats: chats))

View File

@ -94,24 +94,7 @@ QtObject:
proc hasChannel*(self: Service, chatId: string): bool =
self.chats.hasKey(chatId)
# TODO refactor this to new object types
proc parseChatResponse*(self: Service, response: string): (seq[chat_type.Chat], seq[Message]) =
var parsedResponse = parseJson(response)
var chats: seq[Chat] = @[]
var messages: seq[Message] = @[]
if parsedResponse{"result"}{"messages"} != nil:
for jsonMsg in parsedResponse["result"]["messages"]:
messages.add(jsonMsg.toMessage())
if parsedResponse{"result"}{"chats"} != nil:
for jsonChat in parsedResponse["result"]["chats"]:
let chat = chat_type.toChat(jsonChat)
# TODO add the channel back to `chat` when it is refactored
# self.channels[chat.id] = chat
chats.add(chat)
result = (chats, messages)
# TODO refactor this to new object types
proc parseChatResponse2*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =
proc parseChatResponse*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =
var chats: seq[ChatDto] = @[]
var messages: seq[MessageDto] = @[]
if response.result{"messages"} != nil:
@ -125,8 +108,8 @@ QtObject:
chats.add(chat)
result = (chats, messages)
proc processMessageUpdateAfterSend(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =
result = self.parseChatResponse2(response)
proc processMessageUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =
result = self.parseChatResponse(response)
var (chats, messages) = result
if chats.len == 0 and messages.len == 0:
self.events.emit(SIGNAL_SENDING_FAILED, Args())
@ -146,7 +129,7 @@ QtObject:
self.events.emit(SIGNAL_MESSAGE_DELETED, MessageArgs(id: messageId, channel: chats[0].id))
proc emitUpdate(self: Service, response: RpcResponse[JsonNode]) =
var (chats, messages) = self.parseChatResponse2(response)
var (chats, messages) = self.parseChatResponse(response)
self.events.emit(SIGNAL_CHAT_UPDATE, ChatUpdateArgsNew(messages: messages, chats: chats))
proc getAllChats*(self: Service): seq[ChatDto] =
@ -251,6 +234,27 @@ QtObject:
error "Error sending images", msg = e.msg
result = fmt"Error sending images: {e.msg}"
proc sendChatMessage*(
self: Service,
chatId: string,
msg: string,
replyTo: string,
contentType: int,
preferredUsername: string = "",
communityId: string = "") =
try:
let response = status_chat.sendChatMessage(
chatId,
msg,
replyTo,
contentType,
preferredUsername,
communityId)
discard self.processMessageUpdateAfterSend(response)
except Exception as e:
error "Error sending message", msg = e.msg
proc requestAddressForTransaction*(self: Service, chatId: string, fromAddress: string, amount: string, tokenAddress: string) =
try:
let address = if (tokenAddress == ZERO_ADDRESS): "" else: tokenAddress

View File

@ -9,6 +9,7 @@ import web3/ethtypes, web3/conversions, stew/byteutils, nimcrypto, json_serializ
import json, tables, json_serialization
import status/statusgo_backend_new/stickers as status_stickers
import status/statusgo_backend_new/chat as status_chat
import status/statusgo_backend_new/transactions as transactions
import status/statusgo_backend_new/response_type
import status/statusgo_backend_new/eth
@ -19,15 +20,12 @@ import ../wallet_account/service as wallet_account_service
import ../transaction/service as transaction_service
import ../network/service as network_service
import ../chat/service as chat_service
import ../../common/types
import ../eth/utils as status_utils
import ../eth/dto/edn_dto as edn_helper
# TODO Remove those imports once chat is refactored
import status/statusgo_backend/chat as status_chat
import status/types/[sticker]
export StickerDto
export StickerPackDto
@ -375,18 +373,24 @@ QtObject:
discard self.settingsService.saveRecentStickers(installedStickerPacks)
proc sendSticker*(self: Service, chatId: string, replyTo: string, sticker: StickerDto) =
# TODO change this to StcikerDto once it's available
let stickerToSend = Sticker(
hash: sticker.hash,
packId: sticker.packId
)
# TODO change this to the new chat service call once it is available
var response = status_chat.sendStickerMessage(chatId, replyTo, stickerToSend)
proc sendSticker*(
self: Service,
chatId: string,
replyTo: string,
sticker: StickerDto,
preferredUsername: string) =
let response = status_chat.sendChatMessage(
chatId,
"Update to latest version to see a nice sticker here!",
replyTo,
ContentType.Sticker.int,
preferredUsername,
communityId = "", # communityId is not ncessary when sending a sticker
sticker.hash,
sticker.packId)
discard self.chatService.processMessageUpdateAfterSend(response)
self.addStickerToRecent(sticker, true)
var (chats, messages) = self.chatService.parseChatResponse(response)
# TODO change this event when the chat is refactored
self.events.emit("chatUpdate", ChatUpdateArgs(messages: messages, chats: chats))
proc removeRecentStickers*(self: Service, packId: int) =
self.recentStickers.keepItIf(it.packId != packId)

View File

@ -57,6 +57,10 @@ QtObject {
property var addedContacts: contactsModuleModel.addedContacts
property var allContacts: contactsModuleModel.list
function sendSticker(channelId, hash, replyTo, pack) {
stickersModuleInst.send(channelId, hash, replyTo, pack)
}
function copyToClipboard(text) {
// Not Refactored Yet
// chatsModelInst.copyToClipboard(text);

View File

@ -165,6 +165,7 @@ Item {
delegate: Repeater {
model: subItems
delegate: ChatContentView {
rootStore: root.rootStore
Component.onCompleted: {
parentModule.prepareChatContentModuleForChatId(model.itemId)
chatContentModule = parentModule.getChatContentModule()
@ -174,6 +175,7 @@ Item {
}
DelegateChoice { // In all other cases
delegate: ChatContentView {
rootStore: root.rootStore
Component.onCompleted: {
parentModule.prepareChatContentModuleForChatId(itemId)
chatContentModule = parentModule.getChatContentModule()

View File

@ -29,6 +29,7 @@ ColumnLayout {
// Important:
// Each chat/channel has its own ChatContentModule
property var chatContentModule
property var rootStore
StatusChatToolBar {
id: topBar
@ -80,18 +81,18 @@ ColumnLayout {
chatContentModule.chatDetails.type !== Constants.chatType.communityChat
chatInfoButton.onClicked: {
// Not Refactored Yet
// switch (root.rootStore.chatsModelInst.channelView.activeChannel.chatType) {
// switch (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType) {
// case Constants.chatType.privateGroupChat:
// openPopup(groupInfoPopupComponent, {
// channelType: GroupInfoPopup.ChannelType.ActiveChannel,
// channel: root.rootStore.chatsModelInst.channelView.activeChannel
// channel: chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel
// })
// break;
// case Constants.chatType.oneToOne:
// openProfilePopup(root.rootStore.chatsModelInst.userNameOrAlias(chatsModel.channelView.activeChannel.id),
// root.rootStore.chatsModelInst.channelView.activeChannel.id, profileImage
// || root.rootStore.chatsModelInst.channelView.activeChannel.identicon,
// "", root.rootStore.chatsModelInst.channelView.activeChannel.nickname)
// openProfilePopup(chatContentRoot.rootStore.chatsModelInst.userNameOrAlias(chatsModel.channelView.activeChannel.id),
// chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.id, profileImage
// || chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.identicon,
// "", chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.nickname)
// break;
// }
}
@ -196,7 +197,7 @@ ColumnLayout {
// Not Refactored Yet
// Connections {
// target: root.rootStore.chatsModelInst
// target: chatContentRoot.rootStore.chatsModelInst
// onOnlineStatusChanged: {
// if (connected == isConnected) return;
// isConnected = connected;
@ -210,7 +211,7 @@ ColumnLayout {
// }
// }
// Component.onCompleted: {
// isConnected = root.rootStore.chatsModelInst.isOnline
// isConnected = chatContentRoot.rootStore.chatsModelInst.isOnline
// if(!isConnected){
// connectedStatusRect.visible = true
// }
@ -245,7 +246,7 @@ ColumnLayout {
MessageContextMenuView {
id: contextmenu
reactionModel: root.rootStore.emojiReactionsModel
reactionModel: chatContentRoot.rootStore.emojiReactionsModel
onPinMessage: {
messageStore.pinMessage(messageId)
}
@ -291,7 +292,7 @@ ColumnLayout {
id: chatMessages
Layout.fillWidth: true
Layout.fillHeight: true
store: root.rootStore
store: chatContentRoot.rootStore
messageContextMenuInst: contextmenu
messageStore: messageStore
}
@ -306,7 +307,7 @@ ColumnLayout {
// Not Refactored Yet
// Connections {
// target: root.rootStore.chatsModelInst.messageView
// target: chatContentRoot.rootStore.chatsModelInst.messageView
// onLoadingMessagesChanged:
// if(value){
// loadingMessagesIndicator.active = true
@ -320,7 +321,7 @@ ColumnLayout {
// Not Refactored Yet
// Loader {
// id: loadingMessagesIndicator
// active: root.rootStore.chatsModelInst.messageView.loadingMessages
// active: chatContentRoot.rootStore.chatsModelInst.messageView.loadingMessages
// sourceComponent: loadingIndicator
// anchors.right: parent.right
// anchors.bottom: chatInput.top
@ -338,17 +339,17 @@ ColumnLayout {
visible: {
// Not Refactored Yet
return true
// if (root.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.privateGroupChat) {
// return root.rootStore.chatsModelInst.channelView.activeChannel.isMember
// if (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.privateGroupChat) {
// return chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.isMember
// }
// if (root.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.oneToOne) {
// if (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.oneToOne) {
// return isContact
// }
// const community = root.rootStore.chatsModelInst.communities.activeCommunity
// const community = chatContentRoot.rootStore.chatsModelInst.communities.activeCommunity
// return !community.active ||
// community.access === Constants.communityChatPublicAccess ||
// community.admin ||
// root.rootStore.chatsModelInst.channelView.activeChannel.canPost
// chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.canPost
}
isContactBlocked: isBlocked
chatInputPlaceholder: isBlocked ?
@ -357,12 +358,12 @@ ColumnLayout {
//% "Type a message."
qsTrId("type-a-message-")
anchors.bottom: parent.bottom
recentStickers: root.rootStore.stickersModuleInst.recent
stickerPackList: root.rootStore.stickersModuleInst.stickerPacks
// chatType: root.rootStore.chatsModelInst.channelView.activeChannel.chatType
recentStickers: chatContentRoot.rootStore.stickersModuleInst.recent
stickerPackList: chatContentRoot.rootStore.stickersModuleInst.stickerPacks
// chatType: chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType
onSendTransactionCommandButtonClicked: {
// Not Refactored Yet
// if (root.rootStore.chatsModelInst.channelView.activeChannel.ensVerified) {
// if (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.ensVerified) {
// txModalLoader.sourceComponent = cmpSendTransactionWithEns
// } else {
// txModalLoader.sourceComponent = cmpSendTransactionNoEns
@ -375,29 +376,33 @@ ColumnLayout {
// txModalLoader.item.open()
}
onStickerSelected: {
// Not Refactored Yet
// root.rootStore.stickersModuleInst.send(root.rootStore.chatsModelInst.channelView.activeChannel.id,
// hashId,
// chatInput.isReply ? SelectedMessage.messageId : "",
// packId)
chatContentRoot.rootStore.sendSticker(chatContentModule.getMyChatId(),
hashId,
chatInput.isReply ? SelectedMessage.messageId : "",
packId)
}
onSendMessage: {
// Not Refactored Yet
// if (chatInput.fileUrls.length > 0){
// root.rootStore.chatsModelInst.sendImages(JSON.stringify(fileUrls));
// }
// let msg = root.rootStore.chatsModelInst.plainText(Emoji.deparse(chatInput.textInput.text))
// if (msg.length > 0){
// msg = chatInput.interpretMessage(msg)
// root.rootStore.chatsModelInst.messageView.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType, false);
// if(event) event.accepted = true
// sendMessageSound.stop();
// Qt.callLater(sendMessageSound.play);
if (chatInput.fileUrls.length > 0){
chatContentModule.inputAreaModule.sendImages(JSON.stringify(fileUrls));
}
let msg = globalUtils.plainText(Emoji.deparse(chatInput.textInput.text))
if (msg.length > 0) {
msg = chatInput.interpretMessage(msg)
// chatInput.textInput.clear();
// chatInput.textInput.textFormat = TextEdit.PlainText;
// chatInput.textInput.textFormat = TextEdit.RichText;
// }
chatContentModule.inputAreaModule.sendMessage(
msg,
chatInput.isReply ? SelectedMessage.messageId : "",
Utils.isOnlyEmoji(msg) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType,
false)
if (event) event.accepted = true
sendMessageSound.stop();
Qt.callLater(sendMessageSound.play);
chatInput.textInput.clear();
chatInput.textInput.textFormat = TextEdit.PlainText;
chatInput.textInput.textFormat = TextEdit.RichText;
}
}
}
}

View File

@ -207,8 +207,7 @@ QtObject {
}
function generateAlias(pubKey) {
// Not Refactored Yet
// return utilsModelInst.generateAlias(pubKey)
return globalUtils.generateAlias(pubKey)
}
function joinPrivateChat(address) {