fix: community chat positions

This commit is contained in:
Richard Ramos 2022-01-25 10:51:38 -04:00
parent b21d2c5618
commit 3fd10e7915
9 changed files with 79 additions and 10 deletions

View File

@ -351,4 +351,10 @@ method setCommunityMuted*(self: Controller, muted: bool) =
self.communityService.setCommunityMuted(self.sectionId, muted)
method inviteUsersToCommunity*(self: Controller, pubKeys: string): string =
result = self.communityService.inviteUsersToCommunityById(self.sectionId, pubKeys)
result = self.communityService.inviteUsersToCommunityById(self.sectionId, pubKeys)
method reorderCommunityCategories*(self: Controller, categoryId: string, position: int) =
self.communityService.reorderCommunityCategories(self.sectionId, categoryId, position)
method reorderCommunityChat*(self: Controller, categoryId: string, chatId: string, position: int): string =
self.communityService.reorderCommunityChat(self.sectionId, categoryId, chatId, position)

View File

@ -150,4 +150,10 @@ method setCommunityMuted*(self: AccessInterface, muted: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method inviteUsersToCommunity*(self: AccessInterface, pubKeys: string): string {.base.} =
raise newException(ValueError, "No implementation available")
raise newException(ValueError, "No implementation available")
method reorderCommunityCategories*(self: AccessInterface, categoryId: string, position: int) =
raise newException(ValueError, "No implementation available")
method reorderCommunityChat*(self: AccessInterface, categoryId: string, chatId: string, position: int): string =
raise newException(ValueError, "No implementation available")

View File

@ -676,4 +676,10 @@ method prepareEditCategoryModel*(self: Module, categoryId: string) =
let c = self.controller.getChatDetails(communityId, chat.id)
let item = initItem(c.id, c.name, "", false, c.color, c.description, c.chatType.int, false,
false, 0, c.muted, false, active = false, c.position, categoryId)
self.view.editCategoryChannelsModel().appendItem(item)
self.view.editCategoryChannelsModel().appendItem(item)
method reorderCommunityCategories*(self: Module, categoryId: string, position: int) =
self.controller.reorderCommunityCategories(categoryId, position)
method reorderCommunityChat*(self: Module, categoryId: string, chatId: string, position: int): string =
self.controller.reorderCommunityChat(categoryId, chatId, position)

View File

@ -123,3 +123,9 @@ method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.bas
method prepareEditCategoryModel*(self: AccessInterface, categoryId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method reorderCommunityCategories*(self: AccessInterface, categoryId: string, position: int) =
raise newException(ValueError, "No implementation available")
method reorderCommunityChat*(self: AccessInterface, categoryId: string, chatId: string, position: int): string =
raise newException(ValueError, "No implementation available")

View File

@ -249,4 +249,10 @@ QtObject:
self.delegate.deleteCommunityCategory(categoryId)
proc prepareEditCategoryModel*(self: View, categoryId: string) {.slot.} =
self.delegate.prepareEditCategoryModel(categoryId)
self.delegate.prepareEditCategoryModel(categoryId)
proc reorderCommunityCategories*(self: View, categoryId: string, position: int) {.slot} =
self.delegate.reorderCommunityCategories(categoryId, position)
proc reorderCommunityChat*(self: View, categoryId: string, chatId: string, position: int): string {.slot} =
self.delegate.reorderCommunityChat(categoryId, chatId, position)

View File

@ -51,6 +51,10 @@ method init*(self: Controller) =
method getAllCommunities*(self: Controller): seq[CommunityDto] =
result = self.communityService.getAllCommunities()
self.events.on(SIGNAL_COMMUNITY_CATEGORY_REORDERED) do(e:Args):
let args = CommunityCategoryOrderArgs(e)
# self.delegate.communityCategoryReordered()
method joinCommunity*(self: Controller, communityId: string): string =
self.communityService.joinCommunity(communityId)

View File

@ -43,6 +43,11 @@ type
categoryId*: string
position*: int
CommunityCategoryOrderArgs* = ref object of Args
communityId*: string
categoryId*: string
position*: int
CommunityCategoryArgs* = ref object of Args
communityId*: string
category*: Category
@ -67,6 +72,7 @@ const SIGNAL_COMMUNITY_CHANNEL_DELETED* = "communityChannelDeleted"
const SIGNAL_COMMUNITY_CATEGORY_CREATED* = "communityCategoryCreated"
const SIGNAL_COMMUNITY_CATEGORY_EDITED* = "communityCategoryEdited"
const SIGNAL_COMMUNITY_CATEGORY_DELETED* = "communityCategoryDeleted"
const SIGNAL_COMMUNITY_CATEGORY_REORDERED* = "communityCategoryReordered"
const SIGNAL_COMMUNITY_MEMBER_APPROVED* = "communityMemberApproved"
QtObject:
@ -639,6 +645,31 @@ QtObject:
except Exception as e:
error "Error deleting community category", msg = e.msg, communityId, categoryId
proc reorderCommunityCategories*(
self: Service,
communityId: string,
categoryId: string,
position: int) =
try:
let response = status_go.reorderCommunityCategories(
communityId,
categoryId,
position)
if response.error != nil:
let error = Json.decode($response.error, RpcError)
raise newException(RpcException, "Error reordering community category: " & error.message)
self.events.emit(SIGNAL_COMMUNITY_CATEGORY_REORDERED,
CommunityCategoryOrderArgs(
communityId: communityId,
categoryId: categoryId,
position: position
)
)
except Exception as e:
error "Error reordering category channel", msg = e.msg, communityId, categoryId, position
proc requestCommunityInfo*(self: Service, communityId: string) =
try:
let response = status_go.requestCommunityInfo(communityId)

View File

@ -210,4 +210,12 @@ QtObject {
function removeCommunityChat(chatId) {
chatCommunitySectionModule.removeCommunityChat(chatId)
}
function reorderCommunityCategories(categoryId, to){
chatCommunitySectionModule.reorderCommunityCategories(categoryId, to)
}
function reorderCommunityChat(categoryId, chatId, to){
chatCommunitySectionModule.reorderCommunityChat(categoryId, chatId, to)
}
}

View File

@ -160,12 +160,8 @@ Item {
// onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id)
// onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id)
// onChatItemReordered: function (categoryId, id, from, to) {
// root.store.chatsModelInst.communities.reorderCommunityChannel(chatsModel.communities.activeCommunity.id, categoryId, id, to);
// }
// onChatListCategoryReordered: function (categoryId, from, to) {
// root.store.chatsModelInst.communities.reorderCommunityCategories(chatsModel.communities.activeCommunity.id, categoryId, to);
// }
onChatItemReordered: root.store.reorderCommunityChat(categoryId, id, to)
onChatListCategoryReordered: root.store.reorderCommunityCategories(categoryId, to)
onCategoryAddButtonClicked: Global.openPopup(createChannelPopup, {
categoryId: id