fix(@desktop/chat): edit channel modal to show up-to-date values
This commit is contained in:
parent
1557996cbc
commit
68d34e5706
|
@ -19,7 +19,6 @@ QtObject:
|
||||||
activeChannel*: ChatItemView
|
activeChannel*: ChatItemView
|
||||||
previousActiveChannelIndex*: int
|
previousActiveChannelIndex*: int
|
||||||
contextChannel*: ChatItemView
|
contextChannel*: ChatItemView
|
||||||
chatItemViews: Table[string, ChatItemView]
|
|
||||||
|
|
||||||
proc setup(self: ChannelView) = self.QObject.setup
|
proc setup(self: ChannelView) = self.QObject.setup
|
||||||
proc delete*(self: ChannelView) =
|
proc delete*(self: ChannelView) =
|
||||||
|
@ -296,11 +295,9 @@ QtObject:
|
||||||
result = selectedChannel.muted
|
result = selectedChannel.muted
|
||||||
|
|
||||||
proc getChatItemById*(self: ChannelView, id: string): QObject {.slot.} =
|
proc getChatItemById*(self: ChannelView, id: string): QObject {.slot.} =
|
||||||
if self.chatItemViews.hasKey(id): return self.chatItemViews[id]
|
|
||||||
let chat = self.getChannelById(id)
|
let chat = self.getChannelById(id)
|
||||||
let chatItemView = newChatItemView(self.status)
|
let chatItemView = newChatItemView(self.status)
|
||||||
chatItemView.setChatItem(chat)
|
chatItemView.setChatItem(chat)
|
||||||
self.chatItemViews[id] = chatItemView
|
|
||||||
return chatItemView
|
return chatItemView
|
||||||
|
|
||||||
proc removeChat*(self: ChannelView, chatId: string) =
|
proc removeChat*(self: ChannelView, chatId: string) =
|
||||||
|
|
|
@ -26,6 +26,8 @@ StatusModal {
|
||||||
header.title: qsTrId("create-channel-title")
|
header.title: qsTrId("create-channel-title")
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
|
contentComponent.channelId = channel.id
|
||||||
|
contentComponent.channelCategoryId = channel.categoryId
|
||||||
contentComponent.channelName.input.text = ""
|
contentComponent.channelName.input.text = ""
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
//% "Edit #%1"
|
//% "Edit #%1"
|
||||||
|
@ -33,6 +35,7 @@ StatusModal {
|
||||||
contentComponent.channelName.input.text = channel.name
|
contentComponent.channelName.input.text = channel.name
|
||||||
}
|
}
|
||||||
contentComponent.channelName.input.forceActiveFocus(Qt.MouseFocusReason)
|
contentComponent.channelName.input.forceActiveFocus(Qt.MouseFocusReason)
|
||||||
|
contentComponent.channelDescription.input.text = channel.description
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosed: destroy()
|
onClosed: destroy()
|
||||||
|
@ -50,6 +53,8 @@ StatusModal {
|
||||||
|
|
||||||
property alias channelName: nameInput
|
property alias channelName: nameInput
|
||||||
property alias channelDescription: descriptionTextArea
|
property alias channelDescription: descriptionTextArea
|
||||||
|
property string channelId
|
||||||
|
property string channelCategoryId
|
||||||
|
|
||||||
contentHeight: content.height
|
contentHeight: content.height
|
||||||
height: Math.min(content.height, 432)
|
height: Math.min(content.height, 432)
|
||||||
|
@ -91,7 +96,6 @@ StatusModal {
|
||||||
input.placeholderText: qsTr("Describe the channel")
|
input.placeholderText: qsTr("Describe the channel")
|
||||||
input.multiline: true
|
input.multiline: true
|
||||||
input.implicitHeight: 88
|
input.implicitHeight: 88
|
||||||
input.text: popup.isEdit ? popup.channel.description : ""
|
|
||||||
input.onTextChanged: errorMessage = Utils.getErrorMessage(errors, qsTr("channel description"))
|
input.onTextChanged: errorMessage = Utils.getErrorMessage(errors, qsTr("channel description"))
|
||||||
validators: [StatusMinLengthValidator { minLength: 1 }]
|
validators: [StatusMinLengthValidator { minLength: 1 }]
|
||||||
}
|
}
|
||||||
|
@ -191,16 +195,16 @@ StatusModal {
|
||||||
error = chatsModel.createCommunityChannel(communityId,
|
error = chatsModel.createCommunityChannel(communityId,
|
||||||
Utils.filterXSS(popup.contentComponent.channelName.input.text),
|
Utils.filterXSS(popup.contentComponent.channelName.input.text),
|
||||||
Utils.filterXSS(popup.contentComponent.channelDescription.input.text),
|
Utils.filterXSS(popup.contentComponent.channelDescription.input.text),
|
||||||
categoryId)
|
categoryId)
|
||||||
// TODO: pass the private value when private channels
|
// TODO: pass the private value when private channels
|
||||||
// are implemented
|
// are implemented
|
||||||
//privateSwitch.checked)
|
//privateSwitch.checked)
|
||||||
} else {
|
} else {
|
||||||
error = chatsModel.editCommunityChannel(communityId,
|
error = chatsModel.editCommunityChannel(communityId,
|
||||||
channel.id,
|
popup.contentComponent.channelId,
|
||||||
Utils.filterXSS(popup.contentComponent.channelName.input.text),
|
Utils.filterXSS(popup.contentComponent.channelName.input.text),
|
||||||
Utils.filterXSS(popup.contentComponent.channelDescription.input.text),
|
Utils.filterXSS(popup.contentComponent.channelDescription.input.text),
|
||||||
channel.categoryId)
|
popup.contentComponent.channelCategoryId)
|
||||||
// TODO: pass the private value when private channels
|
// TODO: pass the private value when private channels
|
||||||
// are implemented
|
// are implemented
|
||||||
//privateSwitch.checked)
|
//privateSwitch.checked)
|
||||||
|
|
Loading…
Reference in New Issue