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: if response.result.isNil or response.result.kind == JNull:
error "response is invalid", methodName="editCommunityChannel" 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: except Exception as e:
error "Error editing community channel", msg = e.msg, communityId, channelId, methodName="editCommunityChannel" error "Error editing community channel", msg = e.msg, communityId, channelId, methodName="editCommunityChannel"

View File

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

View File

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