From 68d34e5706594df3af0ef8f600b5ad90e11670c0 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Mon, 30 Aug 2021 14:23:11 +0300 Subject: [PATCH] fix(@desktop/chat): edit channel modal to show up-to-date values --- src/app/chat/views/channel.nim | 3 --- .../Chat/CommunityComponents/CreateChannelPopup.qml | 12 ++++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/chat/views/channel.nim b/src/app/chat/views/channel.nim index 001685fc6a..ce1ca38db1 100644 --- a/src/app/chat/views/channel.nim +++ b/src/app/chat/views/channel.nim @@ -19,7 +19,6 @@ QtObject: activeChannel*: ChatItemView previousActiveChannelIndex*: int contextChannel*: ChatItemView - chatItemViews: Table[string, ChatItemView] proc setup(self: ChannelView) = self.QObject.setup proc delete*(self: ChannelView) = @@ -296,11 +295,9 @@ QtObject: result = selectedChannel.muted proc getChatItemById*(self: ChannelView, id: string): QObject {.slot.} = - if self.chatItemViews.hasKey(id): return self.chatItemViews[id] let chat = self.getChannelById(id) let chatItemView = newChatItemView(self.status) chatItemView.setChatItem(chat) - self.chatItemViews[id] = chatItemView return chatItemView proc removeChat*(self: ChannelView, chatId: string) = diff --git a/ui/app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml b/ui/app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml index de27165855..f216290f31 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml @@ -26,6 +26,8 @@ StatusModal { header.title: qsTrId("create-channel-title") onOpened: { + contentComponent.channelId = channel.id + contentComponent.channelCategoryId = channel.categoryId contentComponent.channelName.input.text = "" if (isEdit) { //% "Edit #%1" @@ -33,6 +35,7 @@ StatusModal { contentComponent.channelName.input.text = channel.name } contentComponent.channelName.input.forceActiveFocus(Qt.MouseFocusReason) + contentComponent.channelDescription.input.text = channel.description } onClosed: destroy() @@ -50,6 +53,8 @@ StatusModal { property alias channelName: nameInput property alias channelDescription: descriptionTextArea + property string channelId + property string channelCategoryId contentHeight: content.height height: Math.min(content.height, 432) @@ -91,7 +96,6 @@ StatusModal { input.placeholderText: qsTr("Describe the channel") input.multiline: true input.implicitHeight: 88 - input.text: popup.isEdit ? popup.channel.description : "" input.onTextChanged: errorMessage = Utils.getErrorMessage(errors, qsTr("channel description")) validators: [StatusMinLengthValidator { minLength: 1 }] } @@ -191,16 +195,16 @@ StatusModal { error = chatsModel.createCommunityChannel(communityId, Utils.filterXSS(popup.contentComponent.channelName.input.text), Utils.filterXSS(popup.contentComponent.channelDescription.input.text), - categoryId) + categoryId) // TODO: pass the private value when private channels // are implemented //privateSwitch.checked) } else { error = chatsModel.editCommunityChannel(communityId, - channel.id, + popup.contentComponent.channelId, Utils.filterXSS(popup.contentComponent.channelName.input.text), Utils.filterXSS(popup.contentComponent.channelDescription.input.text), - channel.categoryId) + popup.contentComponent.channelCategoryId) // TODO: pass the private value when private channels // are implemented //privateSwitch.checked)