parent
1e7c648300
commit
bb2c9e02c2
|
@ -123,7 +123,7 @@ method `notificationsCount=`*(self: var BaseItem, value: int) {.inline base.} =
|
||||||
method muted*(self: BaseItem): bool {.inline base.} =
|
method muted*(self: BaseItem): bool {.inline base.} =
|
||||||
self.muted
|
self.muted
|
||||||
|
|
||||||
method `muted=`*(self: var BaseItem, value: bool) {.inline base.} =
|
method `muted=`*(self: BaseItem, value: bool) {.inline base.} =
|
||||||
self.muted = value
|
self.muted = value
|
||||||
|
|
||||||
method blocked*(self: BaseItem): bool {.inline base.} =
|
method blocked*(self: BaseItem): bool {.inline base.} =
|
||||||
|
|
|
@ -171,6 +171,16 @@ proc init*(self: Controller) =
|
||||||
let args = ReloadMessagesArgs(e)
|
let args = ReloadMessagesArgs(e)
|
||||||
if (args.communityId == self.sectionId):
|
if (args.communityId == self.sectionId):
|
||||||
self.messageService.asyncLoadInitialMessagesForChat(self.getActiveChatId())
|
self.messageService.asyncLoadInitialMessagesForChat(self.getActiveChatId())
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_CATEGORY_MUTED) do(e: Args):
|
||||||
|
let args = CategoryArgs(e)
|
||||||
|
if (args.communityId == self.sectionId):
|
||||||
|
self.delegate.onCategoryMuted(args.categoryId)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_CATEGORY_UNMUTED) do(e: Args):
|
||||||
|
let args = CategoryArgs(e)
|
||||||
|
if (args.communityId == self.sectionId):
|
||||||
|
self.delegate.onCategoryUnmuted(args.categoryId)
|
||||||
|
|
||||||
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
|
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
|
||||||
var args = ContactArgs(e)
|
var args = ContactArgs(e)
|
||||||
|
@ -422,6 +432,12 @@ proc editCommunity*(
|
||||||
proc exportCommunity*(self: Controller): string =
|
proc exportCommunity*(self: Controller): string =
|
||||||
self.communityService.exportCommunity(self.sectionId)
|
self.communityService.exportCommunity(self.sectionId)
|
||||||
|
|
||||||
|
method muteCategory*(self: Controller, categoryId: string) =
|
||||||
|
self.communityService.muteCategory(self.sectionId, categoryId)
|
||||||
|
|
||||||
|
method unmuteCategory*(self: Controller, categoryId: string) =
|
||||||
|
self.communityService.unmuteCategory(self.sectionId, categoryId)
|
||||||
|
|
||||||
proc setCommunityMuted*(self: Controller, muted: bool) =
|
proc setCommunityMuted*(self: Controller, muted: bool) =
|
||||||
self.communityService.setCommunityMuted(self.sectionId, muted)
|
self.communityService.setCommunityMuted(self.sectionId, muted)
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,18 @@ method muteChat*(self: AccessInterface, chatId: string) {.base.} =
|
||||||
method unmuteChat*(self: AccessInterface, chatId: string) {.base.} =
|
method unmuteChat*(self: AccessInterface, chatId: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method muteCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method unmuteCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method onCategoryMuted*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method onCategoryUnmuted*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
|
method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -67,15 +67,19 @@ proc toJsonNode*(self: Item): JsonNode =
|
||||||
|
|
||||||
proc appendSubItems*(self: Item, items: seq[SubItem]) =
|
proc appendSubItems*(self: Item, items: seq[SubItem]) =
|
||||||
self.subItems.appendItems(items)
|
self.subItems.appendItems(items)
|
||||||
|
self.BaseItem.muted = self.subItems.isAllMuted()
|
||||||
|
|
||||||
proc appendSubItem*(self: Item, item: SubItem) =
|
proc appendSubItem*(self: Item, item: SubItem) =
|
||||||
self.subItems.appendItem(item)
|
self.subItems.appendItem(item)
|
||||||
|
self.BaseItem.muted = self.subItems.isAllMuted()
|
||||||
|
|
||||||
proc prependSubItems*(self: Item, items: seq[SubItem]) =
|
proc prependSubItems*(self: Item, items: seq[SubItem]) =
|
||||||
self.subItems.prependItems(items)
|
self.subItems.prependItems(items)
|
||||||
|
self.BaseItem.muted = self.subItems.isAllMuted()
|
||||||
|
|
||||||
proc prependSubItem*(self: Item, item: SubItem) =
|
proc prependSubItem*(self: Item, item: SubItem) =
|
||||||
self.subItems.prependItem(item)
|
self.subItems.prependItem(item)
|
||||||
|
self.BaseItem.muted = self.subItems.isAllMuted()
|
||||||
|
|
||||||
proc setActiveSubItem*(self: Item, subItemId: string) =
|
proc setActiveSubItem*(self: Item, subItemId: string) =
|
||||||
self.subItems.setActiveItem(subItemId)
|
self.subItems.setActiveItem(subItemId)
|
||||||
|
|
|
@ -249,7 +249,16 @@ QtObject:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.items[i].subItems.muteUnmuteItemById(id, mute):
|
if self.items[i].subItems.muteUnmuteItemById(id, mute):
|
||||||
|
self.items[i].BaseItem.muted = self.items[i].subItems.isAllMuted()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
proc muteUnmuteItemsOrSubItemsByCategoryId*(self: Model, categoryId: string, mute: bool) =
|
||||||
|
for i in 0 ..< self.items.len:
|
||||||
|
if(self.items[i].categoryId == categoryId):
|
||||||
|
let index = self.createIndex(i, 0, nil)
|
||||||
|
self.items[i].subItems.muteUnmuteAll(mute)
|
||||||
|
self.items[i].BaseItem.muted = mute
|
||||||
|
self.dataChanged(index, index, @[ModelRole.Muted.int])
|
||||||
|
|
||||||
proc blockUnblockItemOrSubItemById*(self: Model, id: string, blocked: bool) =
|
proc blockUnblockItemOrSubItemById*(self: Model, id: string, blocked: bool) =
|
||||||
for i in 0 ..< self.items.len:
|
for i in 0 ..< self.items.len:
|
||||||
|
|
|
@ -577,6 +577,18 @@ method muteChat*(self: Module, chatId: string) =
|
||||||
method unmuteChat*(self: Module, chatId: string) =
|
method unmuteChat*(self: Module, chatId: string) =
|
||||||
self.controller.unmuteChat(chatId)
|
self.controller.unmuteChat(chatId)
|
||||||
|
|
||||||
|
method muteCategory*(self: Module, categoryId: string) =
|
||||||
|
self.controller.muteCategory(categoryId)
|
||||||
|
|
||||||
|
method unmuteCategory*(self: Module, categoryId: string) =
|
||||||
|
self.controller.unmuteCategory(categoryId)
|
||||||
|
|
||||||
|
method onCategoryMuted*(self: Module, categoryId: string) =
|
||||||
|
self.view.chatsModel().muteUnmuteItemsOrSubItemsByCategoryId(categoryId, true)
|
||||||
|
|
||||||
|
method onCategoryUnmuted*(self: Module, categoryId: string) =
|
||||||
|
self.view.chatsModel().muteUnmuteItemsOrSubItemsByCategoryId(categoryId, false)
|
||||||
|
|
||||||
method onChatMuted*(self: Module, chatId: string) =
|
method onChatMuted*(self: Module, chatId: string) =
|
||||||
self.view.chatsModel().muteUnmuteItemOrSubItemById(chatId, mute=true)
|
self.view.chatsModel().muteUnmuteItemOrSubItemById(chatId, mute=true)
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,18 @@ QtObject:
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
proc muteUnmuteAll*(self: SubModel, mute: bool) =
|
||||||
|
for i in 0 ..< self.items.len:
|
||||||
|
let index = self.createIndex(i, 0, nil)
|
||||||
|
self.items[i].BaseItem.muted = mute
|
||||||
|
self.dataChanged(index, index, @[ModelRole.Muted.int])
|
||||||
|
|
||||||
|
proc isAllMuted*(self: SubModel): bool =
|
||||||
|
for i in 0 ..< self.items.len:
|
||||||
|
if not self.items[i].BaseItem.muted:
|
||||||
|
return false
|
||||||
|
return self.items.len > 0
|
||||||
|
|
||||||
proc blockUnblockItemById*(self: SubModel, id: string, blocked: bool): bool =
|
proc blockUnblockItemById*(self: SubModel, id: string, blocked: bool): bool =
|
||||||
## even we're not able to block specific channel of community now, this is here more as a predisposition
|
## even we're not able to block specific channel of community now, this is here more as a predisposition
|
||||||
## for that feature, which may be added easy later.
|
## for that feature, which may be added easy later.
|
||||||
|
|
|
@ -154,6 +154,12 @@ QtObject:
|
||||||
proc unmuteChat*(self: View, chatId: string) {.slot.} =
|
proc unmuteChat*(self: View, chatId: string) {.slot.} =
|
||||||
self.delegate.unmuteChat(chatId)
|
self.delegate.unmuteChat(chatId)
|
||||||
|
|
||||||
|
proc muteCategory*(self: View, categoryId: string) {.slot.} =
|
||||||
|
self.delegate.muteCategory(categoryId)
|
||||||
|
|
||||||
|
proc unmuteCategory*(self: View, categoryId: string) {.slot.} =
|
||||||
|
self.delegate.unmuteCategory(categoryId)
|
||||||
|
|
||||||
proc markAllMessagesRead*(self: View, chatId: string) {.slot.} =
|
proc markAllMessagesRead*(self: View, chatId: string) {.slot.} =
|
||||||
self.delegate.markAllMessagesRead(chatId)
|
self.delegate.markAllMessagesRead(chatId)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ type CommunityMembershipRequestDto* = object
|
||||||
type CommunitySettingsDto* = object
|
type CommunitySettingsDto* = object
|
||||||
id*: string
|
id*: string
|
||||||
historyArchiveSupportEnabled*: bool
|
historyArchiveSupportEnabled*: bool
|
||||||
|
categoriesMuted*: seq[string]
|
||||||
|
|
||||||
type CommunityAdminSettingsDto* = object
|
type CommunityAdminSettingsDto* = object
|
||||||
pinMessageAllMembersEnabled*: bool
|
pinMessageAllMembersEnabled*: bool
|
||||||
|
|
|
@ -69,6 +69,10 @@ type
|
||||||
communityId*: string
|
communityId*: string
|
||||||
muted*: bool
|
muted*: bool
|
||||||
|
|
||||||
|
CategoryArgs* = ref object of Args
|
||||||
|
communityId*: string
|
||||||
|
categoryId*: string
|
||||||
|
|
||||||
# Signals which may be emitted by this service:
|
# Signals which may be emitted by this service:
|
||||||
const SIGNAL_COMMUNITY_JOINED* = "communityJoined"
|
const SIGNAL_COMMUNITY_JOINED* = "communityJoined"
|
||||||
const SIGNAL_COMMUNITY_MY_REQUEST_ADDED* = "communityMyRequestAdded"
|
const SIGNAL_COMMUNITY_MY_REQUEST_ADDED* = "communityMyRequestAdded"
|
||||||
|
@ -93,6 +97,8 @@ const SIGNAL_COMMUNITY_MEMBER_REMOVED* = "communityMemberRemoved"
|
||||||
const SIGNAL_NEW_REQUEST_TO_JOIN_COMMUNITY* = "newRequestToJoinCommunity"
|
const SIGNAL_NEW_REQUEST_TO_JOIN_COMMUNITY* = "newRequestToJoinCommunity"
|
||||||
const SIGNAL_CURATED_COMMUNITY_FOUND* = "curatedCommunityFound"
|
const SIGNAL_CURATED_COMMUNITY_FOUND* = "curatedCommunityFound"
|
||||||
const SIGNAL_COMMUNITY_MUTED* = "communityMuted"
|
const SIGNAL_COMMUNITY_MUTED* = "communityMuted"
|
||||||
|
const SIGNAL_CATEGORY_MUTED* = "categoryMuted"
|
||||||
|
const SIGNAL_CATEGORY_UNMUTED* = "categoryUnmuted"
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
|
@ -1072,6 +1078,32 @@ QtObject:
|
||||||
error "Error inviting to community", msg = e.msg
|
error "Error inviting to community", msg = e.msg
|
||||||
result = "Error exporting community: " & e.msg
|
result = "Error exporting community: " & e.msg
|
||||||
|
|
||||||
|
proc muteCategory*(self: Service, communityId: string, categoryId: string) =
|
||||||
|
try:
|
||||||
|
let response = status_go.muteCategory(communityId, categoryId)
|
||||||
|
if (not response.error.isNil):
|
||||||
|
let msg = response.error.message & " categoryId=" & categoryId
|
||||||
|
error "error while mute category ", msg
|
||||||
|
return
|
||||||
|
|
||||||
|
self.events.emit(SIGNAL_CATEGORY_MUTED, CategoryArgs(communityId: communityId, categoryId: categoryId))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
error "Error muting category", msg = e.msg
|
||||||
|
|
||||||
|
proc unmuteCategory*(self: Service, communityId: string, categoryId: string) =
|
||||||
|
try:
|
||||||
|
let response = status_go.unmuteCategory(communityId, categoryId)
|
||||||
|
if (not response.error.isNil):
|
||||||
|
let msg = response.error.message & " categoryId=" & categoryId
|
||||||
|
error "error while unmute category ", msg
|
||||||
|
return
|
||||||
|
|
||||||
|
self.events.emit(SIGNAL_CATEGORY_UNMUTED, CategoryArgs(communityId: communityId, categoryId: categoryId))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
error "Error unmuting category", msg = e.msg
|
||||||
|
|
||||||
proc removeUserFromCommunity*(self: Service, communityId: string, pubKey: string) =
|
proc removeUserFromCommunity*(self: Service, communityId: string, pubKey: string) =
|
||||||
try:
|
try:
|
||||||
discard status_go.removeUserFromCommunity(communityId, pubKey)
|
discard status_go.removeUserFromCommunity(communityId, pubKey)
|
||||||
|
|
|
@ -8,6 +8,14 @@ export response_type
|
||||||
|
|
||||||
proc getCommunityTags*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
proc getCommunityTags*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
result = callPrivateRPC("communityTags".prefix)
|
result = callPrivateRPC("communityTags".prefix)
|
||||||
|
|
||||||
|
proc muteCategory*(communityId: string, categoryId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
|
let payload = %* [communityId, categoryId]
|
||||||
|
result = callPrivateRPC("muteCommunityCategory".prefix, payload)
|
||||||
|
|
||||||
|
proc unmuteCategory*(communityId: string, categoryId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
|
let payload = %* [communityId, categoryId]
|
||||||
|
result = callPrivateRPC("unmuteCommunityCategory".prefix, payload)
|
||||||
|
|
||||||
proc getJoinedComunities*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
proc getJoinedComunities*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
let payload = %* []
|
let payload = %* []
|
||||||
|
|
|
@ -234,6 +234,18 @@ Item {
|
||||||
categoryItem = obj
|
categoryItem = obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusMenuItem {
|
||||||
|
text: categoryItem.muted ? qsTr("Unmute category") : qsTr("Mute category")
|
||||||
|
icon.name: "notification"
|
||||||
|
onTriggered: {
|
||||||
|
if (categoryItem.muted) {
|
||||||
|
root.communitySectionModule.unmuteCategory(categoryItem.itemId)
|
||||||
|
} else {
|
||||||
|
root.communitySectionModule.muteCategory(categoryItem.itemId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StatusMenuItem {
|
StatusMenuItem {
|
||||||
enabled: communityData.amISectionAdmin
|
enabled: communityData.amISectionAdmin
|
||||||
//% "Edit Category"
|
//% "Edit Category"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0322ac497bf9e4852b99780f4ff08377a8c3f267
|
Subproject commit 3e65e36fa6312e8c9ccd7e41dc0f8bfc84b37e2e
|
Loading…
Reference in New Issue