mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-13 15:17:45 +00:00
fix(@desktop/chat): cannot create a group chat by hitting Confirm
Fixes #5094
This commit is contained in:
parent
43e58e357c
commit
94e1511644
@ -46,6 +46,13 @@ StatusAppThreePanelLayout {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.rootStore.chatCommunitySectionModule
|
||||
onActiveItemChanged: {
|
||||
root.rootStore.openCreateChat = false;
|
||||
}
|
||||
}
|
||||
|
||||
// property var onActivated: function () {
|
||||
// root.rootStore.chatsModelInst.channelView.restorePreviousActiveChannel();
|
||||
// chatColumn.onActivated();
|
||||
@ -74,14 +81,12 @@ StatusAppThreePanelLayout {
|
||||
onOpenAppSearch: {
|
||||
root.openAppSearch();
|
||||
}
|
||||
CreateChatView {
|
||||
activeChatId: chatColumn.activeChatId
|
||||
rootStore: root.rootStore
|
||||
}
|
||||
}
|
||||
|
||||
showRightPanel: {
|
||||
if (!localAccountSensitiveSettings.showOnlineUsers || !localAccountSensitiveSettings.expandUsersList) {
|
||||
if (root.rootStore.openCreateChat ||
|
||||
!localAccountSensitiveSettings.showOnlineUsers ||
|
||||
!localAccountSensitiveSettings.expandUsersList) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,23 @@
|
||||
import QtQuick 2.13
|
||||
|
||||
import utils 1.0
|
||||
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
property var contactsStore
|
||||
|
||||
property bool openCreateChat: false
|
||||
property bool hideInput: false
|
||||
property string createChatInitMessage
|
||||
property var chatTextInput
|
||||
property string createChatInitMessage: ""
|
||||
property var createChatFileUrls: []
|
||||
property bool createChatStartSendTransactionProcess: false
|
||||
property bool createChatStartReceiveTransactionProcess: false
|
||||
property string createChatStickerHashId: ""
|
||||
property string createChatStickerPackId: ""
|
||||
|
||||
property var contactsModel: profileSectionModule.contactsModule.myContactsModel
|
||||
signal addRemoveGroupMember()
|
||||
signal createChatWithMessage()
|
||||
|
||||
// Important:
|
||||
// Each `ChatLayout` has its own chatCommunitySectionModule
|
||||
// (on the backend chat and community sections share the same module since they are actually the same)
|
||||
@ -67,6 +72,40 @@ QtObject {
|
||||
chatCommunitySectionModule.blockContact(pubKey)
|
||||
}
|
||||
|
||||
function interpretMessage(msg) {
|
||||
if (msg.startsWith("/shrug")) {
|
||||
return msg.replace("/shrug", "") + " ¯\\\\\\_(ツ)\\_/¯"
|
||||
}
|
||||
if (msg.startsWith("/tableflip")) {
|
||||
return msg.replace("/tableflip", "") + " (╯°□°)╯︵ ┻━┻"
|
||||
}
|
||||
|
||||
return msg
|
||||
}
|
||||
|
||||
function sendMessage(event, text, replyMessageId, fileUrls) {
|
||||
var chatContentModule = currentChatContentModule()
|
||||
if (fileUrls.length > 0){
|
||||
chatContentModule.inputAreaModule.sendImages(JSON.stringify(fileUrls));
|
||||
}
|
||||
let msg = globalUtils.plainText(StatusQUtils.Emoji.deparse(text))
|
||||
if (msg.length > 0) {
|
||||
msg = interpretMessage(msg)
|
||||
|
||||
chatContentModule.inputAreaModule.sendMessage(
|
||||
msg,
|
||||
replyMessageId,
|
||||
Utils.isOnlyEmoji(msg) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType,
|
||||
false)
|
||||
|
||||
if (event)
|
||||
event.accepted = true
|
||||
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
property var messageStore: MessageStore { }
|
||||
|
||||
|
@ -105,6 +105,44 @@ Item {
|
||||
tokenAddress)
|
||||
}
|
||||
|
||||
// This function is called once `1:1` or `group` chat is created.
|
||||
function checkForCreateChatOptions(chatId) {
|
||||
if(root.rootStore.createChatStartSendTransactionProcess) {
|
||||
if (Utils.getContactDetailsAsJson(chatId).ensVerified) {
|
||||
Global.openPopup(cmpSendTransactionWithEns);
|
||||
} else {
|
||||
Global.openPopup(cmpSendTransactionNoEns);
|
||||
}
|
||||
}
|
||||
else if (root.rootStore.createChatStartSendTransactionProcess) {
|
||||
Global.openPopup(cmpReceiveTransaction);
|
||||
}
|
||||
else if (root.rootStore.createChatStickerHashId !== "" &&
|
||||
root.rootStore.createChatStickerPackId !== "") {
|
||||
root.rootStore.sendSticker(chatId,
|
||||
root.rootStore.createChatStickerHashId,
|
||||
"",
|
||||
root.rootStore.createChatStickerPackId);
|
||||
}
|
||||
else if (root.rootStore.createChatInitMessage !== "" ||
|
||||
root.rootStore.createChatFileUrls.length > 0) {
|
||||
|
||||
root.rootStore.sendMessage(Qt.Key_Enter,
|
||||
root.rootStore.createChatInitMessage,
|
||||
"",
|
||||
root.rootStore.createChatFileUrls
|
||||
);
|
||||
}
|
||||
|
||||
// Clear.
|
||||
root.rootStore.createChatInitMessage = "";
|
||||
root.rootStore.createChatFileUrls = [];
|
||||
root.rootStore.createChatStartSendTransactionProcess = false;
|
||||
root.rootStore.createChatStartReceiveTransactionProcess = false;
|
||||
root.rootStore.createChatStickerHashId = "";
|
||||
root.rootStore.createChatStickerPackId = "";
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 60000; // 1 min
|
||||
running: true
|
||||
@ -128,6 +166,12 @@ Item {
|
||||
onShareChatKeyClicked: Global.openProfilePopup(userProfile.pubKey);
|
||||
}
|
||||
|
||||
CreateChatView {
|
||||
rootStore: root.rootStore
|
||||
emojiPopup: root.emojiPopup
|
||||
visible: mainModule.activeSection.sectionType === Constants.appSection.chat && root.rootStore.openCreateChat
|
||||
}
|
||||
|
||||
// This is kind of a solution for applying backend refactored changes with the minimal qml changes.
|
||||
// The best would be if we made qml to follow the struct we have on the backend side.
|
||||
Repeater {
|
||||
@ -179,6 +223,7 @@ Item {
|
||||
}
|
||||
|
||||
sourceComponent: ChatContentView {
|
||||
visible: !root.rootStore.openCreateChat
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
clip: true
|
||||
@ -223,6 +268,7 @@ Item {
|
||||
}
|
||||
|
||||
sourceComponent: ChatContentView {
|
||||
visible: !root.rootStore.openCreateChat
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
onHeightChanged: {
|
||||
@ -241,58 +287,15 @@ Item {
|
||||
onOpenStickerPackPopup: {
|
||||
root.openStickerPackPopup(stickerPackId)
|
||||
}
|
||||
onIsActiveChannelChanged: {
|
||||
if (isActiveChannel && root.rootStore.openCreateChat) {
|
||||
root.rootStore.chatTextInput = textInputField.textInput;
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
parentModule.prepareChatContentModuleForChatId(model.itemId)
|
||||
chatContentModule = parentModule.getChatContentModule()
|
||||
if (root.rootStore.openCreateChat) {
|
||||
root.rootStore.openCreateChat = false;
|
||||
if (root.rootStore.createChatInitMessage !== "") {
|
||||
textInputField.textInput.insert(0, root.rootStore.createChatInitMessage);
|
||||
root.rootStore.createChatInitMessage = "";
|
||||
textInputField.sendMessage(Qt.Key_Enter);
|
||||
}
|
||||
}
|
||||
|
||||
root.checkForCreateChatOptions(model.itemId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DelegateChoice { // In all other cases
|
||||
delegate: ChatContentView {
|
||||
width: parent.width
|
||||
clip: true
|
||||
height: {
|
||||
// dynamically calculate the height of the view, if the active one is the current one
|
||||
// then set the height to parent otherwise set it to 0
|
||||
if(!chatContentModule)
|
||||
return 0
|
||||
|
||||
let myChatId = chatContentModule.getMyChatId()
|
||||
if(myChatId === root.activeChatId || myChatId === root.activeSubItemId)
|
||||
return parent.height
|
||||
|
||||
return 0
|
||||
}
|
||||
rootStore: root.rootStore
|
||||
contactsStore: root.contactsStore
|
||||
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
||||
receiveTransactionModal: cmpReceiveTransaction
|
||||
sendTransactionWithEnsModal: cmpSendTransactionWithEns
|
||||
stickersLoaded: root.stickersLoaded
|
||||
isBlocked: model.blocked
|
||||
onOpenStickerPackPopup: {
|
||||
root.openStickerPackPopup(stickerPackId)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
parentModule.prepareChatContentModuleForChatId(itemId)
|
||||
chatContentModule = parentModule.getChatContentModule()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,6 @@ ColumnLayout {
|
||||
|
||||
ChatMessagesView {
|
||||
id: chatMessages
|
||||
opacity: !chatContentRoot.rootStore.openCreateChat ? 1.0 : 0.0
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
store: chatContentRoot.rootStore
|
||||
@ -409,7 +408,6 @@ ColumnLayout {
|
||||
|
||||
Loader {
|
||||
id: loadingMessagesIndicator
|
||||
visible: !chatContentRoot.rootStore.openCreateChat
|
||||
sourceComponent: LoadingAnimation { }
|
||||
anchors {
|
||||
right: parent.right
|
||||
@ -425,10 +423,7 @@ ColumnLayout {
|
||||
usersStore: chatContentRoot.usersStore
|
||||
|
||||
visible: {
|
||||
if (chatContentRoot.rootStore.openCreateChat && chatContentRoot.rootStore.hideInput) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
return true
|
||||
// Not Refactored Yet
|
||||
// if (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.privateGroupChat) {
|
||||
// return chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.isMember
|
||||
@ -441,7 +436,6 @@ ColumnLayout {
|
||||
// community.access === Constants.communityChatPublicAccess ||
|
||||
// community.admin ||
|
||||
// chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.canPost
|
||||
}
|
||||
}
|
||||
messageContextMenu: contextmenu
|
||||
emojiPopup: chatContentRoot.emojiPopup
|
||||
@ -480,37 +474,23 @@ ColumnLayout {
|
||||
|
||||
|
||||
onSendMessage: {
|
||||
if (chatContentRoot.rootStore.openCreateChat) {
|
||||
chatContentRoot.rootStore.createChatInitMessage = textInput.getText(0, textInput.cursorPosition);
|
||||
textInput.clear();
|
||||
chatContentRoot.rootStore.createChatWithMessage();
|
||||
} else {
|
||||
if (!chatContentModule) {
|
||||
console.debug("error on sending message - chat content module is not set")
|
||||
return
|
||||
}
|
||||
if (!chatContentModule) {
|
||||
console.debug("error on sending message - chat content module is not set")
|
||||
return
|
||||
}
|
||||
|
||||
if (chatInput.fileUrls.length > 0){
|
||||
chatContentModule.inputAreaModule.sendImages(JSON.stringify(fileUrls));
|
||||
}
|
||||
let msg = globalUtils.plainText(StatusQUtils.Emoji.deparse(chatInput.textInput.text))
|
||||
if (msg.length > 0) {
|
||||
msg = chatInput.interpretMessage(msg)
|
||||
if(chatContentRoot.rootStore.sendMessage(event,
|
||||
chatInput.textInput.text,
|
||||
chatInput.isReply? chatInput.replyMessageId : "",
|
||||
chatInput.fileUrls
|
||||
))
|
||||
{
|
||||
sendMessageSound.stop();
|
||||
Qt.callLater(sendMessageSound.play);
|
||||
|
||||
chatContentModule.inputAreaModule.sendMessage(
|
||||
msg,
|
||||
chatInput.isReply ? chatInput.replyMessageId : "",
|
||||
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;
|
||||
}
|
||||
chatInput.textInput.clear();
|
||||
chatInput.textInput.textFormat = TextEdit.PlainText;
|
||||
chatInput.textInput.textFormat = TextEdit.RichText;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,6 @@ Item {
|
||||
model: root.chatSectionModule.model
|
||||
onChatItemSelected: {
|
||||
root.chatSectionModule.setActiveItem(id, "")
|
||||
root.store.openCreateChat = false;
|
||||
}
|
||||
onChatItemUnmuted: root.chatSectionModule.unmuteChat(id)
|
||||
|
||||
|
@ -10,31 +10,21 @@ import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
||||
import utils 1.0
|
||||
import shared.status 1.0
|
||||
|
||||
Page {
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: (tagSelector.namesModel.count > 0) ? 64 : 0
|
||||
Behavior on anchors.bottomMargin { NumberAnimation { duration: 30 }}
|
||||
anchors.rightMargin: 32
|
||||
|
||||
property ListModel contactsModel: ListModel { }
|
||||
property var rootStore
|
||||
property string activeChatId
|
||||
property bool editMembers: false
|
||||
property var emojiPopup: null
|
||||
|
||||
//nim model doesn't support a get function, hence
|
||||
//passing it here so that it can be handled accordingly
|
||||
ListView {
|
||||
id: convertModel
|
||||
model: root.rootStore.currentChatContentModule().usersModule.model
|
||||
delegate: Item {
|
||||
property string publicId: model.id
|
||||
property string name: model.name
|
||||
property bool isAdmin: model.isAdmin
|
||||
}
|
||||
}
|
||||
ListView {
|
||||
id: contactsModelListView
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
model: root.rootStore.contactsModel
|
||||
delegate: Item {
|
||||
property string publicId: model.pubKey
|
||||
@ -46,19 +36,6 @@ Page {
|
||||
|
||||
Connections {
|
||||
target: rootStore
|
||||
onCreateChatWithMessage: {
|
||||
root.createChat();
|
||||
}
|
||||
onAddRemoveGroupMember: {
|
||||
for (var i = 0; i < convertModel.count; i ++) {
|
||||
var entry = convertModel.itemAtIndex(i);
|
||||
if (!entry.isAdmin) {
|
||||
tagSelector.namesModel.insert(tagSelector.namesModel.count, {"name": entry.name, "publicId": entry.publicId});
|
||||
}
|
||||
}
|
||||
root.rootStore.openCreateChat = true;
|
||||
root.editMembers = true;
|
||||
}
|
||||
onOpenCreateChatChanged: {
|
||||
if (root.rootStore.openCreateChat) {
|
||||
for (var i = 0; i < contactsModelListView.count; i ++) {
|
||||
@ -70,7 +47,6 @@ Page {
|
||||
} else {
|
||||
tagSelector.namesModel.clear();
|
||||
contactsModel.clear();
|
||||
root.editMembers = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,6 +64,10 @@ Page {
|
||||
}
|
||||
root.rootStore.chatCommunitySectionModule.createGroupChat("",groupName, JSON.stringify(publicIds));
|
||||
}
|
||||
|
||||
chatInput.textInput.clear();
|
||||
chatInput.textInput.textFormat = TextEdit.PlainText;
|
||||
chatInput.textInput.textFormat = TextEdit.RichText;
|
||||
}
|
||||
|
||||
visible: (opacity > 0.01)
|
||||
@ -101,7 +81,7 @@ Page {
|
||||
Behavior on opacity { NumberAnimation {}}
|
||||
background: Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.palette.statusPopupMenu.backgroundColor
|
||||
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor
|
||||
}
|
||||
|
||||
header: RowLayout {
|
||||
@ -121,15 +101,6 @@ Page {
|
||||
implicitHeight: 44
|
||||
toLabelText: qsTr("To: ")
|
||||
warningText: qsTr("USER LIMIT REACHED")
|
||||
Connections {
|
||||
target: tagSelector.namesModel
|
||||
onCountChanged: {
|
||||
root.rootStore.hideInput = (tagSelector.namesModel.count === 0);
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
root.rootStore.hideInput = (tagSelector.namesModel.count === 0);
|
||||
}
|
||||
|
||||
//simulate model filtering, TODO this
|
||||
//makes more sense to be provided by the backend
|
||||
@ -150,24 +121,6 @@ Page {
|
||||
userListView.model = contactsModel;
|
||||
}
|
||||
}
|
||||
onAddMember: {
|
||||
if (root.editMembers) {
|
||||
var pubKeys = [];
|
||||
pubKeys.push(memberId);
|
||||
root.rootStore.chatCommunitySectionModule.addGroupMembers("", activeChatId, JSON.stringify(pubKeys));
|
||||
}
|
||||
if (root.rootStore.chatTextInput.length > 0) {
|
||||
root.rootStore.chatTextInput.clear();
|
||||
}
|
||||
}
|
||||
onRemoveMember: {
|
||||
if (root.editMembers) {
|
||||
root.rootStore.chatCommunitySectionModule.removeMemberFromGroupChat("", activeChatId, memberId);
|
||||
}
|
||||
if (root.rootStore.chatTextInput.length > 0) {
|
||||
root.rootStore.chatTextInput.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
@ -176,10 +129,8 @@ Page {
|
||||
enabled: (tagSelector.namesModel.count > 0)
|
||||
text: "Confirm"
|
||||
onClicked: {
|
||||
if (root.rootStore.chatTextInput.length > 0) {
|
||||
root.rootStore.createChatInitMessage = root.rootStore.chatTextInput.getText(0, root.rootStore.chatTextInput.cursorPosition);
|
||||
root.rootStore.chatTextInput.clear();
|
||||
}
|
||||
root.rootStore.createChatInitMessage = chatInput.textInput.text;
|
||||
root.rootStore.createChatFileUrls = chatInput.fileUrls;
|
||||
root.createChat();
|
||||
}
|
||||
}
|
||||
@ -190,9 +141,18 @@ Page {
|
||||
anchors.topMargin: headerRow.height + 32
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: chatInput.visible? chatInput.top : parent.bottom
|
||||
visible: (contactsModel.count > 0)
|
||||
|
||||
Component.onCompleted: {
|
||||
if (visible) {
|
||||
tagSelector.textEdit.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
StatusBaseText {
|
||||
id: contactsLabel
|
||||
font.pixelSize: 15
|
||||
@ -201,13 +161,13 @@ Page {
|
||||
color: Theme.palette.baseColor1
|
||||
text: qsTr("Contacts")
|
||||
}
|
||||
|
||||
Control {
|
||||
width: 360
|
||||
anchors {
|
||||
top: contactsLabel.bottom
|
||||
topMargin: Style.current.halfPadding
|
||||
bottom: !statusPopupMenuBackgroundContent.visible ? parent.bottom : undefined
|
||||
bottomMargin: Style.current.bigPadding
|
||||
}
|
||||
height: Style.current.padding + (!statusPopupMenuBackgroundContent.visible ? parent.height :
|
||||
(((userListView.count * 64) > parent.height) ? parent.height : (userListView.count * 64)))
|
||||
@ -313,10 +273,40 @@ Page {
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (visible) {
|
||||
tagSelector.textEdit.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
StatusChatInput {
|
||||
id: chatInput
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
visible: tagSelector.namesModel.count > 0
|
||||
chatType: tagSelector.namesModel.count == 1? Constants.chatType.oneToOne : Constants.chatType.privateGroupChat
|
||||
|
||||
emojiPopup: root.emojiPopup
|
||||
recentStickers: root.rootStore.stickersModuleInst.recent
|
||||
stickerPackList: root.rootStore.stickersModuleInst.stickerPacks
|
||||
|
||||
onSendTransactionCommandButtonClicked: {
|
||||
root.rootStore.createChatStartSendTransactionProcess = true;
|
||||
root.createChat();
|
||||
}
|
||||
|
||||
onReceiveTransactionCommandButtonClicked: {
|
||||
root.rootStore.createChatStartReceiveTransactionProcess = true;
|
||||
root.createChat();
|
||||
}
|
||||
|
||||
onStickerSelected: {
|
||||
root.rootStore.createChatStickerHashId = hashId;
|
||||
root.rootStore.createChatStickerPackId = packId;
|
||||
root.createChat();
|
||||
}
|
||||
|
||||
onSendMessage: {
|
||||
root.rootStore.createChatFileUrls = chatInput.fileUrls;
|
||||
root.rootStore.createChatInitMessage = chatInput.textInput.text;
|
||||
root.createChat();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,17 +161,6 @@ Rectangle {
|
||||
mentionsPos.push({"name": aliasName,"leftIndex": lastAtPosition, "rightIndex": (lastAtPosition+aliasName.length+1)});
|
||||
}
|
||||
|
||||
property var interpretMessage: function (msg) {
|
||||
if (msg.startsWith("/shrug")) {
|
||||
return msg.replace("/shrug", "") + " ¯\\\\\\_(ツ)\\_/¯"
|
||||
}
|
||||
if (msg.startsWith("/tableflip")) {
|
||||
return msg.replace("/tableflip", "") + " (╯°□°)╯︵ ┻━┻"
|
||||
}
|
||||
|
||||
return msg
|
||||
}
|
||||
|
||||
function isUploadFilePressed(event) {
|
||||
return (event.key === Qt.Key_U) && (event.modifiers & Qt.ControlModifier) && imageBtn.visible && !imageDialog.visible
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user