fix(@desktop/chat): edit channel modal to show up-to-date values

This commit is contained in:
Andrei Smirnov 2021-08-30 14:23:11 +03:00 committed by Iuri Matias
parent 1557996cbc
commit 68d34e5706
2 changed files with 8 additions and 7 deletions

View File

@ -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) =

View File

@ -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 }]
}
@ -197,10 +201,10 @@ StatusModal {
//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)