fix(Communities): preserve category id when editing channels

As described in #3015, when editing channels that belong to a category of a community,
after saving them, they'll get kicked out of the category.

This is because we haven't passed the category id along the API that performs the
save operation.

This commit ensures we have access to a category chats' `categoryId` and send it
over to `editCommunityChat` RPC API provided by status-go

Fixes #3015
This commit is contained in:
Pascal Precht 2021-07-22 15:51:48 +02:00 committed by Iuri Matias
parent aec0130107
commit e097d2bfe7
5 changed files with 12 additions and 6 deletions

View File

@ -405,7 +405,7 @@ QtObject:
proc editCommunityChannel*(self: ChatsView, communityId: string, channelId: string, name: string, description: string, categoryId: string): string {.slot.} =
try:
let chat = self.status.chat.editCommunityChannel(communityId, channelId, name, description)
let chat = self.status.chat.editCommunityChannel(communityId, channelId, name, description, categoryId)
chat.categoryId = categoryId
self.communities.joinedCommunityList.replaceChannelInCommunity(communityId, chat)

View File

@ -46,6 +46,11 @@ QtObject:
QtProperty[string] communityId:
read = communityId
proc categoryId*(self: ChatItemView): string {.slot.} = result = ?.self.chatItem.categoryId
QtProperty[string] categoryId:
read = categoryId
proc description*(self: ChatItemView): string {.slot.} = result = ?.self.chatItem.description
QtProperty[string] description:

View File

@ -459,8 +459,8 @@ proc editCommunity*(self: ChatModel, id: string, name: string, description: stri
proc createCommunityChannel*(self: ChatModel, communityId: string, name: string, description: string): Chat =
result = status_chat.createCommunityChannel(communityId, name, description)
proc editCommunityChannel*(self: ChatModel, communityId: string, channelId: string, name: string, description: string): Chat =
result = status_chat.editCommunityChannel(communityId, channelId, name, description)
proc editCommunityChannel*(self: ChatModel, communityId: string, channelId: string, name: string, description: string, categoryId: string): Chat =
result = status_chat.editCommunityChannel(communityId, channelId, name, description, categoryId)
proc createCommunityCategory*(self: ChatModel, communityId: string, name: string, channels: seq[string]): CommunityCategory =
result = status_chat.createCommunityCategory(communityId, name, channels)

View File

@ -390,7 +390,7 @@ proc createCommunityChannel*(communityId: string, name: string, description: str
if rpcResult{"result"} != nil and rpcResult{"result"}.kind != JNull:
result = rpcResult["result"]["chats"][0].toChat()
proc editCommunityChannel*(communityId: string, channelId: string, name: string, description: string): Chat =
proc editCommunityChannel*(communityId: string, channelId: string, name: string, description: string, categoryId: string): Chat =
let rpcResult = callPrivateRPC("editCommunityChat".prefix, %*[
communityId,
channelId.replace(communityId, ""),
@ -410,7 +410,8 @@ proc editCommunityChannel*(communityId: string, channelId: string, name: string,
# "image_type": 1 # 1 is a raw payload
# }
# ]
}
},
"category_id": categoryId
}]).parseJSON()
if rpcResult{"error"} != nil:

View File

@ -263,7 +263,7 @@ StatusModal {
channel.id,
Utils.filterXSS(popup.contentComponent.channelName.text),
Utils.filterXSS(popup.contentComponent.channelDescription.text),
categoryId)
channel.categoryId)
// TODO: pass the private value when private channels
// are implemented
//privateSwitch.checked)