fix(community): fix community edits not always working

Fixes #4842
This commit is contained in:
Jonathan Rainville 2022-02-24 16:38:32 -05:00 committed by Iuri Matias
parent bd69d88163
commit 6c5594b576
3 changed files with 31 additions and 3 deletions

View File

@ -626,6 +626,18 @@ QtObject:
if response.result.isNil or response.result.kind == JNull:
error "response is invalid", methodName="editCommunityChannel"
var chatsJArr: JsonNode
if(not response.result.getProp("chats", chatsJArr)):
raise newException(RpcException, fmt"editCommunityChannel; there is no `chats` key in the response for community id: {communityId}")
for chatObj in chatsJArr:
var chatDto = chatObj.toChatDto()
self.chatService.updateOrAddChat(chatDto) # we have to update chats stored in the chat service.
let data = CommunityChatArgs(chat: chatDto)
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_EDITED, data)
except Exception as e:
error "Error editing community channel", msg = e.msg, communityId, channelId, methodName="editCommunityChannel"

View File

@ -178,12 +178,17 @@ QtObject {
chatCommunitySectionModule.createCommunityChannel(channelName, channelDescription, categoryId);
}
function editCommunityChannel(communityId, channelId, channelName, channelDescription, channelCategoryId, popupPosition) {
function editCommunityChannel(chatId, newName, newDescription, newCategory, channelPosition) {
// TODO: pass the private value when private channels
// are implemented
//privateSwitch.checked)
// Not Refactored Yet
// chatsModelInst.editCommunityChannel(communityId, channelId, channelName, channelDescription, channelCategoryId, popupPosition);
chatCommunitySectionModule.editCommunityChannel(
chatId,
newName,
newDescription,
newCategory,
channelPosition
)
}
function acceptRequestToJoinCommunity(requestId) {

View File

@ -172,6 +172,7 @@ ColumnLayout {
chatDescription = chatContentModule.chatDetails.description
chatType = chatContentModule.chatDetails.type
chatMuted = chatContentModule.chatDetails.muted
channelPosition = chatContentModule.chatDetails.position
}
onMuteChat: {
@ -234,6 +235,16 @@ ColumnLayout {
chatDetails: chatContentModule.chatDetails
})
}
onEditCommunityChannel: {
root.rootStore.editCommunityChannel(
chatId,
newName,
newDescription,
newCategory,
channelPosition // TODO change this to the signal once it is modifiable
)
}
}
}