mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-03 10:14:04 +00:00
parent
f4a78a29be
commit
08c01d2775
@ -13,9 +13,11 @@ type
|
||||
muted: bool
|
||||
active: bool
|
||||
position: int
|
||||
categoryId: string
|
||||
|
||||
proc setup*(self: BaseItem, id, name, icon: string, isIdenticon: bool, color, description: string, `type`: int,
|
||||
amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int) =
|
||||
proc setup*(self: BaseItem, id, name, icon: string, isIdenticon: bool, color, description: string,
|
||||
`type`: int, amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool,
|
||||
position: int, categoryId: string = "") =
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.amIChatAdmin = amIChatAdmin
|
||||
@ -29,12 +31,14 @@ proc setup*(self: BaseItem, id, name, icon: string, isIdenticon: bool, color, de
|
||||
self.muted = muted
|
||||
self.active = active
|
||||
self.position = position
|
||||
self.categoryId = categoryId
|
||||
|
||||
proc initBaseItem*(id, name, icon: string, isIdenticon: bool, color, description: string, `type`: int,
|
||||
amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int): BaseItem =
|
||||
amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool,
|
||||
position: int, categoryId: string = ""): BaseItem =
|
||||
result = BaseItem()
|
||||
result.setup(id, name, icon, isIdenticon, color, description, `type`, amIChatAdmin, hasUnreadMessages,
|
||||
notificationsCount, muted, active, position)
|
||||
notificationsCount, muted, active, position, categoryId)
|
||||
|
||||
proc delete*(self: BaseItem) =
|
||||
discard
|
||||
@ -104,3 +108,9 @@ method position*(self: BaseItem): int {.inline base.} =
|
||||
|
||||
method `position=`*(self: var BaseItem, value: int) {.inline base.} =
|
||||
self.position = value
|
||||
|
||||
method categoryId*(self: BaseItem): string {.inline base.} =
|
||||
self.categoryId
|
||||
|
||||
method `categoryId=`*(self: var BaseItem, value: string) {.inline base.} =
|
||||
self.categoryId = value
|
||||
|
@ -16,6 +16,7 @@ QtObject:
|
||||
hasUnreadMessages: bool
|
||||
notificationsCount: int
|
||||
muted: bool
|
||||
position: int
|
||||
|
||||
proc delete*(self: ChatDetails) =
|
||||
self.QObject.delete
|
||||
@ -25,8 +26,8 @@ QtObject:
|
||||
result.QObject.setup
|
||||
|
||||
proc setChatDetails*(self: ChatDetails, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
|
||||
name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool, notificationsCount: int,
|
||||
muted: bool) =
|
||||
name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool,
|
||||
notificationsCount: int, muted: bool, position: int) =
|
||||
self.id = id
|
||||
self.`type` = `type`
|
||||
self.belongsToCommunity = belongsToCommunity
|
||||
@ -39,6 +40,7 @@ QtObject:
|
||||
self.hasUnreadMessages = hasUnreadMessages
|
||||
self.notificationsCount = notificationsCount
|
||||
self.muted = muted
|
||||
self.position = position
|
||||
|
||||
proc getId(self: ChatDetails): string {.slot.} =
|
||||
return self.id
|
||||
@ -142,4 +144,15 @@ QtObject:
|
||||
|
||||
proc setMuted*(self: ChatDetails, value: bool) = # this is not a slot
|
||||
self.muted = value
|
||||
self.mutedChanged()
|
||||
self.mutedChanged()
|
||||
|
||||
proc positionChanged(self: ChatDetails) {.signal.}
|
||||
proc getPosition(self: ChatDetails): int {.slot.} =
|
||||
return self.position
|
||||
QtProperty[int] position:
|
||||
read = getPosition
|
||||
notify = positionChanged
|
||||
|
||||
proc setPotion*(self: ChatDetails, value: int) = # this is not a slot
|
||||
self.position = value
|
||||
self.positionChanged()
|
@ -75,8 +75,9 @@ method load*(self: Module) =
|
||||
(chatName, chatImage, isIdenticon) = self.controller.getOneToOneChatNameAndImage()
|
||||
|
||||
self.view.load(chatDto.id, chatDto.chatType.int, self.controller.belongsToCommunity(),
|
||||
self.controller.isUsersListAvailable(), chatName, chatImage, isIdenticon, chatDto.color, chatDto.description,
|
||||
hasNotification, notificationsCount, chatDto.muted)
|
||||
self.controller.isUsersListAvailable(), chatName, chatImage, isIdenticon,
|
||||
chatDto.color, chatDto.description, hasNotification, notificationsCount,
|
||||
chatDto.muted, chatDto.position)
|
||||
|
||||
self.inputAreaModule.load()
|
||||
self.messagesModule.load()
|
||||
|
@ -30,10 +30,11 @@ QtObject:
|
||||
result.chatDetails = newChatDetails()
|
||||
result.chatDetailsVariant = newQVariant(result.chatDetails)
|
||||
|
||||
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool, name, icon: string,
|
||||
isIdenticon: bool, color, description: string, hasUnreadMessages: bool, notificationsCount: int, muted: bool) =
|
||||
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name, icon, isIdenticon,
|
||||
color, description, hasUnreadMessages, notificationsCount, muted)
|
||||
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
|
||||
name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool,
|
||||
notificationsCount: int, muted: bool, position: int) =
|
||||
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name, icon,
|
||||
isIdenticon, color, description, hasUnreadMessages, notificationsCount, muted, position)
|
||||
self.delegate.viewDidLoad()
|
||||
self.chatDetailsChanged()
|
||||
|
||||
|
@ -279,6 +279,21 @@ method createCommunityChannel*(
|
||||
categoryId: string) =
|
||||
self.communityService.createCommunityChannel(self.sectionId, name, description, categoryId)
|
||||
|
||||
method editCommunityChannel*(
|
||||
self: Controller,
|
||||
channelId: string,
|
||||
name: string,
|
||||
description: string,
|
||||
categoryId: string,
|
||||
position: int) =
|
||||
self.communityService.editCommunityChannel(
|
||||
self.sectionId,
|
||||
channelId,
|
||||
name,
|
||||
description,
|
||||
categoryId,
|
||||
position)
|
||||
|
||||
method createCommunityCategory*(self: Controller, name: string, channels: seq[string]) =
|
||||
self.communityService.createCommunityCategory(self.sectionId, name, channels)
|
||||
|
||||
|
@ -126,6 +126,9 @@ method declineRequestToJoinCommunity*(self: AccessInterface, requestId: string)
|
||||
method createCommunityChannel*(self: AccessInterface, name: string, description: string, categoryId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method editCommunityChannel*(self: AccessInterface, channelId: string, name: string, description: string, categoryId: string, position: int) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -6,10 +6,10 @@ type
|
||||
subItems: SubModel
|
||||
|
||||
proc initItem*(id, name, icon: string, isIdenticon: bool, color, description: string, `type`: int, amIChatAdmin: bool,
|
||||
hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int): Item =
|
||||
hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int, categoryId: string): Item =
|
||||
result = Item()
|
||||
result.setup(id, name, icon, isIdenticon, color, description, `type`, amIChatAdmin, hasUnreadMessages,
|
||||
notificationsCount, muted, active, position)
|
||||
notificationsCount, muted, active, position, categoryId)
|
||||
result.subItems = newSubModel()
|
||||
|
||||
proc delete*(self: Item) =
|
||||
@ -34,6 +34,7 @@ proc `$`*(self: Item): string =
|
||||
muted: {self.muted},
|
||||
active: {self.active},
|
||||
position: {self.position},
|
||||
categoryId: {self.categoryId},
|
||||
subItems:[
|
||||
{$self.subItems}
|
||||
]"""
|
||||
@ -52,7 +53,8 @@ proc toJsonNode*(self: Item): JsonNode =
|
||||
"notificationsCount": self.notificationsCount,
|
||||
"muted": self.muted,
|
||||
"active": self.active,
|
||||
"position": self.position
|
||||
"position": self.position,
|
||||
"categoryId": self.categoryId
|
||||
}
|
||||
|
||||
proc appendSubItems*(self: Item, items: seq[SubItem]) =
|
||||
|
@ -111,7 +111,7 @@ proc buildChatUI(self: Module, events: EventEmitter,
|
||||
let amIChatAdmin = self.amIMarkedAsAdminUser(c.members)
|
||||
|
||||
let item = initItem(c.id, chatName, chatImage, isIdenticon, c.color, c.description, c.chatType.int, amIChatAdmin,
|
||||
hasNotification, notificationsCount, c.muted, false, 0)
|
||||
hasNotification, notificationsCount, c.muted, active = false, c.position, c.categoryId)
|
||||
self.view.chatsModel().appendItem(item)
|
||||
self.addSubmodule(c.id, false, isUsersListAvailable, events, settingsService, contactService, chatService,
|
||||
communityService, messageService, gifService)
|
||||
@ -144,8 +144,9 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
|
||||
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
|
||||
let notificationsCount = chatDto.unviewedMentionsCount
|
||||
let amIChatAdmin = comm.admin
|
||||
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color, chatDto.description,
|
||||
chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, false, c.position)
|
||||
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color,
|
||||
chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount,
|
||||
chatDto.muted, active = false, c.position, c.categoryId)
|
||||
self.view.chatsModel().appendItem(channelItem)
|
||||
self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService,
|
||||
messageService, gifService)
|
||||
@ -187,7 +188,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
|
||||
selectedSubItemId = channelItem.id
|
||||
|
||||
var categoryItem = initItem(cat.id, cat.name, "", false, "", "", ChatType.Unknown.int, false,
|
||||
hasNotificationPerCategory, notificationsCountPerCategory, false, false, cat.position)
|
||||
hasNotificationPerCategory, notificationsCountPerCategory, false, false, cat.position, cat.id)
|
||||
categoryItem.prependSubItems(categoryChannels)
|
||||
self.view.chatsModel().appendItem(categoryItem)
|
||||
|
||||
@ -369,7 +370,8 @@ method addNewChat*(
|
||||
|
||||
if chatDto.categoryId == "":
|
||||
let item = initItem(chatDto.id, chatName, chatImage, isIdenticon, chatDto.color, chatDto.description,
|
||||
chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, false, 0)
|
||||
chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted,
|
||||
active = false, position = 0, chatDto.categoryId)
|
||||
self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService,
|
||||
communityService, messageService, gifService)
|
||||
self.chatContentModules[chatDto.id].load()
|
||||
@ -395,7 +397,7 @@ method removeCommunityChat*(self: Module, chatId: string) =
|
||||
|
||||
method onCommunityCategoryCreated*(self: Module, cat: Category, chats: seq[ChatDto]) =
|
||||
var categoryItem = initItem(cat.id, cat.name, "", false, "", "", ChatType.Unknown.int, false,
|
||||
false, 0, false, false, cat.position)
|
||||
false, 0, false, false, cat.position, cat.id)
|
||||
var categoryChannels: seq[SubItem]
|
||||
for chatDto in chats:
|
||||
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
|
||||
@ -573,6 +575,10 @@ method declineRequestToJoinCommunity*(self: Module, requestId: string) =
|
||||
method createCommunityChannel*(self: Module, name, description, categoryId: string) =
|
||||
self.controller.createCommunityChannel(name, description, categoryId)
|
||||
|
||||
method editCommunityChannel*(self: Module, channelId, name, description, categoryId: string,
|
||||
position: int) =
|
||||
self.controller.editCommunityChannel(channelId, name, description, categoryId, position)
|
||||
|
||||
method createCommunityCategory*(self: Module, name: string, channels: seq[string]) =
|
||||
self.controller.createCommunityCategory(name, channels)
|
||||
|
||||
|
@ -94,6 +94,9 @@ method declineRequestToJoinCommunity*(self: AccessInterface, requestId: string)
|
||||
method createCommunityChannel*(self: AccessInterface, name: string, description: string, categoryId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method editCommunityChannel*(self: AccessInterface, channelId, name, description, categoryId: string, position: int) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method leaveCommunity*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -191,6 +191,22 @@ QtObject:
|
||||
proc createCommunityChannel*(self: View, name: string, description: string, categoryId: string) {.slot.} =
|
||||
self.delegate.createCommunityChannel(name, description, categoryId)
|
||||
|
||||
proc editCommunityChannel*(
|
||||
self: View,
|
||||
channelId: string,
|
||||
name: string,
|
||||
description: string,
|
||||
categoryId: string,
|
||||
position: int
|
||||
) {.slot.} =
|
||||
self.delegate.editCommunityChannel(
|
||||
channelId,
|
||||
name,
|
||||
description,
|
||||
categoryId,
|
||||
position
|
||||
)
|
||||
|
||||
proc leaveCommunity*(self: View) {.slot.} =
|
||||
self.delegate.leaveCommunity()
|
||||
|
||||
|
@ -68,22 +68,6 @@ method createCommunity*(
|
||||
imageUrl,
|
||||
aX, aY, bX, bY)
|
||||
|
||||
method editCommunityChannel*(
|
||||
self: Controller,
|
||||
communityId: string,
|
||||
channelId: string,
|
||||
name: string,
|
||||
description: string,
|
||||
categoryId: string,
|
||||
position: int) =
|
||||
self.communityService.editCommunityChannel(
|
||||
communityId,
|
||||
channelId,
|
||||
name,
|
||||
description,
|
||||
categoryId,
|
||||
position)
|
||||
|
||||
method reorderCommunityChat*(
|
||||
self: Controller,
|
||||
communityId: string,
|
||||
|
@ -108,14 +108,6 @@ method communityLeft*(self: Module, communityId: string) =
|
||||
# TODO to model or view
|
||||
discard
|
||||
|
||||
method communityChannelCreated*(self: Module) =
|
||||
# TODO to model or view
|
||||
discard
|
||||
|
||||
method communityChannelEdited*(self: Module) =
|
||||
# TODO to model or view
|
||||
discard
|
||||
|
||||
method communityChannelReordered*(self: Module) =
|
||||
# TODO to model or view
|
||||
discard
|
||||
|
@ -5,12 +5,6 @@ method myRequestAdded*(self: AccessInterface) {.base.} =
|
||||
method communityLeft*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityChannelCreated*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityChannelEdited*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityChannelReordered*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -14,6 +14,7 @@ StatusModal {
|
||||
id: popup
|
||||
|
||||
property bool isEdit: false
|
||||
property string chatId: ""
|
||||
property string categoryId: ""
|
||||
property string channelName: ""
|
||||
property string channelDescription: ""
|
||||
@ -22,7 +23,7 @@ StatusModal {
|
||||
readonly property int maxChannelDescLength: 140
|
||||
|
||||
signal createCommunityChannel(string chName, string chDescription, string chCategoryId)
|
||||
signal editCommunityChannel(string chName, string chDescription)
|
||||
signal editCommunityChannel(string chName, string chDescription, string chCategoryId)
|
||||
signal openPinnedMessagesPopup()
|
||||
|
||||
//% "New channel"
|
||||
@ -209,7 +210,8 @@ StatusModal {
|
||||
popup.categoryId)
|
||||
} else {
|
||||
popup.editCommunityChannel(Utils.filterXSS(popup.contentItem.channelName.input.text),
|
||||
Utils.filterXSS(popup.contentItem.channelDescription.input.text))
|
||||
Utils.filterXSS(popup.contentItem.channelDescription.input.text),
|
||||
popup.categoryId)
|
||||
}
|
||||
|
||||
if (error) {
|
||||
|
@ -227,10 +227,6 @@ ColumnLayout {
|
||||
})
|
||||
}
|
||||
|
||||
onEditCommunityChannel: {
|
||||
// Not Refactored Yet
|
||||
}
|
||||
|
||||
onOpenPinnedMessagesList: {
|
||||
if(!chatContentModule) {
|
||||
console.debug("error on open pinned messages from context menu - chat content module is not set")
|
||||
|
@ -22,6 +22,8 @@ StatusPopupMenu {
|
||||
property string chatIcon: ""
|
||||
property int chatType: -1
|
||||
property bool chatMuted: false
|
||||
property int channelPosition: -1
|
||||
property string chatCategoryId: ""
|
||||
|
||||
signal displayProfilePopup(string publicKey)
|
||||
signal displayGroupInfoPopup(string chatId)
|
||||
@ -36,7 +38,7 @@ StatusPopupMenu {
|
||||
|
||||
signal openPinnedMessagesList(string chatId)
|
||||
signal createCommunityChannel(string chatId, string newName, string newDescription)
|
||||
signal editCommunityChannel(string chatId, string newName, string newDescription)
|
||||
signal editCommunityChannel(string chatId, string newName, string newDescription, string newCategory)
|
||||
|
||||
StatusMenuItem {
|
||||
id: viewProfileMenuItem
|
||||
@ -124,7 +126,8 @@ StatusPopupMenu {
|
||||
Global.openPopup(editChannelPopup, {
|
||||
isEdit: true,
|
||||
channelName: root.chatName,
|
||||
channelDescription: root.chatDescription
|
||||
channelDescription: root.chatDescription,
|
||||
categoryId: root.chatCategoryId
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -138,7 +141,7 @@ StatusPopupMenu {
|
||||
root.createCommunityChannel(root.chatId, chName, chDescription);
|
||||
}
|
||||
onEditCommunityChannel: {
|
||||
root.editCommunityChannel(root.chatId, chName, chDescription);
|
||||
root.editCommunityChannel(root.chatId, chName, chDescription, chCategoryId);
|
||||
}
|
||||
onOpenPinnedMessagesPopup: {
|
||||
root.openPinnedMessagesList(root.chatId, chName, chDescription);
|
||||
|
@ -273,6 +273,8 @@ Item {
|
||||
chatDescription = obj.description
|
||||
chatType = obj.type
|
||||
chatMuted = obj.muted
|
||||
channelPosition = obj.position
|
||||
chatCategoryId = obj.categoryId
|
||||
}
|
||||
|
||||
onMuteChat: {
|
||||
@ -320,7 +322,13 @@ Item {
|
||||
}
|
||||
|
||||
onEditCommunityChannel: {
|
||||
// Not Refactored Yet
|
||||
communitySectionModule.editCommunityChannel(
|
||||
chatId,
|
||||
newName,
|
||||
newDescription,
|
||||
newCategory,
|
||||
channelPosition // TODO change this to the signal once it is modifiable
|
||||
)
|
||||
}
|
||||
|
||||
onOpenPinnedMessagesList: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user