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