feat: add api to delete a community channel
This commit is contained in:
parent
b5aa8d876e
commit
9f21740bae
|
@ -498,6 +498,15 @@ QtObject:
|
|||
chat.muted = true
|
||||
return chat
|
||||
|
||||
proc deleteCommunityChat*(self: CommunitiesView, communityId: string, channelId: string): string {.slot.} =
|
||||
try:
|
||||
self.status.chat.deleteCommunityChat(communityId, channelId)
|
||||
|
||||
self.joinedCommunityList.removeChannelInCommunity(communityId, channelId)
|
||||
except RpcException as e:
|
||||
error "Error deleting channel", msg=e.msg, channelId
|
||||
result = StatusGoError(error: e.msg).toJson
|
||||
|
||||
proc setCommunityMuted*(self: CommunitiesView, communityId: string, muted: bool) {.slot.} =
|
||||
self.status.chat.setCommunityMuted(communityId, muted)
|
||||
if (communityId == self.activeCommunity.communityItem.id):
|
||||
|
|
|
@ -194,6 +194,14 @@ QtObject:
|
|||
let channelIdx = community.chats.findIndexById(channel.id)
|
||||
if channelIdx > -1:
|
||||
community.chats[channelIdx] = channel
|
||||
|
||||
proc removeChannelInCommunity*(self: CommunityList, communityId: string, channelId: string) =
|
||||
var community = self.getCommunityById(communityId)
|
||||
let idx = community.chats.findIndexById(channelId)
|
||||
if idx == -1: return
|
||||
community.chats.delete(idx)
|
||||
let index = self.communities.findIndexById(communityId)
|
||||
self.communities[index] = community
|
||||
|
||||
proc addCategoryToCommunity*(self: CommunityList, communityId: string, category: CommunityCategory) =
|
||||
var community = self.getCommunityById(communityId)
|
||||
|
|
|
@ -467,6 +467,9 @@ proc createCommunityChannel*(self: ChatModel, communityId: string, name: string,
|
|||
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 deleteCommunityChat*(self: ChatModel, communityId: string, channelId: string) =
|
||||
status_chat.deleteCommunityChat(communityId, channelId)
|
||||
|
||||
proc createCommunityCategory*(self: ChatModel, communityId: string, name: string, channels: seq[string]): CommunityCategory =
|
||||
result = status_chat.createCommunityCategory(communityId, name, channels)
|
||||
|
||||
|
|
|
@ -424,6 +424,9 @@ proc editCommunityChannel*(communityId: string, channelId: string, name: string,
|
|||
if rpcResult{"result"} != nil and rpcResult{"result"}.kind != JNull:
|
||||
result = rpcResult["result"]["chats"][0].toChat()
|
||||
|
||||
proc deleteCommunityChat*(communityId: string, chatId: string) =
|
||||
discard callPrivateRPC("deleteCommunityChat".prefix, %*[communityId, chatId])
|
||||
|
||||
proc createCommunityCategory*(communityId: string, name: string, channels: seq[string]): CommunityCategory =
|
||||
let rpcResult = callPrivateRPC("createCommunityCategory".prefix, %*[
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ import StatusQ.Popups 0.1
|
|||
StatusPopupMenu {
|
||||
|
||||
property var chatItem
|
||||
property bool communityActive: chatsModel.communities.activeCommunity.active
|
||||
|
||||
StatusMenuItem {
|
||||
id: viewProfileMenuItem
|
||||
|
@ -19,11 +20,9 @@ StatusPopupMenu {
|
|||
case Constants.chatTypeOneToOne:
|
||||
//% "View Profile"
|
||||
return qsTrId("view-profile")
|
||||
break;
|
||||
case Constants.chatTypePrivateGroupChat:
|
||||
//% "View Group"
|
||||
return qsTrId("view-group")
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
@ -58,7 +57,7 @@ StatusPopupMenu {
|
|||
|
||||
|
||||
Action {
|
||||
enabled: profileModel.fleets.fleet == Constants.waku_prod || profileModel.fleets.fleet == Constants.waku_test
|
||||
enabled: profileModel.fleets.fleet == Constants.waku_prod || profileModel.fleets.fleet === Constants.waku_test
|
||||
//% "Test WakuV2 - requestAllHistoricMessages"
|
||||
text: qsTrId("test-wakuv2---requestallhistoricmessages")
|
||||
onTriggered: chatsModel.requestAllHistoricMessages()
|
||||
|
@ -99,7 +98,7 @@ StatusPopupMenu {
|
|||
//% "Edit Channel"
|
||||
text: qsTrId("edit-channel")
|
||||
icon.name: "edit"
|
||||
enabled: chatsModel.communities.activeCommunity.active &&
|
||||
enabled: communityActive &&
|
||||
chatsModel.communities.activeCommunity.admin
|
||||
onTriggered: openPopup(editChannelPopup, {
|
||||
communityId: chatsModel.communities.activeCommunity.id,
|
||||
|
@ -113,30 +112,35 @@ StatusPopupMenu {
|
|||
|
||||
StatusMenuItem {
|
||||
id: deleteOrLeaveMenuItem
|
||||
text: chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
||||
//% "Delete chat"
|
||||
qsTrId("delete-chat") :
|
||||
//% "Leave chat"
|
||||
qsTrId("leave-chat")
|
||||
icon.name: chatItem && chatItem.chatType === Constants.chatTypeOneToOne ? "delete" : "arrow-right"
|
||||
text: {
|
||||
if (communityActive) {
|
||||
return qsTr("Delete Channel")
|
||||
}
|
||||
return chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
||||
//% "Delete chat"
|
||||
qsTrId("delete-chat") :
|
||||
//% "Leave chat"
|
||||
qsTrId("leave-chat")
|
||||
}
|
||||
icon.name: chatItem && chatItem.chatType === Constants.chatTypeOneToOne || communityActive ? "delete" : "arrow-right"
|
||||
icon.width: chatItem && chatItem.chatType === Constants.chatTypeOneToOne ? 18 : 14
|
||||
iconRotation: chatItem && chatItem.chatType === Constants.chatTypeOneToOne ? 0 : 180
|
||||
|
||||
type: StatusMenuItem.Type.Danger
|
||||
onTriggered: {
|
||||
let label = chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
||||
//% "Delete chat"
|
||||
qsTrId("delete-chat") :
|
||||
//% "Leave chat"
|
||||
qsTrId("leave-chat")
|
||||
openPopup(deleteChatConfirmationDialogComponent, {
|
||||
title: label,
|
||||
confirmButtonLabel: label,
|
||||
chatId: chatItem.id
|
||||
})
|
||||
let label = chatItem && chatItem.chatType === Constants.chatTypeOneToOne ?
|
||||
//% "Delete chat"
|
||||
qsTrId("delete-chat") :
|
||||
//% "Leave chat"
|
||||
qsTrId("leave-chat")
|
||||
openPopup(deleteChatConfirmationDialogComponent, {
|
||||
title: label,
|
||||
confirmButtonLabel: label,
|
||||
chatId: chatItem.id
|
||||
})
|
||||
}
|
||||
|
||||
enabled: !chatsModel.communities.activeCommunity.active
|
||||
enabled: !communityActive || chatsModel.communities.activeCommunity.admin
|
||||
}
|
||||
|
||||
Component {
|
||||
|
@ -144,13 +148,17 @@ StatusPopupMenu {
|
|||
ConfirmationDialog {
|
||||
property string chatId
|
||||
btnType: "warn"
|
||||
//% "Are you sure you want to leave this chat?"
|
||||
confirmationText: qsTrId("are-you-sure-you-want-to-leave-this-chat-")
|
||||
confirmationText: communityActive ? qsTr("Are you sure you want to delete this channel?") :
|
||||
qsTr("Are you sure you want to leave this chat?")
|
||||
onClosed: {
|
||||
destroy()
|
||||
}
|
||||
onConfirmButtonClicked: {
|
||||
chatsModel.channelView.leaveChat(chatId)
|
||||
if (communityActive) {
|
||||
chatsModel.communities.deleteCommunityChat(chatsModel.communities.activeCommunity.id, chatId)
|
||||
} else {
|
||||
chatsModel.channelView.leaveChat(chatId)
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cdc7c5503001e2c987cf657dc707a3da81ea397e
|
||||
Subproject commit 151edb36077cdbb9f1f2b89f32cd939ee873ed98
|
Loading…
Reference in New Issue