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
10 changes: 2 additions & 8 deletions src/app/boot/app_controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ 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 @@ -84,7 +83,6 @@ 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 @@ -181,7 +179,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
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 @@ -222,7 +219,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.gifService,
result.ensService,
result.networkService,
result.visualIdentityService
)

# Do connections
Expand Down Expand Up @@ -271,7 +267,6 @@ 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 @@ -320,14 +315,14 @@ proc load(self: AppController) =
self.gifService.init()

singletonInstance.engine.setRootContextProperty("globalUtils", self.globalUtilsVariant)

let pubKey = self.settingsService.getPublicKey()
singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)

self.buildAndRegisterLocalAccountSensitiveSettings()
self.buildAndRegisterUserProfile()

self.networkService.init()
self.tokenService.init()
self.walletAccountService.init()
Expand All @@ -342,7 +337,6 @@ proc load(self: AppController) =
self.messageService,
self.gifService,
self.mailserversService,
self.visualIdentityService,
)

proc userLoggedIn*(self: AppController) =
Expand Down
7 changes: 7 additions & 0 deletions src/app/global/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ./utils/qrcodegen
# Services as instances shouldn't be used in this class, just some general/global procs
import ../../app_service/common/conversion
import ../../app_service/service/accounts/service as procs_from_accounts
import ../../app_service/service/visual_identity/service as procs_from_visual_identity_service


QtObject:
Expand Down Expand Up @@ -128,3 +129,9 @@ QtObject:

proc plainText*(self: Utils, text: string): string {.slot.} =
result = plain_text(text)

proc getEmojiHashAsJson*(self: Utils, publicKey: string): string {.slot.} =
procs_from_visual_identity_service.getEmojiHashAsJson(publicKey)

proc getColorHashAsJson*(self: Utils, publicKey: string): string {.slot.} =
procs_from_visual_identity_service.getColorHashAsJson(publicKey)
5 changes: 2 additions & 3 deletions src/app/modules/main/chat_section/chat_content/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ 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 @@ -42,7 +41,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, visualIdentityService: visual_identity_service.Service):
mailserversService: mailservers_service.Service):
Module =
result = Module()
result.delegate = delegate
Expand All @@ -57,7 +56,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, visualIdentityService
contactService, chat_service, communityService, messageService
)

method delete*(self: Module) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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,13 +23,12 @@ 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, visualIdentityService: visual_identity_service.Service
messageService: message_service.Service
): Controller =
result = Controller()
result.delegate = delegate
Expand All @@ -44,7 +42,6 @@ proc newController*(
result.communityService = communityService
result.messageService = messageService
result.chatService = chatService
result.visualIdentityService = visualIdentityService

method delete*(self: Controller) =
discard
Expand Down Expand Up @@ -155,9 +152,3 @@ 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,6 +1,5 @@
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 @@ -33,9 +32,3 @@ 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")
13 changes: 2 additions & 11 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,7 +9,6 @@ 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 @@ -25,15 +24,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, visualIdentityService: visual_identity_service.Service
messageService: message_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, visualIdentityService
contactService, chatService, communityService, messageService,
)
result.moduleLoaded = false

Expand Down Expand Up @@ -63,8 +62,6 @@ 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 @@ -90,8 +87,6 @@ method viewDidLoad*(self: Module) =
contactDetails.icon,
contactDetails.details.identicon,
contactDetails.isidenticon,
self.controller.getEmojiHash(publicKey),
self.controller.getColorHash(publicKey),
contactDetails.details.added,
admin,
joined
Expand Down Expand Up @@ -125,8 +120,6 @@ 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 @@ -180,8 +173,6 @@ 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,
joined
Expand Down
32 changes: 13 additions & 19 deletions src/app/modules/main/chat_section/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ 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 @@ -86,11 +85,10 @@ 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,
visualIdentityService: visual_identity_service.Service) =
mailserversService: mailservers_service.Service) =
self.chatContentModules[chatId] = chat_content_module.newModule(self, events, self.controller.getMySectionId(), chatId,
belongToCommunity, isUsersListAvailable, settingsService, contactService, chatService, communityService,
messageService, gifService, mailserversService, visualIdentityService)
messageService, gifService, mailserversService)

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

Expand Down Expand Up @@ -133,7 +130,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, visualIdentityService)
communityService, messageService, gifService, mailserversService)

# make the first Public chat active when load the app
if(selectedItemId.len == 0 and c.chatType == ChatType.Public):
Expand All @@ -148,8 +145,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
communityService: community_service.Service,
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service) =
mailserversService: mailservers_service.Service) =
var selectedItemId = ""
var selectedSubItemId = ""
let communities = self.controller.getJoinedCommunities()
Expand All @@ -170,7 +166,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, visualIdentityService)
messageService, gifService, mailserversService)

# make the first channel which doesn't belong to any category active when load the app
if(selectedItemId.len == 0):
Expand Down Expand Up @@ -201,7 +197,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, visualIdentityService)
messageService, gifService, mailserversService)

# 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 @@ -266,15 +262,14 @@ method load*(self: Module, events: EventEmitter,
communityService: community_service.Service,
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service) =
mailserversService: mailservers_service.Service) =
self.controller.init()
self.view.load()

if(self.controller.isCommunity()):
self.buildCommunityUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService)
self.buildCommunityUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService)
else:
self.buildChatUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService)
self.buildChatUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService)
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 @@ -405,7 +400,6 @@ 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 @@ -427,7 +421,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, visualIdentityService)
communityService, messageService, gifService, mailserversService)
self.chatContentModules[chatDto.id].load()
self.view.chatsModel().appendItem(item)
if setChatAsActive:
Expand All @@ -443,7 +437,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, visualIdentityService)
communityService, messageService, gifService, mailserversService)
self.chatContentModules[chatDto.id].load()
categoryItem.appendSubItem(channelItem)
if setChatAsActive:
Expand Down Expand Up @@ -558,7 +552,7 @@ method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
method onCommunityChannelEdited*(self: Module, chat: ChatDto) =
if(not self.chatContentModules.contains(chat.id)):
return
self.view.chatsModel().updateItemDetails(chat.id, chat.name, chat.description, chat.emoji,
self.view.chatsModel().updateItemDetails(chat.id, chat.name, chat.description, chat.emoji,
chat.color)

method createOneToOneChat*(self: Module, communityID: string, chatId: string, ensName: string) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ../../../../../app_service/service/community/service as community_service
import ../../../../../app_service/service/message/service as message_service
import ../../../../../app_service/service/gif/service as gif_service
import ../../../../../app_service/service/mailservers/service as mailservers_service
import ../../../../../app_service/service/visual_identity/service as visual_identity_service

import ../model as chats_model

Expand All @@ -23,8 +22,7 @@ method load*(self: AccessInterface, events: EventEmitter,
communityService: community_service.Service,
messageService: message_service.Service,
gifService: gif_service.Service,
mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service) {.base.} =
mailserversService: mailservers_service.Service) {.base.} =
raise newException(ValueError, "No implementation available")

method isLoaded*(self: AccessInterface): bool {.base.} =
Expand Down
Loading