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:
parent
aec0130107
commit
e097d2bfe7
|
@ -405,7 +405,7 @@ QtObject:
|
||||||
|
|
||||||
proc editCommunityChannel*(self: ChatsView, communityId: string, channelId: string, name: string, description: string, categoryId: string): string {.slot.} =
|
proc editCommunityChannel*(self: ChatsView, communityId: string, channelId: string, name: string, description: string, categoryId: string): string {.slot.} =
|
||||||
try:
|
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
|
chat.categoryId = categoryId
|
||||||
self.communities.joinedCommunityList.replaceChannelInCommunity(communityId, chat)
|
self.communities.joinedCommunityList.replaceChannelInCommunity(communityId, chat)
|
||||||
|
|
|
@ -46,6 +46,11 @@ QtObject:
|
||||||
QtProperty[string] communityId:
|
QtProperty[string] communityId:
|
||||||
read = 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
|
proc description*(self: ChatItemView): string {.slot.} = result = ?.self.chatItem.description
|
||||||
|
|
||||||
QtProperty[string] description:
|
QtProperty[string] description:
|
||||||
|
|
|
@ -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 =
|
proc createCommunityChannel*(self: ChatModel, communityId: string, name: string, description: string): Chat =
|
||||||
result = status_chat.createCommunityChannel(communityId, name, description)
|
result = status_chat.createCommunityChannel(communityId, name, description)
|
||||||
|
|
||||||
proc editCommunityChannel*(self: ChatModel, communityId: string, channelId: string, name: string, description: string): Chat =
|
proc editCommunityChannel*(self: ChatModel, communityId: string, channelId: string, name: string, description: string, categoryId: string): Chat =
|
||||||
result = status_chat.editCommunityChannel(communityId, channelId, name, description)
|
result = status_chat.editCommunityChannel(communityId, channelId, name, description, categoryId)
|
||||||
|
|
||||||
proc createCommunityCategory*(self: ChatModel, communityId: string, name: string, channels: seq[string]): CommunityCategory =
|
proc createCommunityCategory*(self: ChatModel, communityId: string, name: string, channels: seq[string]): CommunityCategory =
|
||||||
result = status_chat.createCommunityCategory(communityId, name, channels)
|
result = status_chat.createCommunityCategory(communityId, name, channels)
|
||||||
|
|
|
@ -390,7 +390,7 @@ proc createCommunityChannel*(communityId: string, name: string, description: str
|
||||||
if rpcResult{"result"} != nil and rpcResult{"result"}.kind != JNull:
|
if rpcResult{"result"} != nil and rpcResult{"result"}.kind != JNull:
|
||||||
result = rpcResult["result"]["chats"][0].toChat()
|
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, %*[
|
let rpcResult = callPrivateRPC("editCommunityChat".prefix, %*[
|
||||||
communityId,
|
communityId,
|
||||||
channelId.replace(communityId, ""),
|
channelId.replace(communityId, ""),
|
||||||
|
@ -410,7 +410,8 @@ proc editCommunityChannel*(communityId: string, channelId: string, name: string,
|
||||||
# "image_type": 1 # 1 is a raw payload
|
# "image_type": 1 # 1 is a raw payload
|
||||||
# }
|
# }
|
||||||
# ]
|
# ]
|
||||||
}
|
},
|
||||||
|
"category_id": categoryId
|
||||||
}]).parseJSON()
|
}]).parseJSON()
|
||||||
|
|
||||||
if rpcResult{"error"} != nil:
|
if rpcResult{"error"} != nil:
|
||||||
|
|
|
@ -263,7 +263,7 @@ StatusModal {
|
||||||
channel.id,
|
channel.id,
|
||||||
Utils.filterXSS(popup.contentComponent.channelName.text),
|
Utils.filterXSS(popup.contentComponent.channelName.text),
|
||||||
Utils.filterXSS(popup.contentComponent.channelDescription.text),
|
Utils.filterXSS(popup.contentComponent.channelDescription.text),
|
||||||
categoryId)
|
channel.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)
|
||||||
|
|
Loading…
Reference in New Issue