refactor: refactor contacts sub-section to the new architecture

This commit is contained in:
Jonathan Rainville 2021-10-21 15:13:13 -04:00 committed by Iuri Matias
parent 8c3c4d7607
commit 1d0b20b156
16 changed files with 164 additions and 90 deletions

View File

@ -2,7 +2,7 @@ import NimQml, os, strformat
import ../../app_service/service/keychain/service as keychain_service
import ../../app_service/service/accounts/service as accounts_service
import ../../app_service/service/contacts/service as contact_service
import ../../app_service/service/contacts/service as contacts_service
import ../../app_service/service/chat/service as chat_service
import ../../app_service/service/community/service as community_service
import ../../app_service/service/token/service as token_service
@ -15,7 +15,6 @@ import ../../app_service/service/bookmarks/service as bookmark_service
import ../core/local_account_settings
import ../../app_service/service/profile/service as profile_service
import ../../app_service/service/settings/service as settings_service
import ../../app_service/service/contacts/service as contacts_service
import ../../app_service/service/about/service as about_service
import ../modules/startup/module as startup_module
import ../modules/main/module as main_module
@ -62,7 +61,7 @@ type
# Services
keychainService: keychain_service.Service
accountsService: accounts_service.Service
contactService: contact_service.Service
contactsService: contacts_service.Service
chatService: chat_service.Service
communityService: community_service.Service
tokenService: token_service.Service
@ -73,7 +72,6 @@ type
bookmarkService: bookmark_service.Service
profileService: profile_service.Service
settingsService: settings_service.Service
contactsService: contacts_service.Service
aboutService: about_service.Service
# Core
@ -119,7 +117,7 @@ proc newAppController*(appService: AppService): AppController =
result.keychainService = keychain_service.newService(appService.status.events)
result.settingService = setting_service.newService()
result.accountsService = accounts_service.newService()
result.contactService = contact_service.newService()
result.contactsService = contacts_service.newService(appService.status.events)
result.chatService = chat_service.newService()
result.communityService = community_service.newService(result.chatService)
result.tokenService = token_service.newService(result.settingService)
@ -131,7 +129,6 @@ proc newAppController*(appService: AppService): AppController =
result.bookmarkService = bookmark_service.newService()
result.profileService = profile_service.newService()
result.settingsService = settings_service.newService()
result.contactsService = contacts_service.newService()
result.aboutService = about_service.newService()
# Core
@ -161,7 +158,7 @@ proc newAppController*(appService: AppService): AppController =
result.settingService,
result.profileService,
result.settingsService,
result.contactService,
result.contactsService,
result.aboutService,
)
@ -185,7 +182,7 @@ proc newAppController*(appService: AppService): AppController =
#result.connect()
proc delete*(self: AppController) =
self.contactService.delete
self.contactsService.delete
self.chatService.delete
self.communityService.delete
self.bookmarkService.delete
@ -203,7 +200,6 @@ proc delete*(self: AppController) =
self.localAccountSensitiveSettingsVariant.delete
self.accountsService.delete
self.contactService.delete
self.chatService.delete
self.communityService.delete
self.tokenService.delete
@ -248,7 +244,7 @@ proc load*(self: AppController) =
#################################################
self.settingService.init()
self.contactService.init()
self.contactsService.init()
self.chatService.init()
self.communityService.init()
self.bookmarkService.init()

View File

@ -98,7 +98,7 @@ proc newModule*[T](
)
result.browserSectionModule = browser_section_module.newModule(result, bookmarkService)
result.profileSectionModule = profile_section_module.newModule(result, accountsService, settingsService, profileService, contactsService, aboutService)
result.profileSectionModule = profile_section_module.newModule(result, events, accountsService, settingsService, profileService, contactsService, aboutService)
method delete*[T](self: Module[T]) =
self.chatSectionModule.delete

View File

@ -1,21 +1,31 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/contacts/service as contacts_service
import ../../../../../app_service/service/contacts/dto/contacts
import ../../../../../app_service/service/accounts/service as accounts_service
# import ./item as item
import eventemitter
export controller_interface
type
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
delegate: io_interface.AccessInterface
events: EventEmitter
contactsService: contacts_service.ServiceInterface
accountsService: accounts_service.ServiceInterface
proc newController*[T](delegate: T, contactsService: contacts_service.ServiceInterface, accountsService: accounts_service.ServiceInterface): Controller[T] =
# forward declaration:
method getContacts*[T](self: Controller[T]): seq[ContactsDto]
proc newController*[T](delegate: io_interface.AccessInterface,
events: EventEmitter,
contactsService: contacts_service.ServiceInterface,
accountsService: accounts_service.ServiceInterface): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.events = events
result.contactsService = contactsService
result.accountsService = accountsService
@ -23,7 +33,25 @@ method delete*[T](self: Controller[T]) =
discard
method init*[T](self: Controller[T]) =
discard
self.events.on("contactAdded") do(e: Args):
let contacts = self.getContacts()
self.delegate.setContactList(contacts)
self.events.on("contactBlocked") do(e: Args):
let contacts = self.getContacts()
self.delegate.setContactList(contacts)
self.events.on("contactUnblocked") do(e: Args):
let contacts = self.getContacts()
self.delegate.setContactList(contacts)
self.events.on("contactRemoved") do(e: Args):
let contacts = self.getContacts()
self.delegate.setContactList(contacts)
method getContacts*[T](self: Controller[T]): seq[ContactsDto] =
return self.contactsService.getContacts()
method getContact*[T](self: Controller[T], id: string): ContactsDto =
return self.contactsService.getContact(id)
@ -32,7 +60,6 @@ method generateAlias*[T](self: Controller[T], publicKey: string): string =
return self.accountsService.generateAlias(publicKey)
method addContact*[T](self: Controller[T], publicKey: string): void =
echo "Adding this from controller ", publicKey
self.contactsService.addContact(publicKey)
method rejectContactRequest*[T](self: Controller[T], publicKey: string): void =
@ -42,7 +69,7 @@ method unblockContact*[T](self: Controller[T], publicKey: string): void =
self.contactsService.unblockContact(publicKey)
method blockContact*[T](self: Controller[T], publicKey: string): void =
self.contactsService.unblockContact(publicKey)
self.contactsService.blockContact(publicKey)
method removeContact*[T](self: Controller[T], publicKey: string): void =
self.contactsService.removeContact(publicKey)

View File

@ -12,8 +12,8 @@ method delete*(self: AccessInterface) {.base.} =
method init*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
# method getProfile*(self: AccessInterface): Item {.base.} =
# raise newException(ValueError, "No implementation available")
method getContacts*(self: AccessInterface): seq[ContactDto.ContactsDto] {.base.} =
raise newException(ValueError, "No implementation available")
method getContact*(self: AccessInterface, id: string): ContactDto.ContactsDto {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -10,6 +10,9 @@ method delete*(self: AccessInterface) {.base.} =
method load*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method setContactList*(self: AccessInterface, contacts: seq[ContactsDto]) {.base.} =
raise newException(ValueError, "No implementation available")
method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -1,5 +1,6 @@
import NimQml, chronicles, sequtils, sugar, strutils, json
import ../../../../../app_service/service/contacts/dto/contacts
import status/utils as status_utils
import status/chat/chat
import status/types/profile
@ -35,11 +36,11 @@ QtObject:
proc contactListChanged*(self: Model) {.signal.}
proc contactRequestAdded*(self: Model, name: string, address: string) {.signal.}
proc updateContactList*(self: Model, contacts: seq[Profile]) =
proc updateContactList*(self: Model, contacts: seq[ContactsDto]) =
for contact in contacts:
var requestAlreadyAdded = false
for existingContact in self.contactList.contacts:
if existingContact.address == contact.address and existingContact.requestReceived():
if existingContact.id == contact.id and existingContact.requestReceived():
requestAlreadyAdded = true
break
@ -55,7 +56,7 @@ QtObject:
if not requestAlreadyAdded and contact.requestReceived():
# TODO add back userNameOrAlias call
self.contactRequestAdded(contact.username, contact.address)
self.contactRequestAdded(contact.name, contact.id)
# self.contactRequestAdded(status_ens.userNameOrAlias(contact), contact.address)
self.contactListChanged()
@ -63,7 +64,7 @@ QtObject:
proc getContactList(self: Model): QVariant {.slot.} =
return newQVariant(self.contactList)
proc setContactList*(self: Model, contactList: seq[Profile]) =
proc setContactList*(self: Model, contactList: seq[ContactsDto]) =
self.contactList.setNewData(contactList)
self.addedContacts.setNewData(contactList.filter(c => c.added))
self.blockedContacts.setNewData(contactList.filter(c => c.blocked))

View File

@ -1,8 +1,7 @@
import NimQml, chronicles
import Tables
import status/types/profile
from status/ens import nil
import ../../../../../../app_service/service/contacts/dto/contacts
type
ContactRoles {.pure.} = enum
@ -21,7 +20,7 @@ type
QtObject:
type ContactList* = ref object of QAbstractListModel
contacts*: seq[Profile]
contacts*: seq[ContactsDto]
proc setup(self: ContactList) = self.QAbstractListModel.setup
@ -31,7 +30,7 @@ QtObject:
proc newContactList*(): ContactList =
new(result, delete)
# TODO: (rramos) contacts should be a table[string, Profile] instead, with the key being the public key
# TODO: (rramos) contacts should be a table[string, ContactsDto] instead, with the key being the public key
# This is to optimize determining if a contact is part of the contact list or not
# (including those that do not have a system tag)
result.contacts = @[]
@ -52,7 +51,7 @@ QtObject:
proc userName*(self: ContactList, pubKey: string, defaultValue: string = ""): string {.slot.} =
for contact in self.contacts:
if(contact.id != pubKey): continue
return ens.userNameOrAlias(contact)
return userNameOrAlias(contact)
return defaultValue
proc getContactIndexByPubkey(self: ContactList, pubkey: string): int {.slot.} =
@ -66,17 +65,18 @@ QtObject:
proc rowData(self: ContactList, index: int, column: string): string {.slot.} =
let contact = self.contacts[index]
case column:
of "name": result = ens.userNameOrAlias(contact)
of "address": result = contact.address
of "name": result = userNameOrAlias(contact)
of "address": result = contact.id
of "identicon": result = contact.identicon
of "pubKey": result = contact.id
of "isContact": result = $contact.isContact()
of "isBlocked": result = $contact.isBlocked()
of "alias": result = contact.alias
of "ensVerified": result = $contact.ensVerified
of "localNickname": result = $contact.localNickname
of "thumbnailImage": result = $contact.identityImage.thumbnail
of "largeImage": result = $contact.identityImage.large
# TODO check if localNickname exists in the contact ContactsDto
of "localNickname": result = ""#$contact.localNickname
of "thumbnailImage": result = $contact.image.thumbnail
of "largeImage": result = $contact.image.large
of "requestReceived": result = $contact.requestReceived()
method data(self: ContactList, index: QModelIndex, role: int): QVariant =
@ -86,17 +86,17 @@ QtObject:
return
let contact = self.contacts[index.row]
case role.ContactRoles:
of ContactRoles.Name: result = newQVariant(ens.userNameOrAlias(contact))
of ContactRoles.Address: result = newQVariant(contact.address)
of ContactRoles.Name: result = newQVariant(userNameOrAlias(contact))
of ContactRoles.Address: result = newQVariant(contact.id)
of ContactRoles.Identicon: result = newQVariant(contact.identicon)
of ContactRoles.PubKey: result = newQVariant(contact.id)
of ContactRoles.IsContact: result = newQVariant(contact.isContact())
of ContactRoles.IsBlocked: result = newQVariant(contact.isBlocked())
of ContactRoles.Alias: result = newQVariant(contact.alias)
of ContactRoles.EnsVerified: result = newQVariant(contact.ensVerified)
of ContactRoles.LocalNickname: result = newQVariant(contact.localNickname)
of ContactRoles.ThumbnailImage: result = newQVariant(contact.identityImage.thumbnail)
of ContactRoles.LargeImage: result = newQVariant(contact.identityImage.large)
of ContactRoles.LocalNickname: result = newQVariant("")#newQVariant(contact.localNickname)
of ContactRoles.ThumbnailImage: result = newQVariant(contact.image.thumbnail)
of ContactRoles.LargeImage: result = newQVariant(contact.image.large)
of ContactRoles.RequestReceived: result = newQVariant(contact.requestReceived())
method roleNames(self: ContactList): Table[int, string] =
@ -115,7 +115,7 @@ QtObject:
ContactRoles.RequestReceived.int:"requestReceived"
}.toTable
proc addContactToList*(self: ContactList, contact: Profile) =
proc addContactToList*(self: ContactList, contact: ContactsDto) =
self.beginInsertRows(newQModelIndex(), self.contacts.len, self.contacts.len)
self.contacts.add(contact)
self.endInsertRows()
@ -128,16 +128,15 @@ QtObject:
proc contactChanged*(self: ContactList, pubkey: string) {.signal.}
proc updateContact*(self: ContactList, contact: Profile) =
proc updateContact*(self: ContactList, contact: ContactsDto) =
var found = false
let topLeft = self.createIndex(0, 0, nil)
let bottomRight = self.createIndex(self.contacts.len, 0, nil)
for c in self.contacts:
if(c.id != contact.id): continue
found = true
c.ensName = contact.ensName
c.ensVerified = contact.ensVerified
c.identityImage = contact.identityImage
c.image = contact.image
c.added = contact.added
c.blocked = contact.blocked
@ -147,7 +146,7 @@ QtObject:
self.dataChanged(topLeft, bottomRight, @[ContactRoles.Name.int])
self.contactChanged(contact.id)
proc setNewData*(self: ContactList, contactList: seq[Profile]) =
proc setNewData*(self: ContactList, contactList: seq[ContactsDto]) =
self.beginResetModel()
self.contacts = contactList
self.endResetModel()

View File

@ -7,6 +7,8 @@ import ../../../../../app_service/service/contacts/service as contacts_service
import ../../../../../app_service/service/contacts/dto/contacts
import ../../../../../app_service/service/accounts/service as accounts_service
import eventemitter
export io_interface
type
@ -17,24 +19,30 @@ type
viewVariant: QVariant
moduleLoaded: bool
proc newModule*[T](delegate: T, contactsService: contacts_service.ServiceInterface, accountsService: accounts_service.ServiceInterface): Module[T] =
proc newModule*[T](delegate: T,
events: EventEmitter,
contactsService: contacts_service.ServiceInterface,
accountsService: accounts_service.ServiceInterface):
Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
echo "Module loaded"
result.controller = controller.newController[Module[T]](result, contactsService, accountsService)
result.controller = controller.newController[Module[T]](result, events, contactsService, accountsService)
result.moduleLoaded = false
echo "Module set as root prop"
singletonInstance.engine.setRootContextProperty("contactsModule", result.viewVariant)
method delete*[T](self: Module[T]) =
self.view.delete
method setContactList*[T](self: Module[T], contacts: seq[ContactsDto]) =
self.view.setContactList(contacts)
method load*[T](self: Module[T]) =
# let profile = self.controller.getProfile()
# self.view.setProfile(profile)
self.controller.init()
let contacts = self.controller.getContacts()
self.setContactList(contacts)
self.moduleLoaded = true
method isLoaded*[T](self: Module[T]): bool =

View File

@ -45,6 +45,9 @@ QtObject:
result.modelVariant = newQVariant(result.model)
result.contactToAdd = ContactsDto()
proc setContactList*(self: View, contacts: seq[ContactsDto]) =
self.model.setContactList(contacts)
proc modelChanged*(self: View) {.signal.}
proc getModel*(self: View): QVariant {.slot.} =
@ -140,13 +143,11 @@ QtObject:
self.delegate.changeContactNickname(publicKey, nicknameToSet, self.accountKeyUID)
proc unblockContact*(self: View, publicKey: string) {.slot.} =
self.model.contactListChanged()
self.delegate.unblockContact(publicKey)
proc contactBlocked*(self: View, publicKey: string) {.signal.}
proc blockContact*(self: View, publicKey: string) {.slot.} =
self.model.contactListChanged()
self.contactBlocked(publicKey)
self.delegate.blockContact(publicKey)

View File

@ -12,6 +12,8 @@ import ./profile/module as profile_module
import ./contacts/module as contacts_module
import ./about/module as about_module
import eventemitter
export io_interface
type
@ -26,7 +28,14 @@ type
contactsModule: contacts_module.AccessInterface
aboutModule: about_module.AccessInterface
proc newModule*[T](delegate: T, accountsService: accounts_service.ServiceInterface, settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface, contactsService: contacts_service.ServiceInterface, aboutService: about_service.ServiceInterface): Module[T] =
proc newModule*[T](delegate: T,
events: EventEmitter,
accountsService: accounts_service.ServiceInterface,
settingsService: settings_service.ServiceInterface,
profileService: profile_service.ServiceInterface,
contactsService: contacts_service.ServiceInterface,
aboutService: about_service.ServiceInterface):
Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = view.newView()
@ -35,7 +44,7 @@ proc newModule*[T](delegate: T, accountsService: accounts_service.ServiceInterfa
result.moduleLoaded = false
result.profileModule = profile_module.newModule(result, accountsService, settingsService, profileService)
result.contactsModule = contacts_module.newModule(result, contactsService, accountsService)
result.contactsModule = contacts_module.newModule(result, events, contactsService, accountsService)
result.aboutModule = about_module.newModule(result, aboutService)
singletonInstance.engine.setRootContextProperty("profileSectionModule", result.viewVariant)

View File

@ -1,10 +1,10 @@
{.used.}
import json, strformat
import json, strformat, strutils
include ../../../common/json_utils
# const DELETE_CONTACT* = "delete_contact"
const domain* = ".stateofus.eth"
type
Images* = ref object
@ -77,4 +77,30 @@ proc toContactsDto*(jsonObj: JsonNode): ContactsDto =
discard jsonObj.getProp("blocked", result.blocked)
discard jsonObj.getProp("hasAddedUs", result.hasAddedUs)
discard jsonObj.getProp("IsSyncing", result.isSyncing)
discard jsonObj.getProp("Removed", result.removed)
discard jsonObj.getProp("Removed", result.removed)
proc userName*(ensName: string, removeSuffix: bool = false): string =
if ensName != "" and ensName.endsWith(domain):
if removeSuffix:
result = ensName.split(".")[0]
else:
result = ensName
else:
if ensName.endsWith(".eth") and removeSuffix:
return ensName.split(".")[0]
result = ensName
proc userNameOrAlias*(contact: ContactsDto, removeSuffix: bool = false): string =
if(contact.name != "" and contact.ensVerified):
result = "@" & userName(contact.name, removeSuffix)
else:
result = contact.alias
proc isContact*(self: ContactsDto): bool =
result = self.added
proc isBlocked*(self: ContactsDto): bool =
result = self.blocked
proc requestReceived*(self: ContactsDto): bool =
result = self.hasAddedUs

View File

@ -1,10 +1,13 @@
import Tables, json, sequtils, strformat, chronicles
import eventemitter
import service_interface, ./dto/contacts
import status/statusgo_backend_new/contacts as status_contacts
import status/statusgo_backend_new/accounts as status_accounts
import status/statusgo_backend_new/chat as status_chat
import status/statusgo_backend_new/utils as status_utils
import status/contacts as old_status_contacts
export service_interface
@ -14,38 +17,30 @@ logScope:
type
Service* = ref object of ServiceInterface
contacts: Table[string, ContactsDto] # [contact_id, ContactsDto]
events: EventEmitter
method delete*(self: Service) =
discard
proc newService*(): Service =
proc newService*(events: EventEmitter): Service =
result = Service()
result.events = events
result.contacts = initTable[string, ContactsDto]()
method init*(self: Service) =
try:
let response = status_contacts.getContacts()
discard
let contacts = map(response.result.getElems(),
proc(x: JsonNode): ContactsDto = x.toContactsDto())
for contact in contacts:
self.contacts[contact.id] = contact
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return
# method getContacts*(self: Service): seq[Profile] =
# return status_contacts.getContacts(false)
method getContacts*(self: Service): seq[ContactsDto] =
let profiles = status_contacts.getContacts()
for profile in profiles.result:
result.add(profile.toContactsDto)
method getContact*(self: Service, id: string): ContactsDto =
return status_contacts.getContactByID(id).result.toContactsDto()
method getOrCreateContact*(self: Service, id: string): ContactsDto =
result = status_contacts.getContactByID(id).result.toContactsDto()
if result == nil:
if result == nil or result.id == "":
let alias = $status_accounts.generateAlias(id)
result = ContactsDto(
id: id,
@ -73,7 +68,6 @@ proc saveContact(self: Service, contact: ContactsDto) =
method addContact*(self: Service, publicKey: string) =
var contact = self.getOrCreateContact(publicKey)
let updating = contact.added
if not updating:
@ -82,15 +76,10 @@ method addContact*(self: Service, publicKey: string) =
else:
contact.blocked = false
# FIXME Save contact fails
try:
self.saveContact(contact)
except Exception as e:
echo "ERROROR ", e.msg
self.saveContact(contact)
# self.events.emit("contactAdded", Args())
self.events.emit("contactAdded", Args())
# sendContactUpdate(contact.id, accountKeyUID)
if updating:
let profile = ContactsDto(
id: contact.id,
@ -105,6 +94,7 @@ method addContact*(self: Service, publicKey: string) =
hasAddedUs: contact.hasAddedUs,
# localNickname: contact.localNickname
)
# TODO fix this to use ContactsDto
# self.events.emit("contactUpdate", ContactUpdateArgs(contacts: @[profile]))
method rejectContactRequest*(self: Service, publicKey: string) =
@ -112,7 +102,7 @@ method rejectContactRequest*(self: Service, publicKey: string) =
contact.hasAddedUs = false
self.saveContact(contact)
# self.events.emit("contactRemoved", Args())
self.events.emit("contactRemoved", Args())
# status_contacts.rejectContactRequest(publicKey)
method changeContactNickname*(self: Service, accountKeyUID: string, publicKey: string, nicknameToSet: string) =
@ -128,7 +118,7 @@ method changeContactNickname*(self: Service, accountKeyUID: string, publicKey: s
# contact.localNickname = nickname
self.saveContact(contact)
# self.events.emit("contactAdded", Args())
self.events.emit("contactAdded", Args())
# sendContactUpdate(contact.id, accountKeyUID)
method unblockContact*(self: Service, publicKey: string) =
@ -136,14 +126,13 @@ method unblockContact*(self: Service, publicKey: string) =
var contact = status_contacts.getContactByID(publicKey).result.toContactsDto()
contact.blocked = false
self.saveContact(contact)
# self.events.emit("contactUnblocked", ContactIdArgs(id: publicKey))
self.events.emit("contactUnblocked", old_status_contacts.ContactIdArgs(id: publicKey))
method blockContact*(self: Service, publicKey: string) =
# status_contacts.blockContact(publicKey)
var contact = status_contacts.getContactByID(publicKey).result.toContactsDto()
contact.blocked = true
self.saveContact(contact)
# self.events.emit("contactBlocked", ContactIdArgs(id: publicKey))
self.events.emit("contactBlocked", old_status_contacts.ContactIdArgs(id: publicKey))
method removeContact*(self: Service, publicKey: string) =
# status_contacts.removeContact(publicKey)
@ -152,7 +141,7 @@ method removeContact*(self: Service, publicKey: string) =
contact.hasAddedUs = false
self.saveContact(contact)
# self.events.emit("contactRemoved", Args())
self.events.emit("contactRemoved", Args())
# let channelId = status_utils.getTimelineChatId(publicKey)
# if status_chat.hasChannel(channelId):
# status_chat.leave(channelId)

View File

@ -1,4 +1,5 @@
import ./dto/contacts as contacts_dto
import status/statusgo_backend_new/accounts as status_accounts
export contacts_dto
@ -15,6 +16,9 @@ method init*(self: ServiceInterface) {.base.} =
method getContact*(self: ServiceInterface, id: string): contacts_dto.ContactsDto {.base.} =
raise newException(ValueError, "No implementation available")
method getContacts*(self: ServiceInterface): seq[contacts_dto.ContactsDto] {.base.} =
raise newException(ValueError, "No implementation available")
method getOrCreateContact*(self: ServiceInterface, id: string): contacts_dto.ContactsDto {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -291,7 +291,8 @@ StatusModal {
text: qsTr("Add to contacts")
visible: !isBlocked && !isAdded
onClicked: {
profileModel.contacts.addContact(fromAuthor);
// TODO make a store for this
contactsModule.addContact(fromAuthor)
popup.contactAdded(fromAuthor);
popup.close();
}

View File

@ -20,9 +20,9 @@ QtObject {
property var permissionList: profileModelInst.dappList.permissionList
property var mailservers: profileModelInst.mailservers
property var mailserversList: profileModelInst.mailservers.list
property var contacts: profileModelInst.contacts.model.list
property var blockedContacts: profileModelInst.contacts.model.blockedContacts
property var addedContacts: profileModelInst.contacts.model.addedContacts
property var contacts: contactsModuleInst.model.list
property var blockedContacts: contactsModuleInst.model.blockedContacts
property var addedContacts: contactsModuleInst.model.addedContacts
property var mutedChatsContacts: profileModelInst.mutedChats.contacts
property var mutedChats: profileModelInst.mutedChats.chats
property var devicesList: profileModelInst.devices.list

View File

@ -134,6 +134,15 @@ Item {
anchors.top: parent.top
anchors.bottom: parent.bottom
contacts: root.store.blockedContacts
onRemoveContactActionTriggered: {
removeContactConfirmationDialog.value = contact.address
removeContactConfirmationDialog.open()
}
onUnblockContactActionTriggered: {
root.store.unblockContact(contact.address)
}
}
}
@ -264,6 +273,7 @@ Item {
removeContactConfirmationDialog.value = contact.address
removeContactConfirmationDialog.open()
}
onUnblockContactActionTriggered: {
root.store.unblockContact(contact.address)
}