Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/app/boot/app_controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ../../app_service/service/devices/service as devices_service
import ../../app_service/service/mailservers/service as mailservers_service
import ../../app_service/service/gif/service as gif_service
import ../../app_service/service/ens/service as ens_service
import ../../app_service/service/visual_identity/service as visual_identity_service

import ../modules/startup/module as startup_module
import ../modules/main/module as main_module
Expand Down Expand Up @@ -83,6 +84,7 @@ type
nodeService: node_service.Service
gifService: gif_service.Service
ensService: ens_service.Service
visualIdentityService: visual_identity_service.Service

# Modules
startupModule: startup_module.AccessInterface
Expand Down Expand Up @@ -146,7 +148,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
)
result.messageService = message_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.contactsService, result.ethService, result.tokenService, result.walletAccountService)
result.transactionService = transaction_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.transactionService = transaction_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.walletAccountService, result.ethService, result.networkService, result.settingsService)
result.bookmarkService = bookmark_service.newService()
result.profileService = profile_service.newService()
Expand Down Expand Up @@ -175,10 +177,11 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.nodeService = node_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.settingsService)
result.gifService = gif_service.newService(result.settingsService)
result.ensService = ens_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.settingsService, result.walletAccountService, result.transactionService, result.ethService,
result.ensService = ens_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.settingsService, result.walletAccountService, result.transactionService, result.ethService,
result.networkService, result.tokenService)
result.providerService = provider_service.newService(result.ensService)
result.visualIdentityService = visual_identity_service.newService()

# Modules
result.startupModule = startup_module.newModule[AppController](
Expand Down Expand Up @@ -219,6 +222,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.gifService,
result.ensService,
result.networkService,
result.visualIdentityService
)

# Do connections
Expand Down Expand Up @@ -267,6 +271,7 @@ proc delete*(self: AppController) =
self.generalService.delete
self.ensService.delete
self.gifService.delete
self.visualIdentityService.delete

proc startupDidLoad*(self: AppController) =
singletonInstance.engine.setRootContextProperty("localAppSettings", self.localAppSettingsVariant)
Expand Down Expand Up @@ -336,7 +341,8 @@ proc load(self: AppController) =
self.communityService,
self.messageService,
self.gifService,
self.mailserversService
self.mailserversService,
self.visualIdentityService,
)

proc userLoggedIn*(self: AppController) =
Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/main/chat_section/chat_content/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ../../../../../app_service/service/community/service as community_service
import ../../../../../app_service/service/gif/service as gif_service
import ../../../../../app_service/service/message/service as message_service
import ../../../../../app_service/service/mailservers/service as mailservers_service
import ../../../../../app_service/service/visual_identity/service as visual_identity_service

export io_interface

Expand All @@ -41,7 +42,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.ServiceInterface,
contactService: contact_service.Service, chatService: chat_service.Service,
communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service):
mailserversService: mailservers_service.Service, visualIdentityService: visual_identity_service.Service):
Module =
result = Module()
result.delegate = delegate
Expand All @@ -56,7 +57,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
contactService, communityService, chatService, messageService, mailserversService)
result.usersModule = users_module.newModule(
result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable,
contactService, chat_service, communityService, messageService,
contactService, chat_service, communityService, messageService, visualIdentityService
)

method delete*(self: Module) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ../../../../../../app_service/service/contacts/service as contact_service
import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/message/service as message_service
import ../../../../../../app_service/service/chat/service as chat_service

import ../../../../../../app_service/service/visual_identity/service as visual_identity_service

import ../../../../../core/eventemitter

Expand All @@ -24,12 +24,13 @@ type
chatService: chat_service.Service
communityService: community_service.Service
messageService: message_service.Service
visualIdentityService: visual_identity_service.Service

proc newController*(
delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service,
chatService: chat_service.Service, communityService: community_service.Service,
messageService: message_service.Service
messageService: message_service.Service, visualIdentityService: visual_identity_service.Service
): Controller =
result = Controller()
result.delegate = delegate
Expand All @@ -43,6 +44,7 @@ proc newController*(
result.communityService = communityService
result.messageService = messageService
result.chatService = chatService
result.visualIdentityService = visualIdentityService

method delete*(self: Controller) =
discard
Expand Down Expand Up @@ -153,3 +155,9 @@ method getContactDetails*(self: Controller, contactId: string): ContactDetails =

method getStatusForContact*(self: Controller, contactId: string): StatusUpdateDto =
return self.contactService.getStatusForContactWithId(contactId)

method getEmojiHash*(self: Controller, pubkey: string): EmojiHashDto =
return self.visual_identity_service.emojiHashOf(pubkey)

method getColorHash*(self: Controller, pubkey: string): ColorHashDto =
return self.visual_identity_service.colorHashOf(pubkey)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ../../../../../../app_service/service/contacts/service as contacts_service
import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/visual_identity/service

type
AccessInterface* {.pure inheritable.} = ref object of RootObj
Expand Down Expand Up @@ -32,3 +33,9 @@ method getChat*(self: AccessInterface): ChatDto {.base.} =

method getChatMemberInfo*(self: AccessInterface, id: string): (bool, bool) =
raise newException(ValueError, "No implementation available")

method getEmojiHash*(self: AccessInterface, pubkey: string): EmojiHashDto {.base.} =
raise newException(ValueError, "No implementation available")

method getColorHash*(self: AccessInterface, pubkey: string): ColorHashDto {.base.} =
raise newException(ValueError, "No implementation available")
17 changes: 13 additions & 4 deletions src/app/modules/main/chat_section/chat_content/users/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ../../../../../../app_service/service/contacts/service as contact_service
import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/message/service as message_service
import ../../../../../../app_service/service/visual_identity/service as visual_identity_service

export io_interface

Expand All @@ -24,15 +25,15 @@ proc newModule*(
delegate: delegate_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service,
chatService: chat_service.Service, communityService: community_service.Service,
messageService: message_service.Service,
messageService: message_service.Service, visualIdentityService: visual_identity_service.Service
): Module =
result = Module()
result.delegate = delegate
result.view = view.newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(
result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable,
contactService, chatService, communityService, messageService,
contactService, chatService, communityService, messageService, visualIdentityService
)
result.moduleLoaded = false

Expand Down Expand Up @@ -62,6 +63,8 @@ method viewDidLoad*(self: Module) =
singletonInstance.userProfile.getIcon(),
singletonInstance.userProfile.getIdenticon(),
singletonInstance.userProfile.getIsIdenticon(),
self.controller.getEmojiHash(singletonInstance.userProfile.getPubKey()),
self.controller.getColorHash(singletonInstance.userProfile.getPubKey()),
isAdded = true,
admin,
joined,
Expand All @@ -87,8 +90,10 @@ method viewDidLoad*(self: Module) =
contactDetails.icon,
contactDetails.details.identicon,
contactDetails.isidenticon,
self.controller.getEmojiHash(publicKey),
self.controller.getColorHash(publicKey),
Comment thread
osmaczko marked this conversation as resolved.
contactDetails.details.added,
admin,
admin,
joined
))

Expand Down Expand Up @@ -120,6 +125,8 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto]) =
contactDetails.icon,
contactDetails.details.identicon,
contactDetails.isidenticon,
self.controller.getEmojiHash(m.`from`),
self.controller.getColorHash(m.`from`),
contactDetails.details.added,
))

Expand Down Expand Up @@ -173,8 +180,10 @@ method onChatMembersAdded*(self: Module, ids: seq[string]) =
contactDetails.icon,
contactDetails.details.identicon,
contactDetails.isidenticon,
self.controller.getEmojiHash(id),
self.controller.getColorHash(id),
contactDetails.details.added,
admin,
admin,
joined
))

Expand Down
40 changes: 23 additions & 17 deletions src/app/modules/main/chat_section/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ../../../../app_service/service/community/service as community_service
import ../../../../app_service/service/message/service as message_service
import ../../../../app_service/service/mailservers/service as mailservers_service
import ../../../../app_service/service/gif/service as gif_service
import ../../../../app_service/service/visual_identity/service as visual_identity_service

export io_interface

Expand Down Expand Up @@ -85,10 +86,11 @@ proc addSubmodule(self: Module, chatId: string, belongToCommunity: bool, isUsers
communityService: community_service.Service,
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service) =
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service) =
self.chatContentModules[chatId] = chat_content_module.newModule(self, events, self.controller.getMySectionId(), chatId,
belongToCommunity, isUsersListAvailable, settingsService, contactService, chatService, communityService,
messageService, gifService, mailserversService)
messageService, gifService, mailserversService, visualIdentityService)

proc removeSubmodule(self: Module, chatId: string) =
if(not self.chatContentModules.contains(chatId)):
Expand All @@ -102,7 +104,8 @@ proc buildChatUI(self: Module, events: EventEmitter,
communityService: community_service.Service,
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service) =
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service) =
let types = @[ChatType.OneToOne, ChatType.Public, ChatType.PrivateGroupChat]
let chats = self.controller.getChatDetailsForChatTypes(types)

Expand Down Expand Up @@ -130,7 +133,7 @@ proc buildChatUI(self: Module, events: EventEmitter,
active=false, c.position, c.categoryId)
self.view.chatsModel().appendItem(item)
self.addSubmodule(c.id, false, isUsersListAvailable, events, settingsService, contactService, chatService,
communityService, messageService, gifService, mailserversService)
communityService, messageService, gifService, mailserversService, visualIdentityService)

# make the first Public chat active when load the app
if(selectedItemId.len == 0 and c.chatType == ChatType.Public):
Expand All @@ -145,7 +148,8 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
communityService: community_service.Service,
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service) =
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service) =
var selectedItemId = ""
var selectedSubItemId = ""
let communities = self.controller.getJoinedCommunities()
Expand All @@ -166,7 +170,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
notificationsCount, chatDto.muted, blocked=false, active = false, c.position, c.categoryId)
self.view.chatsModel().appendItem(channelItem)
self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService,
messageService, gifService, mailserversService)
messageService, gifService, mailserversService, visualIdentityService)

# make the first channel which doesn't belong to any category active when load the app
if(selectedItemId.len == 0):
Expand Down Expand Up @@ -197,7 +201,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
active=false, c.position)
categoryChannels.add(channelItem)
self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService,
messageService, gifService, mailserversService)
messageService, gifService, mailserversService, visualIdentityService)

# in case there is no channels beyond categories,
# make the first channel of the first category active when load the app
Expand Down Expand Up @@ -262,14 +266,15 @@ method load*(self: Module, events: EventEmitter,
communityService: community_service.Service,
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service) =
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service) =
self.controller.init()
self.view.load()

if(self.controller.isCommunity()):
self.buildCommunityUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService)
self.buildCommunityUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService)
else:
self.buildChatUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService)
self.buildChatUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService)
self.initContactRequestsModel() # we do this only in case of chat section (not in case of communities)

for cModule in self.chatContentModules.values:
Expand Down Expand Up @@ -400,6 +405,7 @@ method addNewChat*(
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service,
setChatAsActive: bool = true) =
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
let notificationsCount = chatDto.unviewedMentionsCount
Expand All @@ -421,7 +427,7 @@ method addNewChat*(
chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount,
chatDto.muted, blocked=false, active=false, position = 0, chatDto.categoryId, chatDto.highlight)
self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService,
communityService, messageService, gifService, mailserversService)
communityService, messageService, gifService, mailserversService, visualIdentityService)
self.chatContentModules[chatDto.id].load()
self.view.chatsModel().appendItem(item)
if setChatAsActive:
Expand All @@ -437,7 +443,7 @@ method addNewChat*(
amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, blocked=false, active=false,
chatDto.position)
self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService,
communityService, messageService, gifService, mailserversService)
communityService, messageService, gifService, mailserversService, visualIdentityService)
self.chatContentModules[chatDto.id].load()
categoryItem.appendSubItem(channelItem)
if setChatAsActive:
Expand Down Expand Up @@ -638,8 +644,8 @@ method onContactDetailsUpdated*(self: Module, publicKey: string) =
let item = self.createItemFromPublicKey(publicKey)
self.view.contactRequestsModel().addItem(item)
self.updateParentBadgeNotifications()
singletonInstance.globalEvents.showNewContactRequestNotification("New Contact Request",
fmt "{contactDetails.displayName} added you as contact", conf.CHAT_SECTION_ID)
singletonInstance.globalEvents.showNewContactRequestNotification("New Contact Request",
fmt "{contactDetails.displayName} added you as contact", conf.CHAT_SECTION_ID)

let chatName = contactDetails.displayName
let chatImage = contactDetails.icon
Expand All @@ -659,10 +665,10 @@ method onNewMessagesReceived*(self: Module, chatId: string, unviewedMessagesCoun
let renderedMessageText = self.controller.getRenderedText(m.parsedText)
let plainText = singletonInstance.utils.plainText(renderedMessageText)
if(m.isUserWithPkMentioned(myPK)):
singletonInstance.globalEvents.showMentionMessageNotification(contactDetails.displayName, plainText,
singletonInstance.globalEvents.showMentionMessageNotification(contactDetails.displayName, plainText,
self.controller.getMySectionId(), chatId, m.id)
else:
singletonInstance.globalEvents.showNormalMessageNotification(contactDetails.displayName, plainText,
singletonInstance.globalEvents.showNormalMessageNotification(contactDetails.displayName, plainText,
self.controller.getMySectionId(), chatId, m.id)

method addGroupMembers*(self: Module, communityID: string, chatId: string, pubKeys: string) =
Expand Down Expand Up @@ -757,7 +763,7 @@ method reorderCommunityCategories*(self: Module, categoryId: string, position: i

method reorderCommunityChat*(self: Module, categoryId: string, chatId: string, position: int): string =
self.controller.reorderCommunityChat(categoryId, chatId, position)

method setLoadingHistoryMessagesInProgress*(self: Module, isLoading: bool) =
self.view.setLoadingHistoryMessagesInProgress(isLoading)

Expand Down
Loading