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:
Patryk Osmaczko 2022-03-17 11:28:38 +01:00 committed by osmaczko
parent 7994faf756
commit e244260c81
26 changed files with 50 additions and 322 deletions

View File

@ -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/mailservers/service as mailservers_service
import ../../app_service/service/gif/service as gif_service import ../../app_service/service/gif/service as gif_service
import ../../app_service/service/ens/service as ens_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/startup/module as startup_module
import ../modules/main/module as main_module import ../modules/main/module as main_module
@ -84,7 +83,6 @@ type
nodeService: node_service.Service nodeService: node_service.Service
gifService: gif_service.Service gifService: gif_service.Service
ensService: ens_service.Service ensService: ens_service.Service
visualIdentityService: visual_identity_service.Service
# Modules # Modules
startupModule: startup_module.AccessInterface startupModule: startup_module.AccessInterface
@ -181,7 +179,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.settingsService, result.walletAccountService, result.transactionService, result.ethService, result.settingsService, result.walletAccountService, result.transactionService, result.ethService,
result.networkService, result.tokenService) result.networkService, result.tokenService)
result.providerService = provider_service.newService(result.ensService) result.providerService = provider_service.newService(result.ensService)
result.visualIdentityService = visual_identity_service.newService()
# Modules # Modules
result.startupModule = startup_module.newModule[AppController]( result.startupModule = startup_module.newModule[AppController](
@ -222,7 +219,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.gifService, result.gifService,
result.ensService, result.ensService,
result.networkService, result.networkService,
result.visualIdentityService
) )
# Do connections # Do connections
@ -271,7 +267,6 @@ proc delete*(self: AppController) =
self.generalService.delete self.generalService.delete
self.ensService.delete self.ensService.delete
self.gifService.delete self.gifService.delete
self.visualIdentityService.delete
proc startupDidLoad*(self: AppController) = proc startupDidLoad*(self: AppController) =
singletonInstance.engine.setRootContextProperty("localAppSettings", self.localAppSettingsVariant) singletonInstance.engine.setRootContextProperty("localAppSettings", self.localAppSettingsVariant)
@ -320,14 +315,14 @@ proc load(self: AppController) =
self.gifService.init() self.gifService.init()
singletonInstance.engine.setRootContextProperty("globalUtils", self.globalUtilsVariant) singletonInstance.engine.setRootContextProperty("globalUtils", self.globalUtilsVariant)
let pubKey = self.settingsService.getPublicKey() let pubKey = self.settingsService.getPublicKey()
singletonInstance.localAccountSensitiveSettings.setFileName(pubKey) singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant) singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)
self.buildAndRegisterLocalAccountSensitiveSettings() self.buildAndRegisterLocalAccountSensitiveSettings()
self.buildAndRegisterUserProfile() self.buildAndRegisterUserProfile()
self.networkService.init() self.networkService.init()
self.tokenService.init() self.tokenService.init()
self.walletAccountService.init() self.walletAccountService.init()
@ -342,7 +337,6 @@ proc load(self: AppController) =
self.messageService, self.messageService,
self.gifService, self.gifService,
self.mailserversService, self.mailserversService,
self.visualIdentityService,
) )
proc userLoggedIn*(self: AppController) = proc userLoggedIn*(self: AppController) =

View File

@ -5,6 +5,7 @@ import ./utils/qrcodegen
# Services as instances shouldn't be used in this class, just some general/global procs # Services as instances shouldn't be used in this class, just some general/global procs
import ../../app_service/common/conversion import ../../app_service/common/conversion
import ../../app_service/service/accounts/service as procs_from_accounts import ../../app_service/service/accounts/service as procs_from_accounts
import ../../app_service/service/visual_identity/service as procs_from_visual_identity_service
QtObject: QtObject:
@ -128,3 +129,9 @@ QtObject:
proc plainText*(self: Utils, text: string): string {.slot.} = proc plainText*(self: Utils, text: string): string {.slot.} =
result = plain_text(text) 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)

View File

@ -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/gif/service as gif_service
import ../../../../../app_service/service/message/service as message_service import ../../../../../app_service/service/message/service as message_service
import ../../../../../app_service/service/mailservers/service as mailservers_service import ../../../../../app_service/service/mailservers/service as mailservers_service
import ../../../../../app_service/service/visual_identity/service as visual_identity_service
export io_interface export io_interface
@ -42,7 +41,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.ServiceInterface, belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.ServiceInterface,
contactService: contact_service.Service, chatService: chat_service.Service, contactService: contact_service.Service, chatService: chat_service.Service,
communityService: community_service.Service, messageService: message_service.Service, gifService: gif_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 = Module =
result = Module() result = Module()
result.delegate = delegate result.delegate = delegate
@ -57,7 +56,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
contactService, communityService, chatService, messageService, mailserversService) contactService, communityService, chatService, messageService, mailserversService)
result.usersModule = users_module.newModule( result.usersModule = users_module.newModule(
result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable, result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable,
contactService, chat_service, communityService, messageService, visualIdentityService contactService, chat_service, communityService, messageService
) )
method delete*(self: Module) = method delete*(self: Module) =

View File

@ -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/community/service as community_service
import ../../../../../../app_service/service/message/service as message_service import ../../../../../../app_service/service/message/service as message_service
import ../../../../../../app_service/service/chat/service as chat_service import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/visual_identity/service as visual_identity_service
import ../../../../../core/eventemitter import ../../../../../core/eventemitter
@ -24,13 +23,12 @@ type
chatService: chat_service.Service chatService: chat_service.Service
communityService: community_service.Service communityService: community_service.Service
messageService: message_service.Service messageService: message_service.Service
visualIdentityService: visual_identity_service.Service
proc newController*( proc newController*(
delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string, delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service, belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service,
chatService: chat_service.Service, communityService: community_service.Service, chatService: chat_service.Service, communityService: community_service.Service,
messageService: message_service.Service, visualIdentityService: visual_identity_service.Service messageService: message_service.Service
): Controller = ): Controller =
result = Controller() result = Controller()
result.delegate = delegate result.delegate = delegate
@ -44,7 +42,6 @@ proc newController*(
result.communityService = communityService result.communityService = communityService
result.messageService = messageService result.messageService = messageService
result.chatService = chatService result.chatService = chatService
result.visualIdentityService = visualIdentityService
method delete*(self: Controller) = method delete*(self: Controller) =
discard discard
@ -155,9 +152,3 @@ method getContactDetails*(self: Controller, contactId: string): ContactDetails =
method getStatusForContact*(self: Controller, contactId: string): StatusUpdateDto = method getStatusForContact*(self: Controller, contactId: string): StatusUpdateDto =
return self.contactService.getStatusForContactWithId(contactId) 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)

View File

@ -1,6 +1,5 @@
import ../../../../../../app_service/service/contacts/service as contacts_service import ../../../../../../app_service/service/contacts/service as contacts_service
import ../../../../../../app_service/service/chat/service as chat_service import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/visual_identity/service
type type
AccessInterface* {.pure inheritable.} = ref object of RootObj 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) = method getChatMemberInfo*(self: AccessInterface, id: string): (bool, bool) =
raise newException(ValueError, "No implementation available") 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")

View File

@ -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/chat/service as chat_service
import ../../../../../../app_service/service/community/service as community_service import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/message/service as message_service import ../../../../../../app_service/service/message/service as message_service
import ../../../../../../app_service/service/visual_identity/service as visual_identity_service
export io_interface export io_interface
@ -25,7 +24,7 @@ proc newModule*(
delegate: delegate_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string, delegate: delegate_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service, belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service,
chatService: chat_service.Service, communityService: community_service.Service, chatService: chat_service.Service, communityService: community_service.Service,
messageService: message_service.Service, visualIdentityService: visual_identity_service.Service messageService: message_service.Service,
): Module = ): Module =
result = Module() result = Module()
result.delegate = delegate result.delegate = delegate
@ -33,7 +32,7 @@ proc newModule*(
result.viewVariant = newQVariant(result.view) result.viewVariant = newQVariant(result.view)
result.controller = controller.newController( result.controller = controller.newController(
result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable, result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable,
contactService, chatService, communityService, messageService, visualIdentityService contactService, chatService, communityService, messageService,
) )
result.moduleLoaded = false result.moduleLoaded = false
@ -63,8 +62,6 @@ method viewDidLoad*(self: Module) =
singletonInstance.userProfile.getIcon(), singletonInstance.userProfile.getIcon(),
singletonInstance.userProfile.getIdenticon(), singletonInstance.userProfile.getIdenticon(),
singletonInstance.userProfile.getIsIdenticon(), singletonInstance.userProfile.getIsIdenticon(),
self.controller.getEmojiHash(singletonInstance.userProfile.getPubKey()),
self.controller.getColorHash(singletonInstance.userProfile.getPubKey()),
isAdded = true, isAdded = true,
admin, admin,
joined, joined,
@ -90,8 +87,6 @@ method viewDidLoad*(self: Module) =
contactDetails.icon, contactDetails.icon,
contactDetails.details.identicon, contactDetails.details.identicon,
contactDetails.isidenticon, contactDetails.isidenticon,
self.controller.getEmojiHash(publicKey),
self.controller.getColorHash(publicKey),
contactDetails.details.added, contactDetails.details.added,
admin, admin,
joined joined
@ -125,8 +120,6 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto]) =
contactDetails.icon, contactDetails.icon,
contactDetails.details.identicon, contactDetails.details.identicon,
contactDetails.isidenticon, contactDetails.isidenticon,
self.controller.getEmojiHash(m.`from`),
self.controller.getColorHash(m.`from`),
contactDetails.details.added, contactDetails.details.added,
)) ))
@ -180,8 +173,6 @@ method onChatMembersAdded*(self: Module, ids: seq[string]) =
contactDetails.icon, contactDetails.icon,
contactDetails.details.identicon, contactDetails.details.identicon,
contactDetails.isidenticon, contactDetails.isidenticon,
self.controller.getEmojiHash(id),
self.controller.getColorHash(id),
contactDetails.details.added, contactDetails.details.added,
admin, admin,
joined joined

View File

@ -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/message/service as message_service
import ../../../../app_service/service/mailservers/service as mailservers_service import ../../../../app_service/service/mailservers/service as mailservers_service
import ../../../../app_service/service/gif/service as gif_service import ../../../../app_service/service/gif/service as gif_service
import ../../../../app_service/service/visual_identity/service as visual_identity_service
export io_interface export io_interface
@ -86,11 +85,10 @@ proc addSubmodule(self: Module, chatId: string, belongToCommunity: bool, isUsers
communityService: community_service.Service, communityService: community_service.Service,
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_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, self.chatContentModules[chatId] = chat_content_module.newModule(self, events, self.controller.getMySectionId(), chatId,
belongToCommunity, isUsersListAvailable, settingsService, contactService, chatService, communityService, belongToCommunity, isUsersListAvailable, settingsService, contactService, chatService, communityService,
messageService, gifService, mailserversService, visualIdentityService) messageService, gifService, mailserversService)
proc removeSubmodule(self: Module, chatId: string) = proc removeSubmodule(self: Module, chatId: string) =
if(not self.chatContentModules.contains(chatId)): if(not self.chatContentModules.contains(chatId)):
@ -104,8 +102,7 @@ proc buildChatUI(self: Module, events: EventEmitter,
communityService: community_service.Service, communityService: community_service.Service,
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_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 types = @[ChatType.OneToOne, ChatType.Public, ChatType.PrivateGroupChat]
let chats = self.controller.getChatDetailsForChatTypes(types) let chats = self.controller.getChatDetailsForChatTypes(types)
@ -133,7 +130,7 @@ proc buildChatUI(self: Module, events: EventEmitter,
active=false, c.position, c.categoryId) active=false, c.position, c.categoryId)
self.view.chatsModel().appendItem(item) self.view.chatsModel().appendItem(item)
self.addSubmodule(c.id, false, isUsersListAvailable, events, settingsService, contactService, chatService, 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 # make the first Public chat active when load the app
if(selectedItemId.len == 0 and c.chatType == ChatType.Public): if(selectedItemId.len == 0 and c.chatType == ChatType.Public):
@ -148,8 +145,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
communityService: community_service.Service, communityService: community_service.Service,
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service) =
visualIdentityService: visual_identity_service.Service) =
var selectedItemId = "" var selectedItemId = ""
var selectedSubItemId = "" var selectedSubItemId = ""
let communities = self.controller.getJoinedCommunities() 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) notificationsCount, chatDto.muted, blocked=false, active = false, c.position, c.categoryId)
self.view.chatsModel().appendItem(channelItem) self.view.chatsModel().appendItem(channelItem)
self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService, 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 # make the first channel which doesn't belong to any category active when load the app
if(selectedItemId.len == 0): if(selectedItemId.len == 0):
@ -201,7 +197,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter,
active=false, c.position) active=false, c.position)
categoryChannels.add(channelItem) categoryChannels.add(channelItem)
self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService, 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, # in case there is no channels beyond categories,
# make the first channel of the first category active when load the app # 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, communityService: community_service.Service,
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service) =
visualIdentityService: visual_identity_service.Service) =
self.controller.init() self.controller.init()
self.view.load() self.view.load()
if(self.controller.isCommunity()): 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: 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) self.initContactRequestsModel() # we do this only in case of chat section (not in case of communities)
for cModule in self.chatContentModules.values: for cModule in self.chatContentModules.values:
@ -405,7 +400,6 @@ method addNewChat*(
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service,
setChatAsActive: bool = true) = setChatAsActive: bool = true) =
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0 let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
let notificationsCount = chatDto.unviewedMentionsCount let notificationsCount = chatDto.unviewedMentionsCount
@ -427,7 +421,7 @@ method addNewChat*(
chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount,
chatDto.muted, blocked=false, active=false, position = 0, chatDto.categoryId, chatDto.highlight) chatDto.muted, blocked=false, active=false, position = 0, chatDto.categoryId, chatDto.highlight)
self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, 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.chatContentModules[chatDto.id].load()
self.view.chatsModel().appendItem(item) self.view.chatsModel().appendItem(item)
if setChatAsActive: if setChatAsActive:
@ -443,7 +437,7 @@ method addNewChat*(
amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, blocked=false, active=false, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, blocked=false, active=false,
chatDto.position) chatDto.position)
self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, 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.chatContentModules[chatDto.id].load()
categoryItem.appendSubItem(channelItem) categoryItem.appendSubItem(channelItem)
if setChatAsActive: if setChatAsActive:
@ -558,7 +552,7 @@ method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
method onCommunityChannelEdited*(self: Module, chat: ChatDto) = method onCommunityChannelEdited*(self: Module, chat: ChatDto) =
if(not self.chatContentModules.contains(chat.id)): if(not self.chatContentModules.contains(chat.id)):
return 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) chat.color)
method createOneToOneChat*(self: Module, communityID: string, chatId: string, ensName: string) = method createOneToOneChat*(self: Module, communityID: string, chatId: string, ensName: string) =

View File

@ -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/message/service as message_service
import ../../../../../app_service/service/gif/service as gif_service import ../../../../../app_service/service/gif/service as gif_service
import ../../../../../app_service/service/mailservers/service as mailservers_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 import ../model as chats_model
@ -23,8 +22,7 @@ method load*(self: AccessInterface, events: EventEmitter,
communityService: community_service.Service, communityService: community_service.Service,
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service) {.base.} =
visualIdentityService: visual_identity_service.Service) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method isLoaded*(self: AccessInterface): bool {.base.} = method isLoaded*(self: AccessInterface): bool {.base.} =

View File

@ -6,7 +6,6 @@ import ../../../core/signals/types
import ../../../core/eventemitter import ../../../core/eventemitter
import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/community/service as community_service
import ../../../../app_service/service/contacts/service as contacts_service import ../../../../app_service/service/contacts/service as contacts_service
import ../../../../app_service/service/visual_identity/service as visual_identity_service
export controller_interface export controller_interface
@ -16,21 +15,18 @@ type
events: EventEmitter events: EventEmitter
communityService: community_service.Service communityService: community_service.Service
contactsService: contacts_service.Service contactsService: contacts_service.Service
visualIdentityService: visual_identity_service.Service
proc newController*( proc newController*(
delegate: io_interface.AccessInterface, delegate: io_interface.AccessInterface,
events: EventEmitter, events: EventEmitter,
communityService: community_service.Service, communityService: community_service.Service,
contactsService: contacts_service.Service, contactsService: contacts_service.Service,
visualIdentityService: visual_identity_service.Service
): Controller = ): Controller =
result = Controller() result = Controller()
result.delegate = delegate result.delegate = delegate
result.events = events result.events = events
result.communityService = communityService result.communityService = communityService
result.contactsService = contactsService result.contactsService = contactsService
result.visualIdentityService = visualIdentityService
method delete*(self: Controller) = method delete*(self: Controller) =
discard discard
@ -138,9 +134,3 @@ method userCanJoin*(self: Controller, communityId: string): bool =
method isCommunityRequestPending*(self: Controller, communityId: string): bool = method isCommunityRequestPending*(self: Controller, communityId: string): bool =
return self.communityService.isCommunityRequestPending(communityId) 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)

View File

@ -1,6 +1,5 @@
import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/community/service as community_service
import ../../../../app_service/service/contacts/service as contacts_service import ../../../../app_service/service/contacts/service as contacts_service
import ../../../../app_service/service/visual_identity/service as visual_identity_service
type type
AccessInterface* {.pure inheritable.} = ref object of RootObj 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.} = method getContactDetails*(self: AccessInterface, contactId: string): ContactDetails {.base.} =
raise newException(ValueError, "No implementation available") 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 type
## Abstract class (concept) which must be implemented by object/s used in this ## Abstract class (concept) which must be implemented by object/s used in this
## module. ## module.

View File

@ -9,7 +9,6 @@ import ../../../global/global_singleton
import ../../../core/eventemitter import ../../../core/eventemitter
import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/community/service as community_service
import ../../../../app_service/service/contacts/service as contacts_service import ../../../../app_service/service/contacts/service as contacts_service
import ../../../../app_service/service/visual_identity/service as visual_identity_service
export io_interface export io_interface
@ -34,9 +33,7 @@ proc newModule*(
delegate: delegate_interface.AccessInterface, delegate: delegate_interface.AccessInterface,
events: EventEmitter, events: EventEmitter,
communityService: community_service.Service, communityService: community_service.Service,
contactsService: contacts_service.Service, contactsService: contacts_service.Service): Module =
visualIdentityService: visual_identity_service.Service
): Module =
result = Module() result = Module()
result.delegate = delegate result.delegate = delegate
result.view = newView(result) result.view = newView(result)
@ -46,7 +43,6 @@ proc newModule*(
events, events,
communityService, communityService,
contactsService, contactsService,
visualIdentityService
) )
result.moduleLoaded = false result.moduleLoaded = false
@ -103,8 +99,6 @@ method getCommunityItem(self: Module, c: CommunityDto): SectionItem =
contactDetails.icon, contactDetails.icon,
contactDetails.details.identicon, contactDetails.details.identicon,
contactDetails.isidenticon, contactDetails.isidenticon,
self.controller.getEmojiHash(member.id),
self.controller.getColorHash(member.id),
contactDetails.details.added, contactDetails.details.added,
)) ))
) )

View File

@ -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/mailservers/service as mailservers_service
import ../../../app_service/service/privacy/service as privacy_service import ../../../app_service/service/privacy/service as privacy_service
import ../../../app_service/service/node/service as node_service import ../../../app_service/service/node/service as node_service
import ../../../app_service/service/visual_identity/service as visual_identity_service
export controller_interface export controller_interface
@ -38,7 +37,6 @@ type
privacyService: privacy_service.Service privacyService: privacy_service.Service
mailserversService: mailservers_service.Service mailserversService: mailservers_service.Service
nodeService: node_service.Service nodeService: node_service.Service
visualIdentityService: visual_identity_service.Service
activeSectionId: string activeSectionId: string
proc newController*(delegate: io_interface.AccessInterface, proc newController*(delegate: io_interface.AccessInterface,
@ -54,7 +52,6 @@ proc newController*(delegate: io_interface.AccessInterface,
privacyService: privacy_service.Service, privacyService: privacy_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service,
nodeService: node_service.Service, nodeService: node_service.Service,
visualIdentityService: visual_identity_service.Service
): ):
Controller = Controller =
result = Controller() result = Controller()
@ -70,7 +67,6 @@ proc newController*(delegate: io_interface.AccessInterface,
result.gifService = gifService result.gifService = gifService
result.privacyService = privacyService result.privacyService = privacyService
result.nodeService = nodeService result.nodeService = nodeService
result.visualIdentityService = visualIdentityService
method delete*(self: Controller) = method delete*(self: Controller) =
discard discard
@ -108,7 +104,6 @@ method init*(self: Controller) =
self.messageService, self.messageService,
self.gifService, self.gifService,
self.mailserversService, self.mailserversService,
self.visualIdentityService
) )
self.events.on(TOGGLE_SECTION) do(e:Args): self.events.on(TOGGLE_SECTION) do(e:Args):
@ -127,7 +122,6 @@ method init*(self: Controller) =
self.messageService, self.messageService,
self.gifService, self.gifService,
self.mailserversService, self.mailserversService,
self.visualIdentityService
) )
self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args): self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args):
@ -144,7 +138,6 @@ method init*(self: Controller) =
self.messageService, self.messageService,
self.gifService, self.gifService,
self.mailserversService, self.mailserversService,
self.visualIdentityService
) )
self.events.on(SIGNAL_COMMUNITY_LEFT) do(e:Args): 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 = method getCommunityById*(self: Controller, communityId: string): CommunityDto =
return self.communityService.getCommunityById(communityId) 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)

View File

@ -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/contact_details as contact_details
import ../../../app_service/service/contacts/dto/contacts as contacts_dto import ../../../app_service/service/contacts/dto/contacts as contacts_dto
import ../../../app_service/service/community/service as community_service import ../../../app_service/service/community/service as community_service
import ../../../app_service/service/visual_identity/service as visual_identity_service
type type
AccessInterface* {.pure inheritable.} = ref object of RootObj AccessInterface* {.pure inheritable.} = ref object of RootObj
@ -66,9 +65,3 @@ method getCommunityById*(self: AccessInterface, communityId: string): CommunityD
method isConnected*(self: AccessInterface): bool {.base.} = method isConnected*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available") 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")

View File

@ -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/gif/service as gif_service
import ../../../app_service/service/ens/service as ens_service import ../../../app_service/service/ens/service as ens_service
import ../../../app_service/service/network/service as network_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/notifications/details
import ../../core/eventemitter import ../../core/eventemitter
@ -109,7 +108,6 @@ proc newModule*[T](
gifService: gif_service.Service, gifService: gif_service.Service,
ensService: ens_service.Service, ensService: ens_service.Service,
networkService: network_service.Service, networkService: network_service.Service,
visualIdentityService: visual_identity_service.Service
): Module[T] = ): Module[T] =
result = Module[T]() result = Module[T]()
result.delegate = delegate result.delegate = delegate
@ -129,7 +127,6 @@ proc newModule*[T](
privacyService, privacyService,
mailserversService, mailserversService,
nodeService, nodeService,
visualIdentityService
) )
result.moduleLoaded = false result.moduleLoaded = false
@ -152,7 +149,7 @@ proc newModule*[T](
result.stickersModule = stickers_module.newModule(result, events, stickersService, settingsService, walletAccountService) result.stickersModule = stickers_module.newModule(result, events, stickersService, settingsService, walletAccountService)
result.activityCenterModule = activity_center_module.newModule(result, events, activityCenterService, contactsService, result.activityCenterModule = activity_center_module.newModule(result, events, activityCenterService, contactsService,
messageService, chatService) 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, result.appSearchModule = app_search_module.newModule(result, events, contactsService, chatService, communityService,
messageService) messageService)
result.nodeSectionModule = node_section_module.newModule(result, events, settingsService, nodeService, nodeConfigurationService) 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.icon,
contactDetails.details.identicon, contactDetails.details.identicon,
contactDetails.isidenticon, contactDetails.isidenticon,
self.controller.getEmojiHash(member.id),
self.controller.getColorHash(member.id),
contactDetails.details.added contactDetails.details.added
)), )),
c.pendingRequestsToJoin.map(x => pending_request_item.initItem( c.pendingRequestsToJoin.map(x => pending_request_item.initItem(
@ -237,7 +232,6 @@ method load*[T](
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service
) = ) =
singletonInstance.engine.setRootContextProperty("mainModule", self.viewVariant) singletonInstance.engine.setRootContextProperty("mainModule", self.viewVariant)
self.controller.init() self.controller.init()
@ -353,9 +347,9 @@ method load*[T](
activeSection = profileSettingsSectionItem activeSection = profileSettingsSectionItem
# Load all sections # 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: 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.browserSectionModule.load()
# self.nodeManagementSectionModule.load() # self.nodeManagementSectionModule.load()
@ -582,7 +576,6 @@ method communityJoined*[T](
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service,
visualIdentityService: visual_identity_service.Service
) = ) =
var firstCommunityJoined = false var firstCommunityJoined = false
if (self.communitySectionsModule.len == 0): if (self.communitySectionsModule.len == 0):
@ -600,7 +593,7 @@ method communityJoined*[T](
gifService, gifService,
mailserversService 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) let communitySectionItem = self.createCommunityItem(community)
if (firstCommunityJoined): if (firstCommunityJoined):
@ -653,17 +646,6 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string): string =
} }
return $jsonObj 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) = method resolveENS*[T](self: Module[T], ensName: string, uuid: string) =
if ensName.len == 0: if ensName.len == 0:
error "error: cannot do a lookup for empty ens name" error "error: cannot do a lookup for empty ens name"

View File

@ -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/message/service as message_service
import ../../../../app_service/service/gif/service as gif_service import ../../../../app_service/service/gif/service as gif_service
import ../../../../app_service/service/mailservers/service as mailservers_service import ../../../../app_service/service/mailservers/service as mailservers_service
import ../../../../app_service/service/visual_identity/service as visual_identity_service
import ../../../core/eventemitter import ../../../core/eventemitter
@ -21,9 +20,7 @@ method load*(
communityService: community_service.Service, communityService: community_service.Service,
messageService: message_service.Service, messageService: message_service.Service,
gifService: gif_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service)
visualIdentityService: visual_identity_service.Service
)
{.base.} = {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

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

View File

@ -26,12 +26,6 @@ method getAppSearchModule*(self: AccessInterface): QVariant {.base.} =
method getContactDetailsAsJson*(self: AccessInterface, publicKey: string): string {.base.} = method getContactDetailsAsJson*(self: AccessInterface, publicKey: string): string {.base.} =
raise newException(ValueError, "No implementation available") 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.} = method resolveENS*(self: AccessInterface, ensName: string, uuid: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -151,14 +151,6 @@ QtObject:
proc getContactDetailsAsJson(self: View, publicKey: string): string {.slot.} = proc getContactDetailsAsJson(self: View, publicKey: string): string {.slot.} =
return self.delegate.getContactDetailsAsJson(publicKey) 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.} = proc resolveENS*(self: View, ensName: string, uuid: string) {.slot.} =
self.delegate.resolveENS(ensName, uuid) self.delegate.resolveENS(ensName, uuid)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,5 @@
import strformat, sequtils, sugar import strformat, sequtils, sugar
import ./emojis_model, ./color_hash_model, ./color_hash_item
type type
OnlineStatus* {.pure.} = enum OnlineStatus* {.pure.} = enum
Offline = 0 Offline = 0
@ -10,9 +8,6 @@ type
Idle Idle
Invisible Invisible
type
ColorHashSegment* = tuple[len, colorIdx: int]
# TODO add role when it is needed # TODO add role when it is needed
type type
Item* = ref object Item* = ref object
@ -25,8 +20,6 @@ type
icon: string icon: string
identicon: string identicon: string
isIdenticon: bool isIdenticon: bool
emojiHashModel: emojis_model.Model
colorHashModel: color_hash_model.Model
isAdded: bool isAdded: bool
isAdmin: bool isAdmin: bool
joined: bool joined: bool
@ -41,8 +34,6 @@ proc initItem*(
icon: string, icon: string,
identicon: string, identicon: string,
isidenticon: bool, isidenticon: bool,
emojiHash: seq[string],
colorHash: seq[ColorHashSegment],
isAdded: bool = false, isAdded: bool = false,
isAdmin: bool = false, isAdmin: bool = false,
joined: bool = false, joined: bool = false,
@ -57,10 +48,6 @@ proc initItem*(
result.icon = icon result.icon = icon
result.identicon = identicon result.identicon = identicon
result.isIdenticon = isidenticon 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.isAdded = isAdded
result.isAdmin = isAdmin result.isAdmin = isAdmin
result.joined = joined result.joined = joined
@ -145,9 +132,3 @@ proc joined*(self: Item): bool {.inline.} =
proc `joined=`*(self: Item, value: bool) {.inline.} = proc `joined=`*(self: Item, value: bool) {.inline.} =
self.joined = value self.joined = value
proc emojiHashModel*(self: Item): emojis_model.Model {.inline.} =
self.emojiHashModel
proc colorHashModel*(self: Item): color_hash_model.Model {.inline.} =
self.colorHashModel

View File

@ -13,8 +13,6 @@ type
Icon Icon
Identicon Identicon
IsIdenticon IsIdenticon
EmojiHashModel
ColorHashModel
IsAdded IsAdded
IsAdmin IsAdmin
Joined Joined
@ -68,8 +66,6 @@ QtObject:
ModelRole.Icon.int:"icon", ModelRole.Icon.int:"icon",
ModelRole.Identicon.int:"identicon", ModelRole.Identicon.int:"identicon",
ModelRole.IsIdenticon.int:"isIdenticon", ModelRole.IsIdenticon.int:"isIdenticon",
ModelRole.EmojiHashModel.int:"emojiHashModel",
ModelRole.ColorHashModel.int:"colorHashModel",
ModelRole.IsAdded.int:"isAdded", ModelRole.IsAdded.int:"isAdded",
ModelRole.IsAdmin.int:"isAdmin", ModelRole.IsAdmin.int:"isAdmin",
ModelRole.Joined.int:"joined", ModelRole.Joined.int:"joined",
@ -104,10 +100,6 @@ QtObject:
result = newQVariant(item.identicon) result = newQVariant(item.identicon)
of ModelRole.IsIdenticon: of ModelRole.IsIdenticon:
result = newQVariant(item.isIdenticon) result = newQVariant(item.isIdenticon)
of ModelRole.EmojiHashModel:
result = newQVariant(item.emojiHashModel)
of ModelRole.ColorHashModel:
result = newQVariant(item.colorHashModel)
of ModelRole.IsAdded: of ModelRole.IsAdded:
result = newQVariant(item.isAdded) result = newQVariant(item.isAdded)
of ModelRole.IsAdmin: of ModelRole.IsAdmin:

View File

@ -1,21 +1,11 @@
import chronicles import chronicles, marshal, json
import ./dto as dto import ./dto as dto
import ./service_interface
import ../../../backend/visual_identity as status_visual_identity import ../../../backend/visual_identity as status_visual_identity
export dto export dto
type proc emojiHashOf*(pubkey: string): EmojiHashDto =
Service* = ref object of service_interface.ServiceInterface
proc newService*(): Service =
result = Service()
method delete*(self: Service) =
discard
proc emojiHashOf*(self: Service, pubkey: string): EmojiHashDto =
try: try:
let response = status_visual_identity.emojiHashOf(pubkey) 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, error "error: ", methodName = "emojiHashOf", errName = e.name,
errDesription = e.msg errDesription = e.msg
proc colorHashOf*(self: Service, pubkey: string): ColorHashDto = proc colorHashOf*(pubkey: string): ColorHashDto =
try: try:
let response = status_visual_identity.colorHashOf(pubkey) let response = status_visual_identity.colorHashOf(pubkey)
@ -40,3 +30,13 @@ proc colorHashOf*(self: Service, pubkey: string): ColorHashDto =
except Exception as e: except Exception as e:
error "error: ", methodName = "colorHashOf", errName = e.name, error "error: ", methodName = "colorHashOf", errName = e.name,
errDesription = e.msg 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

View File

@ -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")

View File

@ -608,7 +608,7 @@ QtObject {
if (publicKey === "") { if (publicKey === "") {
return "" return ""
} }
let jsonObj = mainModule.getEmojiHashAsJson(publicKey) let jsonObj = globalUtils.getEmojiHashAsJson(publicKey)
return JSON.parse(jsonObj) return JSON.parse(jsonObj)
} }
@ -616,7 +616,7 @@ QtObject {
if (publicKey === "") { if (publicKey === "") {
return "" return ""
} }
let jsonObj = mainModule.getColorHashAsJson(publicKey) let jsonObj = globalUtils.getColorHashAsJson(publicKey)
return JSON.parse(jsonObj) return JSON.parse(jsonObj)
} }