chore: clean up modules and controllers by removing the useless function
This commit is contained in:
parent
330ccb58a6
commit
3fa315c3a8
|
@ -190,9 +190,6 @@ proc getChatDetails*(self: Controller): ChatDto =
|
||||||
proc getCommunityDetails*(self: Controller): CommunityDto =
|
proc getCommunityDetails*(self: Controller): CommunityDto =
|
||||||
return self.communityService.getCommunityById(self.sectionId)
|
return self.communityService.getCommunityById(self.sectionId)
|
||||||
|
|
||||||
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
|
||||||
return self.communityService.getCommunityById(communityId)
|
|
||||||
|
|
||||||
proc getOneToOneChatNameAndImage*(self: Controller): tuple[name: string, image: string, largeImage: string] =
|
proc getOneToOneChatNameAndImage*(self: Controller): tuple[name: string, image: string, largeImage: string] =
|
||||||
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
|
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
|
||||||
|
|
||||||
|
|
|
@ -242,9 +242,6 @@ proc getChatDetails*(self: Controller): ChatDto =
|
||||||
proc getCommunityDetails*(self: Controller): CommunityDto =
|
proc getCommunityDetails*(self: Controller): CommunityDto =
|
||||||
return self.communityService.getCommunityById(self.sectionId)
|
return self.communityService.getCommunityById(self.sectionId)
|
||||||
|
|
||||||
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
|
||||||
return self.communityService.getCommunityById(communityId)
|
|
||||||
|
|
||||||
proc getOneToOneChatNameAndImage*(self: Controller):
|
proc getOneToOneChatNameAndImage*(self: Controller):
|
||||||
tuple[name: string, image: string, largeImage: string] =
|
tuple[name: string, image: string, largeImage: string] =
|
||||||
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
|
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
|
||||||
|
|
|
@ -237,8 +237,6 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
|
||||||
if message.deleted or message.deletedForMe:
|
if message.deleted or message.deletedForMe:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let chatDetails = self.controller.getChatDetails()
|
|
||||||
|
|
||||||
let sender = self.controller.getContactDetails(message.`from`)
|
let sender = self.controller.getContactDetails(message.`from`)
|
||||||
var quotedMessageAuthorDetails = ContactDetails()
|
var quotedMessageAuthorDetails = ContactDetails()
|
||||||
if message.quotedMessage.`from` != "":
|
if message.quotedMessage.`from` != "":
|
||||||
|
@ -248,8 +246,7 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
|
||||||
quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`)
|
quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`)
|
||||||
|
|
||||||
var communityChats: seq[ChatDto]
|
var communityChats: seq[ChatDto]
|
||||||
if chatDetails.communityId != "":
|
communityChats = self.controller.getCommunityDetails().chats
|
||||||
communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
|
||||||
|
|
||||||
var renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
var renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||||
|
|
||||||
|
@ -367,8 +364,7 @@ method messagesAdded*(self: Module, messages: seq[MessageDto]) =
|
||||||
|
|
||||||
for message in messages:
|
for message in messages:
|
||||||
let sender = self.controller.getContactDetails(message.`from`)
|
let sender = self.controller.getContactDetails(message.`from`)
|
||||||
let chatDetails = self.controller.getChatDetails()
|
let communityChats = self.controller.getCommunityDetails().chats
|
||||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
|
||||||
var quotedMessageAuthorDetails = ContactDetails()
|
var quotedMessageAuthorDetails = ContactDetails()
|
||||||
if message.quotedMessage.`from` != "":
|
if message.quotedMessage.`from` != "":
|
||||||
if(message.`from` == message.quotedMessage.`from`):
|
if(message.`from` == message.quotedMessage.`from`):
|
||||||
|
@ -597,8 +593,7 @@ method updateContactDetails*(self: Module, contactId: string) =
|
||||||
item.quotedMessageAuthorAvatar = updatedContact.icon
|
item.quotedMessageAuthorAvatar = updatedContact.icon
|
||||||
|
|
||||||
if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId):
|
if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId):
|
||||||
let chatDetails = self.controller.getChatDetails()
|
let communityChats = self.controller.getCommunityDetails().chats
|
||||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
|
||||||
item.messageText = self.controller.getRenderedText(item.parsedText, communityChats)
|
item.messageText = self.controller.getRenderedText(item.parsedText, communityChats)
|
||||||
|
|
||||||
method deleteMessage*(self: Module, messageId: string) =
|
method deleteMessage*(self: Module, messageId: string) =
|
||||||
|
@ -616,8 +611,7 @@ method onMessageEdited*(self: Module, message: MessageDto) =
|
||||||
return
|
return
|
||||||
|
|
||||||
let mentionedUsersPks = itemBeforeChange.mentionedUsersPks
|
let mentionedUsersPks = itemBeforeChange.mentionedUsersPks
|
||||||
let chatDetails = self.controller.getChatDetails()
|
let communityChats = self.controller.getCommunityDetails().chats
|
||||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
|
||||||
|
|
||||||
self.view.model().updateEditedMsg(
|
self.view.model().updateEditedMsg(
|
||||||
message.id,
|
message.id,
|
||||||
|
|
|
@ -153,8 +153,7 @@ proc buildPinnedMessageItem(self: Module, message: MessageDto, actionInitiatedBy
|
||||||
item: var pinned_msg_item.Item):bool =
|
item: var pinned_msg_item.Item):bool =
|
||||||
|
|
||||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||||
let chatDetails = self.controller.getChatDetails()
|
let communityChats = self.controller.getCommunityDetails().chats
|
||||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
|
||||||
var quotedMessageAuthorDetails = ContactDetails()
|
var quotedMessageAuthorDetails = ContactDetails()
|
||||||
if message.quotedMessage.`from` != "":
|
if message.quotedMessage.`from` != "":
|
||||||
if(message.`from` == message.quotedMessage.`from`):
|
if(message.`from` == message.quotedMessage.`from`):
|
||||||
|
@ -342,8 +341,7 @@ method onContactDetailsUpdated*(self: Module, contactId: string) =
|
||||||
item.quotedMessageAuthorAvatar = updatedContact.icon
|
item.quotedMessageAuthorAvatar = updatedContact.icon
|
||||||
|
|
||||||
if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId):
|
if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId):
|
||||||
let chatDetails = self.controller.getChatDetails()
|
let communityChats = self.controller.getCommunityDetails().chats
|
||||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
|
||||||
item.messageText = self.controller.getRenderedText(item.parsedText, communityChats)
|
item.messageText = self.controller.getRenderedText(item.parsedText, communityChats)
|
||||||
|
|
||||||
if(self.controller.getMyChatId() == contactId):
|
if(self.controller.getMyChatId() == contactId):
|
||||||
|
|
|
@ -263,7 +263,6 @@ proc init*(self: Controller) =
|
||||||
self.delegate.onCommunityTokenPermissionUpdated(args.communityId, args.tokenPermission)
|
self.delegate.onCommunityTokenPermissionUpdated(args.communityId, args.tokenPermission)
|
||||||
self.asyncCheckPermissions()
|
self.asyncCheckPermissions()
|
||||||
|
|
||||||
|
|
||||||
self.events.on(SIGNAL_COMMUNITY_TOKEN_PERMISSION_UPDATE_FAILED) do(e: Args):
|
self.events.on(SIGNAL_COMMUNITY_TOKEN_PERMISSION_UPDATE_FAILED) do(e: Args):
|
||||||
let args = CommunityTokenPermissionArgs(e)
|
let args = CommunityTokenPermissionArgs(e)
|
||||||
if (args.communityId == self.sectionId):
|
if (args.communityId == self.sectionId):
|
||||||
|
@ -326,6 +325,7 @@ proc init*(self: Controller) =
|
||||||
|
|
||||||
self.events.on(SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED_NO_PERMISSION) do(e: Args):
|
self.events.on(SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED_NO_PERMISSION) do(e: Args):
|
||||||
var args = CommunityMemberArgs(e)
|
var args = CommunityMemberArgs(e)
|
||||||
|
if (args.communityId == self.sectionId):
|
||||||
self.delegate.onAcceptRequestToJoinFailedNoPermission(args.communityId, args.pubKey, args.requestId)
|
self.delegate.onAcceptRequestToJoinFailedNoPermission(args.communityId, args.pubKey, args.requestId)
|
||||||
|
|
||||||
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
|
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
|
||||||
|
@ -380,11 +380,8 @@ proc init*(self: Controller) =
|
||||||
proc isCommunity*(self: Controller): bool =
|
proc isCommunity*(self: Controller): bool =
|
||||||
return self.isCommunitySection
|
return self.isCommunitySection
|
||||||
|
|
||||||
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
|
||||||
return self.communityService.getCommunityById(communityId)
|
|
||||||
|
|
||||||
proc getMyCommunity*(self: Controller): CommunityDto =
|
proc getMyCommunity*(self: Controller): CommunityDto =
|
||||||
return self.getCommunityById(self.sectionId)
|
return self.communityService.getCommunityById(self.sectionId)
|
||||||
|
|
||||||
proc getCategories*(self: Controller, communityId: string): seq[Category] =
|
proc getCategories*(self: Controller, communityId: string): seq[Category] =
|
||||||
return self.communityService.getCategories(communityId)
|
return self.communityService.getCategories(communityId)
|
||||||
|
|
|
@ -662,7 +662,7 @@ method onCommunityCategoryCreated*(self: Module, cat: Category, chats: seq[ChatD
|
||||||
if (self.doesCatOrChatExist(cat.id)):
|
if (self.doesCatOrChatExist(cat.id)):
|
||||||
return
|
return
|
||||||
|
|
||||||
let community = self.controller.getCommunityById(communityId)
|
let community = self.controller.getMyCommunity()
|
||||||
discard self.addCategoryItem(cat, community.memberRole, communityId)
|
discard self.addCategoryItem(cat, community.memberRole, communityId)
|
||||||
# Update chat items that now belong to that category
|
# Update chat items that now belong to that category
|
||||||
self.view.chatsModel().updateItemsWithCategoryDetailsById(
|
self.view.chatsModel().updateItemsWithCategoryDetailsById(
|
||||||
|
@ -763,7 +763,7 @@ method onCommunityTokenPermissionDeleted*(self: Module, communityId: string, per
|
||||||
singletonInstance.globalEvents.showCommunityTokenPermissionDeletedNotification(communityId, "Community permission deleted", "A token permission has been removed")
|
singletonInstance.globalEvents.showCommunityTokenPermissionDeletedNotification(communityId, "Community permission deleted", "A token permission has been removed")
|
||||||
|
|
||||||
method onCommunityTokenPermissionCreated*(self: Module, communityId: string, tokenPermission: CommunityTokenPermissionDto) =
|
method onCommunityTokenPermissionCreated*(self: Module, communityId: string, tokenPermission: CommunityTokenPermissionDto) =
|
||||||
let community = self.controller.getCommunityById(communityId)
|
let community = self.controller.getMyCommunity()
|
||||||
let chats = community.getCommunityChats(tokenPermission.chatIds)
|
let chats = community.getCommunityChats(tokenPermission.chatIds)
|
||||||
let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats)
|
let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats)
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ method onCommunityCheckPermissionsToJoinResponse*(self: Module, checkPermissions
|
||||||
self.setPermissionsToJoinCheckOngoing(false)
|
self.setPermissionsToJoinCheckOngoing(false)
|
||||||
|
|
||||||
method onCommunityTokenPermissionUpdated*(self: Module, communityId: string, tokenPermission: CommunityTokenPermissionDto) =
|
method onCommunityTokenPermissionUpdated*(self: Module, communityId: string, tokenPermission: CommunityTokenPermissionDto) =
|
||||||
let community = self.controller.getCommunityById(communityId)
|
let community = self.controller.getMyCommunity()
|
||||||
let chats = community.getCommunityChats(tokenPermission.chatIds)
|
let chats = community.getCommunityChats(tokenPermission.chatIds)
|
||||||
let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats)
|
let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats)
|
||||||
self.view.tokenPermissionsModel.updateItem(tokenPermission.id, tokenPermissionItem)
|
self.view.tokenPermissionsModel.updateItem(tokenPermission.id, tokenPermissionItem)
|
||||||
|
@ -979,7 +979,7 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
||||||
notificationType = notification_details.NotificationType.NewMessageWithGlobalMention
|
notificationType = notification_details.NotificationType.NewMessageWithGlobalMention
|
||||||
|
|
||||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
let communityChats = self.controller.getMyCommunity().chats
|
||||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||||
var plainText = singletonInstance.utils.plainText(renderedMessageText)
|
var plainText = singletonInstance.utils.plainText(renderedMessageText)
|
||||||
if message.contentType == ContentType.Sticker or (message.contentType == ContentType.Image and len(plainText) == 0):
|
if message.contentType == ContentType.Sticker or (message.contentType == ContentType.Image and len(plainText) == 0):
|
||||||
|
@ -1048,7 +1048,7 @@ method declineRequestToJoinCommunity*(self: Module, requestId: string, community
|
||||||
self.controller.declineRequestToJoinCommunity(requestId, communityId)
|
self.controller.declineRequestToJoinCommunity(requestId, communityId)
|
||||||
|
|
||||||
method onAcceptRequestToJoinFailedNoPermission*(self: Module, communityId: string, memberKey: string, requestId: string) =
|
method onAcceptRequestToJoinFailedNoPermission*(self: Module, communityId: string, memberKey: string, requestId: string) =
|
||||||
let community = self.controller.getCommunityById(communityId)
|
let community = self.controller.getMyCommunity()
|
||||||
let contact = self.controller.getContactById(memberKey)
|
let contact = self.controller.getContactById(memberKey)
|
||||||
self.view.emitOpenNoPermissionsToJoinPopupSignal(community.name, contact.displayName, community.id, requestId)
|
self.view.emitOpenNoPermissionsToJoinPopupSignal(community.name, contact.displayName, community.id, requestId)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue