fix(@desktop): make get(Emoji/Color)Hash global utility
Removed instances of VisualIdentityService as it was stateless. Removed (emoji/color)Hash models as they were reduntant, hashes are obtained only from global utility now.
This commit is contained in:
parent
7994faf756
commit
e244260c81
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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](
|
||||
|
@ -222,7 +219,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
|||
result.gifService,
|
||||
result.ensService,
|
||||
result.networkService,
|
||||
result.visualIdentityService
|
||||
)
|
||||
|
||||
# Do connections
|
||||
|
@ -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)
|
||||
|
@ -342,7 +337,6 @@ proc load(self: AppController) =
|
|||
self.messageService,
|
||||
self.gifService,
|
||||
self.mailserversService,
|
||||
self.visualIdentityService,
|
||||
)
|
||||
|
||||
proc userLoggedIn*(self: AppController) =
|
||||
|
|
|
@ -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:
|
||||
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) =
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -44,7 +42,6 @@ proc newController*(
|
|||
result.communityService = communityService
|
||||
result.messageService = messageService
|
||||
result.chatService = chatService
|
||||
result.visualIdentityService = visualIdentityService
|
||||
|
||||
method delete*(self: Controller) =
|
||||
discard
|
||||
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -25,7 +24,7 @@ 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
|
||||
|
@ -33,7 +32,7 @@ proc newModule*(
|
|||
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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
))
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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)):
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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.} =
|
||||
|
|
|
@ -6,7 +6,6 @@ import ../../../core/signals/types
|
|||
import ../../../core/eventemitter
|
||||
import ../../../../app_service/service/community/service as community_service
|
||||
import ../../../../app_service/service/contacts/service as contacts_service
|
||||
import ../../../../app_service/service/visual_identity/service as visual_identity_service
|
||||
|
||||
export controller_interface
|
||||
|
||||
|
@ -16,21 +15,18 @@ type
|
|||
events: EventEmitter
|
||||
communityService: community_service.Service
|
||||
contactsService: contacts_service.Service
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
|
||||
proc newController*(
|
||||
delegate: io_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
communityService: community_service.Service,
|
||||
contactsService: contacts_service.Service,
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
): Controller =
|
||||
result = Controller()
|
||||
result.delegate = delegate
|
||||
result.events = events
|
||||
result.communityService = communityService
|
||||
result.contactsService = contactsService
|
||||
result.visualIdentityService = visualIdentityService
|
||||
|
||||
method delete*(self: Controller) =
|
||||
discard
|
||||
|
@ -138,9 +134,3 @@ method userCanJoin*(self: Controller, communityId: string): bool =
|
|||
|
||||
method isCommunityRequestPending*(self: Controller, communityId: string): bool =
|
||||
return self.communityService.isCommunityRequestPending(communityId)
|
||||
|
||||
method getEmojiHash*(self: Controller, pubkey: string): EmojiHashDto =
|
||||
return self.visualIdentityService.emojiHashOf(pubkey)
|
||||
|
||||
method getColorHash*(self: Controller, pubkey: string): ColorHashDto =
|
||||
return self.visualIdentityService.colorHashOf(pubkey)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import ../../../../app_service/service/community/service as community_service
|
||||
import ../../../../app_service/service/contacts/service as contacts_service
|
||||
import ../../../../app_service/service/visual_identity/service as visual_identity_service
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
|
@ -64,12 +63,6 @@ method getContactNameAndImage*(self: AccessInterface, contactId: string):
|
|||
method getContactDetails*(self: AccessInterface, contactId: string): ContactDetails {.base.} =
|
||||
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")
|
||||
|
||||
type
|
||||
## Abstract class (concept) which must be implemented by object/s used in this
|
||||
## module.
|
||||
|
|
|
@ -9,7 +9,6 @@ import ../../../global/global_singleton
|
|||
import ../../../core/eventemitter
|
||||
import ../../../../app_service/service/community/service as community_service
|
||||
import ../../../../app_service/service/contacts/service as contacts_service
|
||||
import ../../../../app_service/service/visual_identity/service as visual_identity_service
|
||||
|
||||
export io_interface
|
||||
|
||||
|
@ -34,9 +33,7 @@ proc newModule*(
|
|||
delegate: delegate_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
communityService: community_service.Service,
|
||||
contactsService: contacts_service.Service,
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
): Module =
|
||||
contactsService: contacts_service.Service): Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
result.view = newView(result)
|
||||
|
@ -46,7 +43,6 @@ proc newModule*(
|
|||
events,
|
||||
communityService,
|
||||
contactsService,
|
||||
visualIdentityService
|
||||
)
|
||||
result.moduleLoaded = false
|
||||
|
||||
|
@ -103,8 +99,6 @@ method getCommunityItem(self: Module, c: CommunityDto): SectionItem =
|
|||
contactDetails.icon,
|
||||
contactDetails.details.identicon,
|
||||
contactDetails.isidenticon,
|
||||
self.controller.getEmojiHash(member.id),
|
||||
self.controller.getColorHash(member.id),
|
||||
contactDetails.details.added,
|
||||
))
|
||||
)
|
||||
|
|
|
@ -16,7 +16,6 @@ import ../../../app_service/service/gif/service as gif_service
|
|||
import ../../../app_service/service/mailservers/service as mailservers_service
|
||||
import ../../../app_service/service/privacy/service as privacy_service
|
||||
import ../../../app_service/service/node/service as node_service
|
||||
import ../../../app_service/service/visual_identity/service as visual_identity_service
|
||||
|
||||
export controller_interface
|
||||
|
||||
|
@ -38,7 +37,6 @@ type
|
|||
privacyService: privacy_service.Service
|
||||
mailserversService: mailservers_service.Service
|
||||
nodeService: node_service.Service
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
activeSectionId: string
|
||||
|
||||
proc newController*(delegate: io_interface.AccessInterface,
|
||||
|
@ -54,7 +52,6 @@ proc newController*(delegate: io_interface.AccessInterface,
|
|||
privacyService: privacy_service.Service,
|
||||
mailserversService: mailservers_service.Service,
|
||||
nodeService: node_service.Service,
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
):
|
||||
Controller =
|
||||
result = Controller()
|
||||
|
@ -70,7 +67,6 @@ proc newController*(delegate: io_interface.AccessInterface,
|
|||
result.gifService = gifService
|
||||
result.privacyService = privacyService
|
||||
result.nodeService = nodeService
|
||||
result.visualIdentityService = visualIdentityService
|
||||
|
||||
method delete*(self: Controller) =
|
||||
discard
|
||||
|
@ -108,7 +104,6 @@ method init*(self: Controller) =
|
|||
self.messageService,
|
||||
self.gifService,
|
||||
self.mailserversService,
|
||||
self.visualIdentityService
|
||||
)
|
||||
|
||||
self.events.on(TOGGLE_SECTION) do(e:Args):
|
||||
|
@ -127,7 +122,6 @@ method init*(self: Controller) =
|
|||
self.messageService,
|
||||
self.gifService,
|
||||
self.mailserversService,
|
||||
self.visualIdentityService
|
||||
)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args):
|
||||
|
@ -144,7 +138,6 @@ method init*(self: Controller) =
|
|||
self.messageService,
|
||||
self.gifService,
|
||||
self.mailserversService,
|
||||
self.visualIdentityService
|
||||
)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_LEFT) do(e:Args):
|
||||
|
@ -293,9 +286,3 @@ method switchTo*(self: Controller, sectionId, chatId, messageId: string) =
|
|||
|
||||
method getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
||||
return self.communityService.getCommunityById(communityId)
|
||||
|
||||
method getEmojiHash*(self: Controller, pubkey: string): EmojiHashDto =
|
||||
return self.visualIdentityService.emojiHashOf(pubkey)
|
||||
|
||||
method getColorHash*(self: Controller, pubkey: string): ColorHashDto =
|
||||
return self.visualIdentityService.colorHashOf(pubkey)
|
||||
|
|
|
@ -2,7 +2,6 @@ import ../shared_models/section_item
|
|||
import ../../../app_service/service/contacts/dto/contact_details as contact_details
|
||||
import ../../../app_service/service/contacts/dto/contacts as contacts_dto
|
||||
import ../../../app_service/service/community/service as community_service
|
||||
import ../../../app_service/service/visual_identity/service as visual_identity_service
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
|
@ -66,9 +65,3 @@ method getCommunityById*(self: AccessInterface, communityId: string): CommunityD
|
|||
|
||||
method isConnected*(self: AccessInterface): bool {.base.} =
|
||||
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")
|
||||
|
|
|
@ -49,7 +49,6 @@ 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/network/service as network_service
|
||||
import ../../../app_service/service/visual_identity/service as visual_identity_service
|
||||
|
||||
import ../../core/notifications/details
|
||||
import ../../core/eventemitter
|
||||
|
@ -109,7 +108,6 @@ proc newModule*[T](
|
|||
gifService: gif_service.Service,
|
||||
ensService: ens_service.Service,
|
||||
networkService: network_service.Service,
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
): Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
|
@ -129,7 +127,6 @@ proc newModule*[T](
|
|||
privacyService,
|
||||
mailserversService,
|
||||
nodeService,
|
||||
visualIdentityService
|
||||
)
|
||||
result.moduleLoaded = false
|
||||
|
||||
|
@ -152,7 +149,7 @@ proc newModule*[T](
|
|||
result.stickersModule = stickers_module.newModule(result, events, stickersService, settingsService, walletAccountService)
|
||||
result.activityCenterModule = activity_center_module.newModule(result, events, activityCenterService, contactsService,
|
||||
messageService, chatService)
|
||||
result.communitiesModule = communities_module.newModule(result, events, communityService, contactsService, visualIdentityService)
|
||||
result.communitiesModule = communities_module.newModule(result, events, communityService, contactsService)
|
||||
result.appSearchModule = app_search_module.newModule(result, events, contactsService, chatService, communityService,
|
||||
messageService)
|
||||
result.nodeSectionModule = node_section_module.newModule(result, events, settingsService, nodeService, nodeConfigurationService)
|
||||
|
@ -213,8 +210,6 @@ proc createCommunityItem[T](self: Module[T], c: CommunityDto): SectionItem =
|
|||
contactDetails.icon,
|
||||
contactDetails.details.identicon,
|
||||
contactDetails.isidenticon,
|
||||
self.controller.getEmojiHash(member.id),
|
||||
self.controller.getColorHash(member.id),
|
||||
contactDetails.details.added
|
||||
)),
|
||||
c.pendingRequestsToJoin.map(x => pending_request_item.initItem(
|
||||
|
@ -237,7 +232,6 @@ method load*[T](
|
|||
messageService: message_service.Service,
|
||||
gifService: gif_service.Service,
|
||||
mailserversService: mailservers_service.Service,
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
) =
|
||||
singletonInstance.engine.setRootContextProperty("mainModule", self.viewVariant)
|
||||
self.controller.init()
|
||||
|
@ -353,9 +347,9 @@ method load*[T](
|
|||
activeSection = profileSettingsSectionItem
|
||||
|
||||
# Load all sections
|
||||
self.chatSectionModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService)
|
||||
self.chatSectionModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService)
|
||||
for cModule in self.communitySectionsModule.values:
|
||||
cModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService)
|
||||
cModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService)
|
||||
|
||||
self.browserSectionModule.load()
|
||||
# self.nodeManagementSectionModule.load()
|
||||
|
@ -582,7 +576,6 @@ method communityJoined*[T](
|
|||
messageService: message_service.Service,
|
||||
gifService: gif_service.Service,
|
||||
mailserversService: mailservers_service.Service,
|
||||
visualIdentityService: visual_identity_service.Service
|
||||
) =
|
||||
var firstCommunityJoined = false
|
||||
if (self.communitySectionsModule.len == 0):
|
||||
|
@ -600,7 +593,7 @@ method communityJoined*[T](
|
|||
gifService,
|
||||
mailserversService
|
||||
)
|
||||
self.communitySectionsModule[community.id].load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService)
|
||||
self.communitySectionsModule[community.id].load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService)
|
||||
|
||||
let communitySectionItem = self.createCommunityItem(community)
|
||||
if (firstCommunityJoined):
|
||||
|
@ -653,17 +646,6 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string): string =
|
|||
}
|
||||
return $jsonObj
|
||||
|
||||
method getEmojiHashAsJson*[T](self: Module[T], publicKey: string): string =
|
||||
let emojiHash = self.controller.getEmojiHash(publicKey)
|
||||
return $$emojiHash
|
||||
|
||||
method getColorHashAsJson*[T](self: Module[T], publicKey: string): string =
|
||||
let colorHash = self.controller.getColorHash(publicKey)
|
||||
let json = newJArray()
|
||||
for segment in colorHash:
|
||||
json.add(%* {"segmentLength": segment.len, "colorId": segment.colorIdx})
|
||||
return $json
|
||||
|
||||
method resolveENS*[T](self: Module[T], ensName: string, uuid: string) =
|
||||
if ensName.len == 0:
|
||||
error "error: cannot do a lookup for empty ens name"
|
||||
|
|
|
@ -5,7 +5,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 ../../../core/eventemitter
|
||||
|
||||
|
@ -21,9 +20,7 @@ method load*(
|
|||
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)
|
||||
{.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ method communityJoined*(self: AccessInterface, community: CommunityDto, events:
|
|||
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 communityEdited*(self: AccessInterface, community: CommunityDto) {.base.} =
|
||||
|
|
|
@ -26,12 +26,6 @@ method getAppSearchModule*(self: AccessInterface): QVariant {.base.} =
|
|||
method getContactDetailsAsJson*(self: AccessInterface, publicKey: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getEmojiHashAsJson*(self: AccessInterface, publicKey: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getColorHashAsJson*(self: AccessInterface, publicKey: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method resolveENS*(self: AccessInterface, ensName: string, uuid: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -151,14 +151,6 @@ QtObject:
|
|||
proc getContactDetailsAsJson(self: View, publicKey: string): string {.slot.} =
|
||||
return self.delegate.getContactDetailsAsJson(publicKey)
|
||||
|
||||
# serialized return - nimqml does not allow QVariant return type in slots
|
||||
proc getEmojiHashAsJson(self: View, publicKey: string): string {.slot.} =
|
||||
return self.delegate.getEmojiHashAsJson(publicKey)
|
||||
|
||||
# serialized return - nimqml does not allow QVariant return type in slots
|
||||
proc getColorHashAsJson(self: View, publicKey: string): string {.slot.} =
|
||||
return self.delegate.getColorHashAsJson(publicKey)
|
||||
|
||||
proc resolveENS*(self: View, ensName: string, uuid: string) {.slot.} =
|
||||
self.delegate.resolveENS(ensName, uuid)
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
import strformat
|
||||
|
||||
type
|
||||
Item* = ref object
|
||||
length: int
|
||||
colorIdx: int
|
||||
|
||||
proc initItem*(length: int, colorIdx: int): Item =
|
||||
result = Item()
|
||||
result.length = length
|
||||
result.colorIdx = colorIdx
|
||||
|
||||
proc `$`*(self: Item): string =
|
||||
result = fmt"""ColorHashItem(
|
||||
length: {$self.length},
|
||||
colorIdx: {$self.colorIdx},
|
||||
]"""
|
||||
|
||||
proc length*(self: Item): int {.inline.} =
|
||||
self.length
|
||||
|
||||
proc colorIdx*(self: Item): int {.inline.} =
|
||||
self.colorIdx
|
|
@ -1,53 +0,0 @@
|
|||
import NimQml, Tables
|
||||
|
||||
import color_hash_item
|
||||
|
||||
type
|
||||
ModelRole {.pure.} = enum
|
||||
Length = UserRole + 1
|
||||
ColorIdx
|
||||
|
||||
QtObject:
|
||||
type
|
||||
Model* = ref object of QAbstractListModel
|
||||
items*: seq[Item]
|
||||
|
||||
proc delete(self: Model) =
|
||||
self.items = @[]
|
||||
self.QAbstractListModel.delete
|
||||
|
||||
proc setup(self: Model) =
|
||||
self.QAbstractListModel.setup
|
||||
|
||||
proc newModel*(): Model =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
|
||||
proc setItems*(self: Model, items: seq[Item]) =
|
||||
self.beginResetModel()
|
||||
self.items = items
|
||||
self.endResetModel()
|
||||
|
||||
method rowCount(self: Model, index: QModelIndex = nil): int =
|
||||
return self.items.len
|
||||
|
||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||
if not index.isValid:
|
||||
return
|
||||
if index.row < 0 or index.row >= self.items.len:
|
||||
return
|
||||
|
||||
let item = self.items[index.row]
|
||||
let enumRole = role.ModelRole
|
||||
|
||||
case enumRole:
|
||||
of ModelRole.Length:
|
||||
result = newQVariant(item.length)
|
||||
of ModelRole.ColorIdx:
|
||||
result = newQVariant(item.colorIdx)
|
||||
|
||||
method roleNames(self: Model): Table[int, string] =
|
||||
{
|
||||
ModelRole.Length.int:"length",
|
||||
ModelRole.ColorIdx.int:"colorIdx",
|
||||
}.toTable
|
|
@ -1,42 +0,0 @@
|
|||
import NimQml, Tables
|
||||
|
||||
type
|
||||
RoleNames {.pure.} = enum
|
||||
Emoji = UserRole + 1,
|
||||
|
||||
QtObject:
|
||||
type
|
||||
Model* = ref object of QAbstractListModel
|
||||
items*: seq[string]
|
||||
|
||||
proc delete(self: Model) =
|
||||
self.items = @[]
|
||||
self.QAbstractListModel.delete
|
||||
|
||||
proc setup(self: Model) =
|
||||
self.QAbstractListModel.setup
|
||||
|
||||
proc newModel*(): Model =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
|
||||
proc setItems*(self: Model, items: seq[string]) =
|
||||
self.beginResetModel()
|
||||
self.items = items
|
||||
self.endResetModel()
|
||||
|
||||
proc items*(self: Model): seq[string] =
|
||||
return self.items
|
||||
|
||||
method rowCount(self: Model, index: QModelIndex = nil): int =
|
||||
return self.items.len
|
||||
|
||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||
if not index.isValid:
|
||||
return
|
||||
if index.row < 0 or index.row >= self.items.len:
|
||||
return
|
||||
return newQVariant(self.items[index.row])
|
||||
|
||||
method roleNames(self: Model): Table[int, string] =
|
||||
{ RoleNames.Emoji.int:"emoji" }.toTable
|
|
@ -1,7 +1,5 @@
|
|||
import strformat, sequtils, sugar
|
||||
|
||||
import ./emojis_model, ./color_hash_model, ./color_hash_item
|
||||
|
||||
type
|
||||
OnlineStatus* {.pure.} = enum
|
||||
Offline = 0
|
||||
|
@ -10,9 +8,6 @@ type
|
|||
Idle
|
||||
Invisible
|
||||
|
||||
type
|
||||
ColorHashSegment* = tuple[len, colorIdx: int]
|
||||
|
||||
# TODO add role when it is needed
|
||||
type
|
||||
Item* = ref object
|
||||
|
@ -25,8 +20,6 @@ type
|
|||
icon: string
|
||||
identicon: string
|
||||
isIdenticon: bool
|
||||
emojiHashModel: emojis_model.Model
|
||||
colorHashModel: color_hash_model.Model
|
||||
isAdded: bool
|
||||
isAdmin: bool
|
||||
joined: bool
|
||||
|
@ -41,8 +34,6 @@ proc initItem*(
|
|||
icon: string,
|
||||
identicon: string,
|
||||
isidenticon: bool,
|
||||
emojiHash: seq[string],
|
||||
colorHash: seq[ColorHashSegment],
|
||||
isAdded: bool = false,
|
||||
isAdmin: bool = false,
|
||||
joined: bool = false,
|
||||
|
@ -57,10 +48,6 @@ proc initItem*(
|
|||
result.icon = icon
|
||||
result.identicon = identicon
|
||||
result.isIdenticon = isidenticon
|
||||
result.emojiHashModel = emojis_model.newModel()
|
||||
result.emojiHashModel.setItems(emojiHash)
|
||||
result.colorHashModel = color_hash_model.newModel()
|
||||
result.colorHashModel.setItems(map(colorHash, x => color_hash_item.initItem(x.len, x.colorIdx)))
|
||||
result.isAdded = isAdded
|
||||
result.isAdmin = isAdmin
|
||||
result.joined = joined
|
||||
|
@ -145,9 +132,3 @@ proc joined*(self: Item): bool {.inline.} =
|
|||
|
||||
proc `joined=`*(self: Item, value: bool) {.inline.} =
|
||||
self.joined = value
|
||||
|
||||
proc emojiHashModel*(self: Item): emojis_model.Model {.inline.} =
|
||||
self.emojiHashModel
|
||||
|
||||
proc colorHashModel*(self: Item): color_hash_model.Model {.inline.} =
|
||||
self.colorHashModel
|
||||
|
|
|
@ -13,8 +13,6 @@ type
|
|||
Icon
|
||||
Identicon
|
||||
IsIdenticon
|
||||
EmojiHashModel
|
||||
ColorHashModel
|
||||
IsAdded
|
||||
IsAdmin
|
||||
Joined
|
||||
|
@ -68,8 +66,6 @@ QtObject:
|
|||
ModelRole.Icon.int:"icon",
|
||||
ModelRole.Identicon.int:"identicon",
|
||||
ModelRole.IsIdenticon.int:"isIdenticon",
|
||||
ModelRole.EmojiHashModel.int:"emojiHashModel",
|
||||
ModelRole.ColorHashModel.int:"colorHashModel",
|
||||
ModelRole.IsAdded.int:"isAdded",
|
||||
ModelRole.IsAdmin.int:"isAdmin",
|
||||
ModelRole.Joined.int:"joined",
|
||||
|
@ -104,10 +100,6 @@ QtObject:
|
|||
result = newQVariant(item.identicon)
|
||||
of ModelRole.IsIdenticon:
|
||||
result = newQVariant(item.isIdenticon)
|
||||
of ModelRole.EmojiHashModel:
|
||||
result = newQVariant(item.emojiHashModel)
|
||||
of ModelRole.ColorHashModel:
|
||||
result = newQVariant(item.colorHashModel)
|
||||
of ModelRole.IsAdded:
|
||||
result = newQVariant(item.isAdded)
|
||||
of ModelRole.IsAdmin:
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
import chronicles
|
||||
import chronicles, marshal, json
|
||||
|
||||
import ./dto as dto
|
||||
import ./service_interface
|
||||
import ../../../backend/visual_identity as status_visual_identity
|
||||
|
||||
export dto
|
||||
|
||||
type
|
||||
Service* = ref object of service_interface.ServiceInterface
|
||||
|
||||
proc newService*(): Service =
|
||||
result = Service()
|
||||
|
||||
method delete*(self: Service) =
|
||||
discard
|
||||
|
||||
proc emojiHashOf*(self: Service, pubkey: string): EmojiHashDto =
|
||||
proc emojiHashOf*(pubkey: string): EmojiHashDto =
|
||||
try:
|
||||
let response = status_visual_identity.emojiHashOf(pubkey)
|
||||
|
||||
|
@ -28,7 +18,7 @@ proc emojiHashOf*(self: Service, pubkey: string): EmojiHashDto =
|
|||
error "error: ", methodName = "emojiHashOf", errName = e.name,
|
||||
errDesription = e.msg
|
||||
|
||||
proc colorHashOf*(self: Service, pubkey: string): ColorHashDto =
|
||||
proc colorHashOf*(pubkey: string): ColorHashDto =
|
||||
try:
|
||||
let response = status_visual_identity.colorHashOf(pubkey)
|
||||
|
||||
|
@ -40,3 +30,13 @@ proc colorHashOf*(self: Service, pubkey: string): ColorHashDto =
|
|||
except Exception as e:
|
||||
error "error: ", methodName = "colorHashOf", errName = e.name,
|
||||
errDesription = e.msg
|
||||
|
||||
proc getEmojiHashAsJson*(publicKey: string): string =
|
||||
return $$emojiHashOf(publicKey)
|
||||
|
||||
proc getColorHashAsJson*(publicKey: string): string =
|
||||
let colorHash = colorHashOf(publicKey)
|
||||
let json = newJArray()
|
||||
for segment in colorHash:
|
||||
json.add(%* {"segmentLength": segment.len, "colorId": segment.colorIdx})
|
||||
return $json
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
import ./dto as dto
|
||||
export dto
|
||||
|
||||
type
|
||||
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for this service access.
|
||||
|
||||
method delete*(self: ServiceInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method emojiHashOf*(self: ServiceInterface, pubkey: string): EmojiHashDto {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method colorHashOf*(self: ServiceInterface, pubkey: string): ColorHashDto {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -608,7 +608,7 @@ QtObject {
|
|||
if (publicKey === "") {
|
||||
return ""
|
||||
}
|
||||
let jsonObj = mainModule.getEmojiHashAsJson(publicKey)
|
||||
let jsonObj = globalUtils.getEmojiHashAsJson(publicKey)
|
||||
return JSON.parse(jsonObj)
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ QtObject {
|
|||
if (publicKey === "") {
|
||||
return ""
|
||||
}
|
||||
let jsonObj = mainModule.getColorHashAsJson(publicKey)
|
||||
let jsonObj = globalUtils.getColorHashAsJson(publicKey)
|
||||
return JSON.parse(jsonObj)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue