refactor(@desktop/settings-profile): profile section updated
This commit is contained in:
parent
5bafb2bb5a
commit
9a82370df0
|
@ -1,7 +1,5 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
|
|
||||||
import ../../app_service/common/utils
|
|
||||||
|
|
||||||
import ../../app_service/service/os_notification/service as os_notification_service
|
import ../../app_service/service/os_notification/service as os_notification_service
|
||||||
import ../../app_service/service/eth/service as eth_service
|
import ../../app_service/service/eth/service as eth_service
|
||||||
import ../../app_service/service/keychain/service as keychain_service
|
import ../../app_service/service/keychain/service as keychain_service
|
||||||
|
@ -305,6 +303,9 @@ proc buildAndRegisterLocalAccountSensitiveSettings(self: AppController) =
|
||||||
|
|
||||||
proc buildAndRegisterUserProfile(self: AppController) =
|
proc buildAndRegisterUserProfile(self: AppController) =
|
||||||
let pubKey = self.settingsService.getPublicKey()
|
let pubKey = self.settingsService.getPublicKey()
|
||||||
|
let preferredName = self.settingsService.getPreferredName()
|
||||||
|
let ensUsernames = self.settingsService.getEnsUsernames()
|
||||||
|
let firstEnsName = if (ensUsernames.len > 0): ensUsernames[0] else: ""
|
||||||
let sendUserStatus = self.settingsService.getSendStatusUpdates()
|
let sendUserStatus = self.settingsService.getSendStatusUpdates()
|
||||||
## This is still not in use. Read a comment in UserProfile.
|
## This is still not in use. Read a comment in UserProfile.
|
||||||
## let currentUserStatus = self.settingsService.getCurrentUserStatus()
|
## let currentUserStatus = self.settingsService.getCurrentUserStatus()
|
||||||
|
@ -318,13 +319,12 @@ proc buildAndRegisterUserProfile(self: AppController) =
|
||||||
thumbnail = img.uri
|
thumbnail = img.uri
|
||||||
|
|
||||||
let meAsContact = self.contactsService.getContactById(pubKey)
|
let meAsContact = self.contactsService.getContactById(pubKey)
|
||||||
var ensName: string
|
|
||||||
if(meAsContact.ensVerified):
|
|
||||||
ensName = utils.prettyEnsName(meAsContact.name)
|
|
||||||
|
|
||||||
singletonInstance.userProfile.setFixedData(loggedInAccount.name, loggedInAccount.keyUid, loggedInAccount.identicon,
|
singletonInstance.userProfile.setFixedData(loggedInAccount.name, loggedInAccount.keyUid, loggedInAccount.identicon,
|
||||||
pubKey)
|
pubKey)
|
||||||
singletonInstance.userProfile.setEnsName(ensName)
|
singletonInstance.userProfile.setPreferredName(preferredName)
|
||||||
|
singletonInstance.userProfile.setEnsName(meAsContact.name)
|
||||||
|
singletonInstance.userProfile.setFirstEnsName(firstEnsName)
|
||||||
singletonInstance.userProfile.setThumbnailImage(thumbnail)
|
singletonInstance.userProfile.setThumbnailImage(thumbnail)
|
||||||
singletonInstance.userProfile.setLargeImage(large)
|
singletonInstance.userProfile.setLargeImage(large)
|
||||||
singletonInstance.userProfile.setUserStatus(sendUserStatus)
|
singletonInstance.userProfile.setUserStatus(sendUserStatus)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
|
|
||||||
|
import ../../app_service/common/utils
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type UserProfile* = ref object of QObject
|
type UserProfile* = ref object of QObject
|
||||||
# fields which cannot change
|
# fields which cannot change
|
||||||
|
@ -10,6 +12,8 @@ QtObject:
|
||||||
# fields which may change during runtime
|
# fields which may change during runtime
|
||||||
isIdenticon: bool
|
isIdenticon: bool
|
||||||
ensName: string
|
ensName: string
|
||||||
|
firstEnsName: string
|
||||||
|
preferredName: string
|
||||||
thumbnailImage: string
|
thumbnailImage: string
|
||||||
largeImage: string
|
largeImage: string
|
||||||
userStatus: bool
|
userStatus: bool
|
||||||
|
@ -55,9 +59,6 @@ QtObject:
|
||||||
read = getUsername
|
read = getUsername
|
||||||
notify = nameChanged
|
notify = nameChanged
|
||||||
|
|
||||||
proc getEnsName*(self: UserProfile): string {.slot.} =
|
|
||||||
self.ensName
|
|
||||||
|
|
||||||
# this is not a slot
|
# this is not a slot
|
||||||
proc setEnsName*(self: UserProfile, name: string) =
|
proc setEnsName*(self: UserProfile, name: string) =
|
||||||
if(self.ensName == name):
|
if(self.ensName == name):
|
||||||
|
@ -65,13 +66,66 @@ QtObject:
|
||||||
self.ensName = name
|
self.ensName = name
|
||||||
self.nameChanged()
|
self.nameChanged()
|
||||||
|
|
||||||
|
proc getEnsName*(self: UserProfile): string {.slot.} =
|
||||||
|
self.ensName
|
||||||
QtProperty[string] ensName:
|
QtProperty[string] ensName:
|
||||||
read = getEnsName
|
read = getEnsName
|
||||||
notify = nameChanged
|
notify = nameChanged
|
||||||
|
|
||||||
|
proc getPrettyEnsName*(self: UserProfile): string {.slot.} =
|
||||||
|
utils.prettyEnsName(self.ensName)
|
||||||
|
QtProperty[string] prettyEnsName:
|
||||||
|
read = getPrettyEnsName
|
||||||
|
notify = nameChanged
|
||||||
|
|
||||||
|
|
||||||
|
# this is not a slot
|
||||||
|
proc setFirstEnsName*(self: UserProfile, name: string) =
|
||||||
|
if(self.firstEnsName == name):
|
||||||
|
return
|
||||||
|
self.firstEnsName = name
|
||||||
|
self.nameChanged()
|
||||||
|
|
||||||
|
proc getFirstEnsName*(self: UserProfile): string {.slot.} =
|
||||||
|
self.firstEnsName
|
||||||
|
QtProperty[string] firstEnsName:
|
||||||
|
read = getFirstEnsName
|
||||||
|
notify = nameChanged
|
||||||
|
|
||||||
|
proc getPrettyFirstEnsName*(self: UserProfile): string {.slot.} =
|
||||||
|
utils.prettyEnsName(self.firstEnsName)
|
||||||
|
QtProperty[string] prettyFirstEnsName:
|
||||||
|
read = getPrettyFirstEnsName
|
||||||
|
notify = nameChanged
|
||||||
|
|
||||||
|
|
||||||
|
# this is not a slot
|
||||||
|
proc setPreferredName*(self: UserProfile, name: string) =
|
||||||
|
if(self.preferredName == name):
|
||||||
|
return
|
||||||
|
self.preferredName = name
|
||||||
|
self.nameChanged()
|
||||||
|
|
||||||
|
proc getPreferredName*(self: UserProfile): string {.slot.} =
|
||||||
|
self.preferredName
|
||||||
|
QtProperty[string] preferredName:
|
||||||
|
read = getPreferredName
|
||||||
|
notify = nameChanged
|
||||||
|
|
||||||
|
proc getPrettyPreferredName*(self: UserProfile): string {.slot.} =
|
||||||
|
utils.prettyEnsName(self.preferredName)
|
||||||
|
QtProperty[string] prettyPreferredName:
|
||||||
|
read = getPrettyPreferredName
|
||||||
|
notify = nameChanged
|
||||||
|
|
||||||
|
|
||||||
proc getName*(self: UserProfile): string {.slot.} =
|
proc getName*(self: UserProfile): string {.slot.} =
|
||||||
if(self.ensName.len > 0):
|
if(self.preferredName.len > 0):
|
||||||
return self.ensName
|
return self.getPrettyPreferredName()
|
||||||
|
elif(self.firstEnsName.len > 0):
|
||||||
|
return self.getPrettyFirstEnsName()
|
||||||
|
elif(self.ensName.len > 0):
|
||||||
|
return self.getPrettyEnsName()
|
||||||
return self.username
|
return self.username
|
||||||
|
|
||||||
QtProperty[string] name:
|
QtProperty[string] name:
|
||||||
|
|
|
@ -96,5 +96,5 @@ method contactUpdated*(self: Module, contact: ContactsDto) =
|
||||||
self.view.model().updateItem(contact.id, contact.userNameOrAlias(), icon, isIdenticon)
|
self.view.model().updateItem(contact.id, contact.userNameOrAlias(), icon, isIdenticon)
|
||||||
|
|
||||||
method loggedInUserImageChanged*(self: Module) =
|
method loggedInUserImageChanged*(self: Module) =
|
||||||
self.view.model().setIcon(singletonInstance.userProfile.getPubKey(), singletonInstance.userProfile.getThumbnailImage(),
|
self.view.model().setIcon(singletonInstance.userProfile.getPubKey(), singletonInstance.userProfile.getIcon(),
|
||||||
singletonInstance.userProfile.getIsIdenticon())
|
singletonInstance.userProfile.getIsIdenticon())
|
|
@ -23,6 +23,9 @@ method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||||
method profileModuleDidLoad*(self: AccessInterface) {.base.} =
|
method profileModuleDidLoad*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method getProfileModule*(self: AccessInterface): QVariant {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method contactsModuleDidLoad*(self: AccessInterface) {.base.} =
|
method contactsModuleDidLoad*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ proc newModule*[T](delegate: T,
|
||||||
result.controller = controller.newController[Module[T]](result)
|
result.controller = controller.newController[Module[T]](result)
|
||||||
result.moduleLoaded = false
|
result.moduleLoaded = false
|
||||||
|
|
||||||
result.profileModule = profile_module.newModule(result, accountsService, settingsService, profileService)
|
result.profileModule = profile_module.newModule(result, profileService)
|
||||||
result.contactsModule = contacts_module.newModule(result, events, contactsService, accountsService)
|
result.contactsModule = contacts_module.newModule(result, events, contactsService, accountsService)
|
||||||
result.languageModule = language_module.newModule(result, languageService)
|
result.languageModule = language_module.newModule(result, languageService)
|
||||||
result.mnemonicModule = mnemonic_module.newModule(result, mnemonicService)
|
result.mnemonicModule = mnemonic_module.newModule(result, mnemonicService)
|
||||||
|
@ -156,6 +156,9 @@ method viewDidLoad*[T](self: Module[T]) =
|
||||||
method profileModuleDidLoad*[T](self: Module[T]) =
|
method profileModuleDidLoad*[T](self: Module[T]) =
|
||||||
self.checkIfModuleDidLoad()
|
self.checkIfModuleDidLoad()
|
||||||
|
|
||||||
|
method getProfileModule*[T](self: Module[T]): QVariant =
|
||||||
|
self.profileModule.getModuleAsVariant()
|
||||||
|
|
||||||
method contactsModuleDidLoad*[T](self: Module[T]) =
|
method contactsModuleDidLoad*[T](self: Module[T]) =
|
||||||
self.checkIfModuleDidLoad()
|
self.checkIfModuleDidLoad()
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import ./controller_interface
|
import ./controller_interface
|
||||||
import io_interface
|
import io_interface
|
||||||
import ../../../../global/global_singleton
|
|
||||||
import ../../../../../app_service/service/profile/service as profile_service
|
|
||||||
import ../../../../../app_service/service/accounts/service as accounts_service
|
|
||||||
import ../../../../../app_service/service/settings/service_interface as settings_service
|
|
||||||
|
|
||||||
import ./item as item
|
import ../../../../../app_service/service/profile/service_interface as profile_service
|
||||||
import status/types/identity_image
|
|
||||||
|
|
||||||
export controller_interface
|
export controller_interface
|
||||||
|
|
||||||
|
@ -14,16 +9,12 @@ type
|
||||||
Controller* = ref object of controller_interface.AccessInterface
|
Controller* = ref object of controller_interface.AccessInterface
|
||||||
delegate: io_interface.AccessInterface
|
delegate: io_interface.AccessInterface
|
||||||
profileService: profile_service.ServiceInterface
|
profileService: profile_service.ServiceInterface
|
||||||
settingsService: settings_service.ServiceInterface
|
|
||||||
accountsService: accounts_service.ServiceInterface
|
|
||||||
|
|
||||||
proc newController*(delegate: io_interface.AccessInterface, accountsService: accounts_service.ServiceInterface,
|
proc newController*(delegate: io_interface.AccessInterface,
|
||||||
settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface): Controller =
|
profileService: profile_service.ServiceInterface): Controller =
|
||||||
result = Controller()
|
result = Controller()
|
||||||
result.delegate = delegate
|
result.delegate = delegate
|
||||||
result.profileService = profileService
|
result.profileService = profileService
|
||||||
result.settingsService = settingsService
|
|
||||||
result.accountsService = accountsService
|
|
||||||
|
|
||||||
method delete*(self: Controller) =
|
method delete*(self: Controller) =
|
||||||
discard
|
discard
|
||||||
|
@ -31,41 +22,8 @@ method delete*(self: Controller) =
|
||||||
method init*(self: Controller) =
|
method init*(self: Controller) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
method getProfile*(self: Controller): item.Item =
|
method storeIdentityImage*(self: Controller, address: string, image: string, aX: int, aY: int, bX: int, bY: int): seq[Image] =
|
||||||
|
return self.profileService.storeIdentityImage(address, image, aX, aY, bX, bY)
|
||||||
|
|
||||||
var appearance = self.settingsService.getAppearance()
|
method deleteIdentityImage*(self: Controller, address: string) =
|
||||||
var messagesFromContactsOnly = self.settingsService.getMessagesFromContactsOnly()
|
self.profileService.deleteIdentityImage(address)
|
||||||
|
|
||||||
var identityImage = item.IdentityImage(thumbnail: singletonInstance.userProfile.getThumbnailImage(),
|
|
||||||
large: singletonInstance.userProfile.getLargeImage())
|
|
||||||
|
|
||||||
var item = item.Item(
|
|
||||||
id: singletonInstance.userProfile.getPubKey(),
|
|
||||||
alias: "",
|
|
||||||
username: singletonInstance.userProfile.getUsername(),
|
|
||||||
identicon: singletonInstance.userProfile.getIdenticon(),
|
|
||||||
address: singletonInstance.userProfile.getAddress(),
|
|
||||||
ensName: singletonInstance.userProfile.getEnsName(),
|
|
||||||
ensVerified: false,
|
|
||||||
localNickname: "",
|
|
||||||
messagesFromContactsOnly: messagesFromContactsOnly,
|
|
||||||
sendUserStatus: singletonInstance.userProfile.getUserStatus(),
|
|
||||||
currentUserStatus: 1, # This is still not in use. Read a comment in UserProfile.
|
|
||||||
identityImage: identityImage,
|
|
||||||
appearance: appearance,
|
|
||||||
added: false,
|
|
||||||
blocked: false,
|
|
||||||
hasAddedUs: false
|
|
||||||
)
|
|
||||||
|
|
||||||
return item
|
|
||||||
|
|
||||||
method storeIdentityImage*(self: Controller, address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage =
|
|
||||||
result = self.profileService.storeIdentityImage(address, image, aX, aY, bX, bY)
|
|
||||||
singletonInstance.userProfile.setThumbnailImage(result.thumbnail)
|
|
||||||
singletonInstance.userProfile.setLargeImage(result.large)
|
|
||||||
|
|
||||||
method deleteIdentityImage*(self: Controller, address: string): string =
|
|
||||||
result = self.profileService.deleteIdentityImage(address)
|
|
||||||
singletonInstance.userProfile.setThumbnailImage("")
|
|
||||||
singletonInstance.userProfile.setLargeImage("")
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import ../../../../../app_service/service/profile/service as profile_service
|
import ../../../../../app_service/service/profile/dto/profile as profile_dto
|
||||||
import ./item
|
|
||||||
import status/types/identity_image
|
|
||||||
|
|
||||||
type
|
type
|
||||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||||
|
@ -12,16 +10,9 @@ method delete*(self: AccessInterface) {.base.} =
|
||||||
method init*(self: AccessInterface) {.base.} =
|
method init*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method getProfile*(self: AccessInterface): Item {.base.} =
|
method storeIdentityImage*(self: AccessInterface, address: string, image: string, aX: int, aY: int, bX: int, bY: int):
|
||||||
|
seq[Image] {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method storeIdentityImage*(self: AccessInterface, address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage {.base.} =
|
method deleteIdentityImage*(self: AccessInterface, address: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method deleteIdentityImage*(self: AccessInterface, address: string): string {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
type
|
|
||||||
## Abstract class (concept) which must be implemented by object/s used in this
|
|
||||||
## module.
|
|
||||||
DelegateInterface* = concept c
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import status/types/identity_image
|
import NimQml
|
||||||
|
|
||||||
type
|
type
|
||||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||||
|
@ -13,11 +13,13 @@ method load*(self: AccessInterface) {.base.} =
|
||||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method storeIdentityImage*(self: AccessInterface, address: string, image: string, aX: int, aY: int, bX: int, bY: int):
|
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
|
||||||
identity_image.IdentityImage {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method deleteIdentityImage*(self: AccessInterface, address: string): string {.base.} =
|
method storeIdentityImage*(self: AccessInterface, imageUrl: string, aX: int, aY: int, bX: int, bY: int) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method deleteIdentityImage*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
# View Delegate Interface
|
# View Delegate Interface
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import strformat
|
|
||||||
|
|
||||||
type
|
|
||||||
IdentityImage* = ref object
|
|
||||||
thumbnail*: string
|
|
||||||
large*: string
|
|
||||||
|
|
||||||
type
|
|
||||||
Item* = object
|
|
||||||
id*, alias*, username*, identicon*, address*, ensName*, localNickname*: string
|
|
||||||
ensVerified*: bool
|
|
||||||
messagesFromContactsOnly*: bool
|
|
||||||
sendUserStatus*: bool
|
|
||||||
currentUserStatus*: int
|
|
||||||
identityImage*: IdentityImage
|
|
||||||
appearance*: int
|
|
||||||
added*: bool
|
|
||||||
blocked*: bool
|
|
||||||
hasAddedUs*: bool
|
|
||||||
|
|
||||||
proc `$`*(self: Item): string =
|
|
||||||
result = fmt"""ProfileDto(
|
|
||||||
username: {self.username},
|
|
||||||
identicon: {self.identicon},
|
|
||||||
messagesFromContactsOnly: {self.messagesFromContactsOnly}
|
|
||||||
)"""
|
|
|
@ -1,142 +0,0 @@
|
||||||
import NimQml
|
|
||||||
import chronicles
|
|
||||||
import std/wrapnils
|
|
||||||
|
|
||||||
import status/types/profile
|
|
||||||
|
|
||||||
import ./item as item
|
|
||||||
|
|
||||||
QtObject:
|
|
||||||
type Model* = ref object of QObject
|
|
||||||
username*: string
|
|
||||||
identicon*: string
|
|
||||||
address*: string
|
|
||||||
identityImage*: item.IdentityImage
|
|
||||||
pubKey*: string
|
|
||||||
appearance*: int
|
|
||||||
ensVerified*: bool
|
|
||||||
messagesFromContactsOnly*: bool
|
|
||||||
sendUserStatus*: bool
|
|
||||||
currentUserStatus*: int
|
|
||||||
|
|
||||||
proc setup(self: Model) =
|
|
||||||
self.QObject.setup
|
|
||||||
|
|
||||||
proc delete*(self: Model) =
|
|
||||||
self.QObject.delete
|
|
||||||
|
|
||||||
proc newModel*(): Model =
|
|
||||||
new(result, delete)
|
|
||||||
result = Model()
|
|
||||||
result.pubKey = ""
|
|
||||||
result.username = ""
|
|
||||||
result.identicon = ""
|
|
||||||
result.appearance = 0
|
|
||||||
result.identityImage = item.IdentityImage(thumbnail: "", large: "")
|
|
||||||
result.ensVerified = false
|
|
||||||
result.messagesFromContactsOnly = false
|
|
||||||
result.sendUserStatus = false
|
|
||||||
result.currentUserStatus = 0
|
|
||||||
result.setup
|
|
||||||
|
|
||||||
proc identityImageChanged*(self: Model) {.signal.}
|
|
||||||
proc sendUserStatusChanged*(self: Model) {.signal.}
|
|
||||||
proc currentUserStatusChanged*(self: Model) {.signal.}
|
|
||||||
proc appearanceChanged*(self: Model) {.signal.}
|
|
||||||
proc messagesFromContactsOnlyChanged*(self: Model) {.signal.}
|
|
||||||
|
|
||||||
proc setProfile*(self: Model, profile: item.Item) =
|
|
||||||
self.username = profile.username
|
|
||||||
self.identicon = profile.identicon
|
|
||||||
self.messagesFromContactsOnly = profile.messagesFromContactsOnly
|
|
||||||
self.appearance = profile.appearance
|
|
||||||
self.pubKey = profile.id
|
|
||||||
self.address = profile.address
|
|
||||||
self.ensVerified = profile.ensVerified
|
|
||||||
self.identityImage = item.IdentityImage(thumbnail: profile.identityImage.thumbnail, large: profile.identityImage.large)
|
|
||||||
self.sendUserStatus = profile.sendUserStatus
|
|
||||||
self.currentUserStatus = profile.currentUserStatus
|
|
||||||
|
|
||||||
proc username*(self: Model): string {.slot.} = result = self.username
|
|
||||||
|
|
||||||
QtProperty[string] username:
|
|
||||||
read = username
|
|
||||||
|
|
||||||
proc identicon*(self: Model): string {.slot.} = result = self.identicon
|
|
||||||
|
|
||||||
QtProperty[string] identicon:
|
|
||||||
read = identicon
|
|
||||||
|
|
||||||
proc pubKey*(self: Model): string {.slot.} = self.pubKey
|
|
||||||
|
|
||||||
QtProperty[string] pubKey:
|
|
||||||
read = pubKey
|
|
||||||
|
|
||||||
proc address*(self: Model): string {.slot.} = self.address
|
|
||||||
|
|
||||||
QtProperty[string] address:
|
|
||||||
read = address
|
|
||||||
|
|
||||||
proc ensVerified*(self: Model): bool {.slot.} = self.ensVerified
|
|
||||||
|
|
||||||
QtProperty[bool] ensVerified:
|
|
||||||
read = ensVerified
|
|
||||||
|
|
||||||
proc appearance*(self: Model): int {.slot.} = result = self.appearance
|
|
||||||
proc setAppearance*(self: Model, appearance: int) {.slot.} =
|
|
||||||
if self.appearance == appearance:
|
|
||||||
return
|
|
||||||
self.appearance = appearance
|
|
||||||
self.appearanceChanged()
|
|
||||||
|
|
||||||
QtProperty[int] appearance:
|
|
||||||
read = appearance
|
|
||||||
write = setAppearance
|
|
||||||
notify = appearanceChanged
|
|
||||||
|
|
||||||
proc messagesFromContactsOnly*(self: Model): bool {.slot.} = result = self.messagesFromContactsOnly
|
|
||||||
proc setMessagesFromContactsOnly*(self: Model, messagesFromContactsOnly: bool) {.slot.} =
|
|
||||||
if self.messagesFromContactsOnly == messagesFromContactsOnly:
|
|
||||||
return
|
|
||||||
self.messagesFromContactsOnly = messagesFromContactsOnly
|
|
||||||
self.messagesFromContactsOnlyChanged()
|
|
||||||
|
|
||||||
QtProperty[bool] messagesFromContactsOnly:
|
|
||||||
read = messagesFromContactsOnly
|
|
||||||
write = setMessagesFromContactsOnly
|
|
||||||
notify = messagesFromContactsOnlyChanged
|
|
||||||
|
|
||||||
proc setIdentityImage*(self: Model, identityImage: item.IdentityImage) =
|
|
||||||
self.identityImage = identityImage
|
|
||||||
self.identityImageChanged()
|
|
||||||
|
|
||||||
proc removeIdentityImage*(self: Model) =
|
|
||||||
self.identityImage = item.IdentityImage(thumbnail: "", large: "")
|
|
||||||
self.identityImageChanged()
|
|
||||||
|
|
||||||
proc thumbnailImage*(self: Model): string {.slot.} =
|
|
||||||
if (?.self.identityImage.thumbnail != ""):
|
|
||||||
result = self.identityImage.thumbnail
|
|
||||||
else:
|
|
||||||
result = self.identicon
|
|
||||||
|
|
||||||
QtProperty[string] thumbnailImage:
|
|
||||||
read = thumbnailImage
|
|
||||||
notify = identityImageChanged
|
|
||||||
|
|
||||||
proc largeImage*(self: Model): string {.slot.} =
|
|
||||||
if (?.self.identityImage.large != ""):
|
|
||||||
result = self.identityImage.large
|
|
||||||
else:
|
|
||||||
result = self.identicon
|
|
||||||
|
|
||||||
QtProperty[string] largeImage:
|
|
||||||
read = largeImage
|
|
||||||
notify = identityImageChanged
|
|
||||||
|
|
||||||
proc hasIdentityImage*(self: Model): bool {.slot.} =
|
|
||||||
result = (?.self.identityImage.thumbnail != "")
|
|
||||||
|
|
||||||
QtProperty[bool] hasIdentityImage:
|
|
||||||
read = hasIdentityImage
|
|
||||||
notify = identityImageChanged
|
|
|
@ -1,17 +1,16 @@
|
||||||
import NimQml, Tables
|
import NimQml, chronicles
|
||||||
|
|
||||||
import ./io_interface, ./view, ./controller, ./item
|
import ./io_interface, ./view, ./controller
|
||||||
import ../io_interface as delegate_interface
|
import ../io_interface as delegate_interface
|
||||||
import ../../../../global/global_singleton
|
import ../../../../global/global_singleton
|
||||||
|
|
||||||
import ../../../../../app_service/service/profile/service as profile_service
|
import ../../../../../app_service/service/profile/service_interface as profile_service
|
||||||
import ../../../../../app_service/service/accounts/service as accounts_service
|
|
||||||
import ../../../../../app_service/service/settings/service_interface as settings_service
|
|
||||||
|
|
||||||
import status/types/identity_image
|
|
||||||
|
|
||||||
export io_interface
|
export io_interface
|
||||||
|
|
||||||
|
logScope:
|
||||||
|
topics = "profile-section-profile-module"
|
||||||
|
|
||||||
type
|
type
|
||||||
Module* = ref object of io_interface.AccessInterface
|
Module* = ref object of io_interface.AccessInterface
|
||||||
delegate: delegate_interface.AccessInterface
|
delegate: delegate_interface.AccessInterface
|
||||||
|
@ -20,19 +19,19 @@ type
|
||||||
viewVariant: QVariant
|
viewVariant: QVariant
|
||||||
moduleLoaded: bool
|
moduleLoaded: bool
|
||||||
|
|
||||||
proc newModule*(delegate: delegate_interface.AccessInterface, accountsService: accounts_service.ServiceInterface,
|
proc newModule*(delegate: delegate_interface.AccessInterface,
|
||||||
settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface): Module =
|
profileService: profile_service.ServiceInterface): Module =
|
||||||
result = Module()
|
result = Module()
|
||||||
result.delegate = delegate
|
result.delegate = delegate
|
||||||
result.view = newView(result)
|
result.view = view.newView(result)
|
||||||
result.viewVariant = newQVariant(result.view)
|
result.viewVariant = newQVariant(result.view)
|
||||||
result.controller = controller.newController(result, accountsService, settingsService, profileService)
|
result.controller = controller.newController(result, profileService)
|
||||||
result.moduleLoaded = false
|
result.moduleLoaded = false
|
||||||
|
|
||||||
singletonInstance.engine.setRootContextProperty("profileModule", result.viewVariant)
|
|
||||||
|
|
||||||
method delete*(self: Module) =
|
method delete*(self: Module) =
|
||||||
self.view.delete
|
self.view.delete
|
||||||
|
self.viewVariant.delete
|
||||||
|
self.controller.delete
|
||||||
|
|
||||||
method load*(self: Module) =
|
method load*(self: Module) =
|
||||||
self.controller.init()
|
self.controller.init()
|
||||||
|
@ -41,15 +40,29 @@ method load*(self: Module) =
|
||||||
method isLoaded*(self: Module): bool =
|
method isLoaded*(self: Module): bool =
|
||||||
return self.moduleLoaded
|
return self.moduleLoaded
|
||||||
|
|
||||||
method viewDidLoad*(self: Module) =
|
method getModuleAsVariant*(self: Module): QVariant =
|
||||||
let profile = self.controller.getProfile()
|
return self.viewVariant
|
||||||
self.view.setProfile(profile)
|
|
||||||
|
|
||||||
|
method viewDidLoad*(self: Module) =
|
||||||
self.moduleLoaded = true
|
self.moduleLoaded = true
|
||||||
self.delegate.profileModuleDidLoad()
|
self.delegate.profileModuleDidLoad()
|
||||||
|
|
||||||
method storeIdentityImage*(self: Module, address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage =
|
method storeIdentityImage*(self: Module, imageUrl: string, aX: int, aY: int, bX: int, bY: int) =
|
||||||
self.controller.storeIdentityImage(address, image, aX, aY, bX, bY)
|
let address = singletonInstance.userProfile.getAddress()
|
||||||
|
let image = singletonInstance.utils.formatImagePath(imageUrl)
|
||||||
|
let storedImages = self.controller.storeIdentityImage(address, image, aX, aY, bX, bY)
|
||||||
|
if(storedImages.len == 0):
|
||||||
|
error "error: array of stored images is empty"
|
||||||
|
return
|
||||||
|
|
||||||
method deleteIdentityImage*(self: Module, address: string): string =
|
for img in storedImages:
|
||||||
|
if(img.imgType == "large"):
|
||||||
|
singletonInstance.userProfile.setLargeImage(img.uri)
|
||||||
|
elif(img.imgType == "thumbnail"):
|
||||||
|
singletonInstance.userProfile.setThumbnailImage(img.uri)
|
||||||
|
|
||||||
|
method deleteIdentityImage*(self: Module) =
|
||||||
|
let address = singletonInstance.userProfile.getAddress()
|
||||||
self.controller.deleteIdentityImage(address)
|
self.controller.deleteIdentityImage(address)
|
||||||
|
singletonInstance.userProfile.setLargeImage("")
|
||||||
|
singletonInstance.userProfile.setThumbnailImage("")
|
||||||
|
|
|
@ -1,71 +1,32 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
|
|
||||||
import ./item
|
|
||||||
import ./model
|
|
||||||
import ./io_interface
|
import ./io_interface
|
||||||
import status/profile as status_profile
|
|
||||||
import status/status
|
|
||||||
import ../../../../global/global_singleton
|
|
||||||
|
|
||||||
import status/types/[identity_image, profile]
|
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
View* = ref object of QObject
|
View* = ref object of QObject
|
||||||
delegate: io_interface.AccessInterface
|
delegate: io_interface.AccessInterface
|
||||||
model: Model
|
|
||||||
modelVariant: QVariant
|
|
||||||
|
|
||||||
proc delete*(self: View) =
|
proc delete*(self: View) =
|
||||||
self.model.delete
|
|
||||||
self.modelVariant.delete
|
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
|
||||||
proc newView*(delegate: io_interface.AccessInterface): View =
|
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.QObject.setup
|
result.QObject.setup
|
||||||
result.delegate = delegate
|
result.delegate = delegate
|
||||||
result.model = newModel()
|
|
||||||
result.modelVariant = newQVariant(result.model)
|
|
||||||
|
|
||||||
proc load*(self: View) =
|
proc load*(self: View) =
|
||||||
self.delegate.viewDidLoad()
|
self.delegate.viewDidLoad()
|
||||||
|
|
||||||
proc modelChanged*(self: View) {.signal.}
|
|
||||||
|
|
||||||
proc getModel*(self: View): QVariant {.slot.} =
|
|
||||||
return self.modelVariant
|
|
||||||
|
|
||||||
QtProperty[QVariant] model:
|
|
||||||
read = getModel
|
|
||||||
notify = modelChanged
|
|
||||||
|
|
||||||
proc setProfile*(self: View, profile: Item) =
|
|
||||||
self.model.setProfile(profile)
|
|
||||||
self.modelChanged()
|
|
||||||
|
|
||||||
proc upload*(self: View, imageUrl: string, aX: int, aY: int, bX: int, bY: int): string {.slot.} =
|
proc upload*(self: View, imageUrl: string, aX: int, aY: int, bX: int, bY: int): string {.slot.} =
|
||||||
var image = singletonInstance.utils.formatImagePath(imageUrl)
|
# var image = singletonInstance.utils.formatImagePath(imageUrl)
|
||||||
# FIXME the function to get the file size is messed up
|
# FIXME the function to get the file size is messed up
|
||||||
# var size = image_getFileSize(image)
|
# var size = image_getFileSize(image)
|
||||||
# TODO find a way to i18n this (maybe send just a code and then QML sets the right string)
|
# TODO find a way to i18n this (maybe send just a code and then QML sets the right string)
|
||||||
# return "Max file size is 20MB"
|
# return "Max file size is 20MB"
|
||||||
|
|
||||||
try:
|
self.delegate.storeIdentityImage(imageUrl, aX, aY, bX, bY)
|
||||||
# TODO add crop tool for the image
|
|
||||||
let identityImage = self.delegate.storeIdentityImage(self.model.address, image, aX, aY, bX, bY)
|
|
||||||
# TODO use only one type
|
|
||||||
let identityImageConverted = item.IdentityImage(
|
|
||||||
thumbnail: identityImage.thumbnail,
|
|
||||||
large: identityImage.thumbnail
|
|
||||||
)
|
|
||||||
self.model.setIdentityImage(identityImageConverted)
|
|
||||||
result = ""
|
|
||||||
except Exception as e:
|
|
||||||
echo "Error storing identity image", e.msg
|
|
||||||
result = "Error storing identity image: " & e.msg
|
|
||||||
|
|
||||||
proc remove*(self: View): string {.slot.} =
|
proc remove*(self: View): string {.slot.} =
|
||||||
result = self.delegate.deleteIdentityImage(self.model.address)
|
self.delegate.deleteIdentityImage()
|
||||||
if (result == ""):
|
|
||||||
self.model.removeIdentityImage()
|
|
|
@ -26,6 +26,11 @@ QtObject:
|
||||||
QtProperty[QVariant] languageModule:
|
QtProperty[QVariant] languageModule:
|
||||||
read = getLanguageModule
|
read = getLanguageModule
|
||||||
|
|
||||||
|
proc getProfileModule(self: View): QVariant {.slot.} =
|
||||||
|
return self.delegate.getProfileModule()
|
||||||
|
QtProperty[QVariant] profileModule:
|
||||||
|
read = getProfileModule
|
||||||
|
|
||||||
proc getAdvancedModule(self: View): QVariant {.slot.} =
|
proc getAdvancedModule(self: View): QVariant {.slot.} =
|
||||||
return self.delegate.getAdvancedModule()
|
return self.delegate.getAdvancedModule()
|
||||||
QtProperty[QVariant] advancedModule:
|
QtProperty[QVariant] advancedModule:
|
||||||
|
|
|
@ -24,6 +24,7 @@ proc first*(jArray: JsonNode, fieldName, id: string): JsonNode =
|
||||||
proc prettyEnsName*(ensName: string): string =
|
proc prettyEnsName*(ensName: string): string =
|
||||||
if ensName.endsWith(".eth"):
|
if ensName.endsWith(".eth"):
|
||||||
return "@" & ensName.split(".")[0]
|
return "@" & ensName.split(".")[0]
|
||||||
|
return ensName
|
||||||
|
|
||||||
const sep = when defined(windows): "\\" else: "/"
|
const sep = when defined(windows): "\\" else: "/"
|
||||||
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
{.used.}
|
|
||||||
|
|
||||||
import json, strformat
|
|
||||||
|
|
||||||
include ../../common/json_utils
|
|
||||||
|
|
||||||
type Dto* = ref object
|
|
||||||
username*: string
|
|
||||||
identicon*: string
|
|
||||||
largeImage*: string
|
|
||||||
thumbnailImage*: string
|
|
||||||
hasIdentityImage*: bool
|
|
||||||
messagesFromContactsOnly*: bool
|
|
||||||
|
|
||||||
proc `$`*(self: Dto): string =
|
|
||||||
result = fmt"""ProfileDto(
|
|
||||||
username: {self.username},
|
|
||||||
identicon: {self.identicon},
|
|
||||||
largeImage: {self.largeImage},
|
|
||||||
thumbnailImage: {self.thumbnailImage},
|
|
||||||
hasIdentityImage: {self.hasIdentityImage},
|
|
||||||
messagesFromContactsOnly: {self.messagesFromContactsOnly}
|
|
||||||
)"""
|
|
||||||
|
|
||||||
proc toDto*(jsonObj: JsonNode): Dto =
|
|
||||||
result = Dto()
|
|
||||||
|
|
||||||
discard jsonObj.getProp("username", result.username)
|
|
||||||
discard jsonObj.getProp("identicon", result.identicon)
|
|
||||||
discard jsonObj.getProp("largeImage", result.largeImage)
|
|
||||||
discard jsonObj.getProp("thumbnailImage", result.thumbnailImage)
|
|
||||||
discard jsonObj.getProp("hasIdentityImage", result.hasIdentityImage)
|
|
||||||
discard jsonObj.getProp("messagesFromContactsOnly", result.messagesFromContactsOnly)
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
{.used.}
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
include ../../../common/json_utils
|
||||||
|
|
||||||
|
type
|
||||||
|
Image* = object
|
||||||
|
keyUid*: string
|
||||||
|
imgType*: string
|
||||||
|
uri*: string
|
||||||
|
width: int
|
||||||
|
height: int
|
||||||
|
fileSize: int
|
||||||
|
resizeTarget: int
|
||||||
|
|
||||||
|
type ProfileDto* = object
|
||||||
|
images*: seq[Image]
|
||||||
|
|
||||||
|
proc toImage*(jsonObj: JsonNode): Image =
|
||||||
|
result = Image()
|
||||||
|
discard jsonObj.getProp("keyUid", result.keyUid)
|
||||||
|
discard jsonObj.getProp("type", result.imgType)
|
||||||
|
discard jsonObj.getProp("uri", result.uri)
|
||||||
|
discard jsonObj.getProp("width", result.width)
|
||||||
|
discard jsonObj.getProp("height", result.height)
|
||||||
|
discard jsonObj.getProp("fileSize", result.fileSize)
|
||||||
|
discard jsonObj.getProp("resizeTarget", result.resizeTarget)
|
||||||
|
|
||||||
|
proc toProfileDto*(jsonObj: JsonNode): ProfileDto =
|
||||||
|
result = ProfileDto()
|
||||||
|
|
||||||
|
var imagesObj: JsonNode
|
||||||
|
if(jsonObj.getProp("images", imagesObj) and imagesObj.kind == JArray):
|
||||||
|
for imgObj in imagesObj:
|
||||||
|
result.images.add(toImage(imgObj))
|
|
@ -1,7 +1,7 @@
|
||||||
import json, sequtils, chronicles
|
import json, chronicles
|
||||||
import status/statusgo_backend/accounts
|
|
||||||
|
|
||||||
import ./service_interface, ./dto
|
import ./service_interface
|
||||||
|
import status/statusgo_backend_new/accounts as status_accounts
|
||||||
|
|
||||||
export service_interface
|
export service_interface
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ logScope:
|
||||||
|
|
||||||
type
|
type
|
||||||
Service* = ref object of ServiceInterface
|
Service* = ref object of ServiceInterface
|
||||||
profile: Dto
|
|
||||||
|
|
||||||
method delete*(self: Service) =
|
method delete*(self: Service) =
|
||||||
discard
|
discard
|
||||||
|
@ -19,26 +18,25 @@ proc newService*(): Service =
|
||||||
result = Service()
|
result = Service()
|
||||||
|
|
||||||
method init*(self: Service) =
|
method init*(self: Service) =
|
||||||
try:
|
discard
|
||||||
self.profile = self.getProfile()
|
|
||||||
|
|
||||||
except Exception as e:
|
method storeIdentityImage*(self: Service, address: string, image: string, aX: int, aY: int, bX: int, bY: int): seq[Image] =
|
||||||
let errDesription = e.msg
|
try:
|
||||||
error "error: ", errDesription
|
let response = status_accounts.storeIdentityImage(address, image, aX, aY, bX, bY)
|
||||||
|
|
||||||
|
if(response.result.kind != JArray):
|
||||||
|
error "error: ", methodName="storeIdentityImage", errDesription = "response is not an array"
|
||||||
return
|
return
|
||||||
|
|
||||||
method getProfile*(self: Service): Dto =
|
for img in response.result:
|
||||||
return Dto(
|
result.add(toImage(img))
|
||||||
username: "test username",
|
|
||||||
identicon: "",
|
|
||||||
largeImage: "",
|
|
||||||
thumbnailImage: "",
|
|
||||||
hasIdentityImage: false,
|
|
||||||
messagesFromContactsOnly: false
|
|
||||||
)
|
|
||||||
|
|
||||||
method storeIdentityImage*(self: Service, address: string, image: string, aX: int, aY: int, bX: int, bY: int): IdentityImage =
|
except Exception as e:
|
||||||
storeIdentityImage(address, image, aX, aY, bX, bY)
|
error "error: ", methodName="storeIdentityImage", errName = e.name, errDesription = e.msg
|
||||||
|
|
||||||
method deleteIdentityImage*(self: Service, address: string): string =
|
method deleteIdentityImage*(self: Service, address: string) =
|
||||||
deleteIdentityImage(address)
|
try:
|
||||||
|
let response = status_accounts.deleteIdentityImage(address)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
error "error: ", methodName="deleteIdentityImage", errName = e.name, errDesription = e.msg
|
|
@ -1,10 +1,6 @@
|
||||||
import dto
|
import ./dto/profile as profile_dto
|
||||||
|
|
||||||
export dto
|
export profile_dto
|
||||||
|
|
||||||
import status/types/identity_image
|
|
||||||
|
|
||||||
export IdentityImage
|
|
||||||
|
|
||||||
type
|
type
|
||||||
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
||||||
|
@ -16,14 +12,9 @@ method delete*(self: ServiceInterface) {.base.} =
|
||||||
method init*(self: ServiceInterface) {.base.} =
|
method init*(self: ServiceInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method getProfile*(self: ServiceInterface): Dto {.base.} =
|
method storeIdentityImage*(self: ServiceInterface, address: string, image: string, aX: int, aY: int, bX: int, bY: int):
|
||||||
|
seq[Image] {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method storeIdentityImage*(self: ServiceInterface, address: string, image: string, aX: int, aY: int, bX: int, bY: int): IdentityImage {.base.} =
|
method deleteIdentityImage*(self: ServiceInterface, address: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method deleteIdentityImage*(self: ServiceInterface, address: string): string {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
# method getTokens*(self: ServiceInterface, chainId: int): seq[Dto] {.base.} =
|
|
||||||
# raise newException(ValueError, "No implementation available")
|
|
|
@ -12,6 +12,7 @@ const KEY_DAPPS_ADDRESS* = "dapps-address"
|
||||||
const KEY_EIP1581_ADDRESS* = "eip1581-address"
|
const KEY_EIP1581_ADDRESS* = "eip1581-address"
|
||||||
const KEY_INSTALLATION_ID* = "installation-id"
|
const KEY_INSTALLATION_ID* = "installation-id"
|
||||||
const KEY_PREFERRED_NAME* = "preferred-name"
|
const KEY_PREFERRED_NAME* = "preferred-name"
|
||||||
|
const KEY_ENS_USERNAMES* = "usernames"
|
||||||
const KEY_KEY_UID* = "key-uid"
|
const KEY_KEY_UID* = "key-uid"
|
||||||
const KEY_LATEST_DERIVED_PATH* = "latest-derived-path"
|
const KEY_LATEST_DERIVED_PATH* = "latest-derived-path"
|
||||||
const KEY_LINK_PREVIEW_REQUEST_ENABLED* = "link-preview-request-enabled"
|
const KEY_LINK_PREVIEW_REQUEST_ENABLED* = "link-preview-request-enabled"
|
||||||
|
@ -82,6 +83,7 @@ type
|
||||||
eip1581Address*: string
|
eip1581Address*: string
|
||||||
installationId*: string
|
installationId*: string
|
||||||
preferredName*: string
|
preferredName*: string
|
||||||
|
ensUsernames*: seq[string]
|
||||||
keyUid*: string
|
keyUid*: string
|
||||||
latestDerivedPath*: int
|
latestDerivedPath*: int
|
||||||
linkPreviewRequestEnabled*: bool
|
linkPreviewRequestEnabled*: bool
|
||||||
|
@ -222,6 +224,12 @@ proc toSettingsDto*(jsonObj: JsonNode): SettingsDto =
|
||||||
discard jsonObj.getProp(KEY_NODE_CONFIG, result.nodeConfig)
|
discard jsonObj.getProp(KEY_NODE_CONFIG, result.nodeConfig)
|
||||||
discard jsonObj.getProp(KEY_WAKU_BLOOM_FILTER_MODE, result.wakuBloomFilterMode)
|
discard jsonObj.getProp(KEY_WAKU_BLOOM_FILTER_MODE, result.wakuBloomFilterMode)
|
||||||
|
|
||||||
|
var usernamesArr: JsonNode
|
||||||
|
if(jsonObj.getProp(KEY_ENS_USERNAMES, usernamesArr)):
|
||||||
|
if(usernamesArr.kind == JArray):
|
||||||
|
for username in usernamesArr:
|
||||||
|
result.ensUsernames.add(username.getStr)
|
||||||
|
|
||||||
proc configToJsonNode*(config: Config): JsonNode =
|
proc configToJsonNode*(config: Config): JsonNode =
|
||||||
let configAsString = $$config
|
let configAsString = $$config
|
||||||
result = parseJson(configAsString)
|
result = parseJson(configAsString)
|
||||||
|
|
|
@ -108,6 +108,19 @@ method savePreferredName*(self: Service, value: string): bool =
|
||||||
method getPreferredName*(self: Service): string =
|
method getPreferredName*(self: Service): string =
|
||||||
return self.settings.preferredName
|
return self.settings.preferredName
|
||||||
|
|
||||||
|
method saveNewEnsUsername*(self: Service, username: string): bool =
|
||||||
|
var newEnsUsernames = self.settings.ensUsernames
|
||||||
|
newEnsUsernames.add(username)
|
||||||
|
let newEnsUsernamesAsJson = %* newEnsUsernames
|
||||||
|
|
||||||
|
if(self.saveSetting(KEY_ENS_USERNAMES, newEnsUsernamesAsJson)):
|
||||||
|
self.settings.ensUsernames = newEnsUsernames
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
method getEnsUsernames*(self: Service): seq[string] =
|
||||||
|
return self.settings.ensUsernames
|
||||||
|
|
||||||
method saveKeyUid*(self: Service, value: string): bool =
|
method saveKeyUid*(self: Service, value: string): bool =
|
||||||
if(self.saveSetting(KEY_KEY_UID, value)):
|
if(self.saveSetting(KEY_KEY_UID, value)):
|
||||||
self.settings.keyUid = value
|
self.settings.keyUid = value
|
||||||
|
|
|
@ -65,6 +65,12 @@ method savePreferredName*(self: ServiceInterface, value: string): bool {.base.}
|
||||||
method getPreferredName*(self: ServiceInterface): string {.base.} =
|
method getPreferredName*(self: ServiceInterface): string {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method saveNewEnsUsername*(self: ServiceInterface, username: string): bool {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method getEnsUsernames*(self: ServiceInterface): seq[string] {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method saveKeyUid*(self: ServiceInterface, value: string): bool {.base.} =
|
method saveKeyUid*(self: ServiceInterface, value: string): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ QtObject {
|
||||||
// property var walletModelInst: walletModel
|
// property var walletModelInst: walletModel
|
||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
// property var profileModelInst: profileModel
|
// property var profileModelInst: profileModel
|
||||||
property var profileModuleInst: profileModule
|
|
||||||
property var activityCenterModuleInst: activityCenterModule
|
property var activityCenterModuleInst: activityCenterModule
|
||||||
property var activityCenterList: activityCenterModuleInst.model
|
property var activityCenterList: activityCenterModuleInst.model
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,8 @@ Item {
|
||||||
BlockContactConfirmationDialog {
|
BlockContactConfirmationDialog {
|
||||||
id: blockContactConfirmationDialog
|
id: blockContactConfirmationDialog
|
||||||
onBlockButtonClicked: {
|
onBlockButtonClicked: {
|
||||||
root.store.profileModuleInst.blockContact(blockContactConfirmationDialog.contactAddress)
|
// Not Refactored Yet
|
||||||
|
// root.store.profileModuleInst.blockContact(blockContactConfirmationDialog.contactAddress)
|
||||||
root.store.activityCenterModuleInst.dismissActivityCenterNotification(model.id)
|
root.store.activityCenterModuleInst.dismissActivityCenterNotification(model.id)
|
||||||
blockContactConfirmationDialog.close()
|
blockContactConfirmationDialog.close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ StatusAppTwoPanelLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
MyProfileView {
|
MyProfileView {
|
||||||
store: profileView.store
|
profileStore: profileView.store.profileStore
|
||||||
profileContentWidth: _internal.profileContentWidth
|
profileContentWidth: _internal.profileContentWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import QtQuick 2.13
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property var profileModule
|
||||||
|
|
||||||
|
property string pubkey: userProfile.pubKey
|
||||||
|
property string name: userProfile.name // in case of ens returns pretty ens form
|
||||||
|
property string username: userProfile.username
|
||||||
|
property string ensName: userProfile.preferredName || userProfile.firstEnsName || userProfile.ensName
|
||||||
|
property string profileLargeImage: userProfile.largeImage
|
||||||
|
property string icon: userProfile.icon
|
||||||
|
property bool isIdenticon: userProfile.isIdenticon
|
||||||
|
|
||||||
|
|
||||||
|
function uploadImage(source, aX, aY, bX, bY) {
|
||||||
|
return root.profileModule.upload(source, aX, aY, bX, bY)
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeImage() {
|
||||||
|
return root.profileModule.remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
function getQrCodeSource(publicKey) {
|
||||||
|
return globalUtils.qrCode(publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyToClipboard(value) {
|
||||||
|
globalUtils.copyToClipboard(value)
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,36 +4,39 @@ import utils 1.0
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var profile: profileModule.model
|
|
||||||
property var contactsModuleInst: contactsModule
|
property var contactsModuleInst: contactsModule
|
||||||
property var aboutModuleInst: aboutModule
|
property var aboutModuleInst: aboutModule
|
||||||
property var mnemonicModuleInst: mnemonicModule
|
property var mnemonicModuleInst: mnemonicModule
|
||||||
|
|
||||||
property var profileModuleInst: profileSectionModule
|
property var profileSectionModuleInst: profileSectionModule
|
||||||
|
|
||||||
property AdvancedStore advancedStore: AdvancedStore {
|
property AdvancedStore advancedStore: AdvancedStore {
|
||||||
advancedModule: profileModuleInst.advancedModule
|
advancedModule: profileSectionModuleInst.advancedModule
|
||||||
}
|
}
|
||||||
|
|
||||||
property DevicesStore devicesStore: DevicesStore {
|
property DevicesStore devicesStore: DevicesStore {
|
||||||
devicesModule: profileModuleInst.devicesModule
|
devicesModule: profileSectionModuleInst.devicesModule
|
||||||
}
|
}
|
||||||
|
|
||||||
property SyncStore syncStore: SyncStore {
|
property SyncStore syncStore: SyncStore {
|
||||||
syncModule: profileModuleInst.syncModule
|
syncModule: profileSectionModuleInst.syncModule
|
||||||
}
|
}
|
||||||
|
|
||||||
property NotificationsStore notificationsStore: NotificationsStore {
|
property NotificationsStore notificationsStore: NotificationsStore {
|
||||||
notificationsModule: profileModuleInst.notificationsModule
|
notificationsModule: profileSectionModuleInst.notificationsModule
|
||||||
}
|
}
|
||||||
|
|
||||||
property LanguageStore languageStore: LanguageStore {
|
property LanguageStore languageStore: LanguageStore {
|
||||||
languageModule: profileModuleInst.languageModule
|
languageModule: profileSectionModuleInst.languageModule
|
||||||
}
|
}
|
||||||
|
|
||||||
property AppearanceStore appearanceStore: AppearanceStore {
|
property AppearanceStore appearanceStore: AppearanceStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property ProfileStore profileStore: ProfileStore {
|
||||||
|
profileModule: profileSectionModuleInst.profileModule
|
||||||
|
}
|
||||||
|
|
||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
// property var chatsModelInst: chatsModel
|
// property var chatsModelInst: chatsModel
|
||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
|
@ -58,18 +61,11 @@ QtObject {
|
||||||
property string ensRegisterAddress: "" //utilsModelInst.ensRegisterAddress
|
property string ensRegisterAddress: "" //utilsModelInst.ensRegisterAddress
|
||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
property string etherscanLink: "" //walletModelInst.utilsView.etherscanLink
|
property string etherscanLink: "" //walletModelInst.utilsView.etherscanLink
|
||||||
property string pubKey: profile.pubKey
|
|
||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
// property string preferredUsername: profileModelInst.ens.preferredUsername
|
// property string preferredUsername: userProfile.preferredName // was: profileModelInst.ens.preferredUsername
|
||||||
// property string firstEnsUsername: profileModelInst.ens.firstEnsUsername
|
// property string firstEnsUsername: userProfile.firstEnsName // was: profileModelInst.ens.firstEnsUsername
|
||||||
property string username: profile.username
|
|
||||||
property string identicon: profile.identicon
|
|
||||||
property string profileLargeImage: profile.largeImage
|
|
||||||
property string profileThumbnailImage: profile.thumbnailImage
|
|
||||||
|
|
||||||
property bool profileHasIdentityImage: profile.hasIdentityImage
|
|
||||||
property bool mnemonicBackedUp: mnemonicModuleInst.isBackedUp
|
property bool mnemonicBackedUp: mnemonicModuleInst.isBackedUp
|
||||||
property bool messagesFromContactsOnly: profile.messagesFromContactsOnly
|
property bool messagesFromContactsOnly: false //profile.messagesFromContactsOnly
|
||||||
|
|
||||||
property int profile_id: 0
|
property int profile_id: 0
|
||||||
property int contacts_id: 1
|
property int contacts_id: 1
|
||||||
|
@ -191,24 +187,6 @@ QtObject {
|
||||||
dappPermissionsModule.fetchDapps()
|
dappPermissionsModule.fetchDapps()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQrCodeSource(publicKey) {
|
|
||||||
// Not Refactored Yet
|
|
||||||
// return profileModelInst.qrCode(publicKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard(value) {
|
|
||||||
// Not Refactored Yet
|
|
||||||
// chatsModelInst.copyToClipboard(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
function uploadImage(source, aX, aY, bX, bY) {
|
|
||||||
return profileModule.upload(source, aX, aY, bX, bY)
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeImage() {
|
|
||||||
return profileModule.remove()
|
|
||||||
}
|
|
||||||
|
|
||||||
function lookupContact(value) {
|
function lookupContact(value) {
|
||||||
contactsModuleInst.lookupContact(value)
|
contactsModuleInst.lookupContact(value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,9 @@ import StatusQ.Controls 0.1
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var store
|
property var profileStore
|
||||||
property int profileContentWidth
|
|
||||||
|
|
||||||
property string ensName: store.preferredUsername || store.firstEnsUsername || ""
|
property int profileContentWidth
|
||||||
property string username: store.username
|
|
||||||
property string pubkey: store.pubKey
|
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
@ -31,13 +28,13 @@ Item {
|
||||||
Component {
|
Component {
|
||||||
id: changeProfileModalComponent
|
id: changeProfileModalComponent
|
||||||
ChangeProfilePicModal {
|
ChangeProfilePicModal {
|
||||||
largeImage: store.profileLargeImage
|
largeImage: !root.profileStore.isIdenticon? root.profileStore.profileLargeImage : root.profileStore.icon
|
||||||
hasIdentityImage: store.profileHasIdentityImage
|
hasIdentityImage: !root.profileStore.isIdenticon
|
||||||
onCropFinished: {
|
onCropFinished: {
|
||||||
uploadError = store.uploadImage(selectedImage, aX, aY, bX, bY)
|
uploadError = root.profileStore.uploadImage(selectedImage, aX, aY, bX, bY)
|
||||||
}
|
}
|
||||||
onRemoveImageButtonClicked: {
|
onRemoveImageButtonClicked: {
|
||||||
uploadError = store.removeImage()
|
uploadError = root.profileStore.removeImage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +60,7 @@ Item {
|
||||||
height: 64
|
height: 64
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: Style.current.border
|
border.color: Style.current.border
|
||||||
source: root.store.profileThumbnailImage
|
source: root.profileStore.icon
|
||||||
smooth: false
|
smooth: false
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
}
|
}
|
||||||
|
@ -92,7 +89,7 @@ Item {
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: profileName
|
id: profileName
|
||||||
text: root.ensName !== "" ? root.ensName : root.username
|
text: root.profileStore.name
|
||||||
anchors.left: profileImgContainer.right
|
anchors.left: profileImgContainer.right
|
||||||
anchors.leftMargin: Style.current.halfPadding
|
anchors.leftMargin: Style.current.halfPadding
|
||||||
anchors.top: profileImgContainer.top
|
anchors.top: profileImgContainer.top
|
||||||
|
@ -104,7 +101,7 @@ Item {
|
||||||
|
|
||||||
Address {
|
Address {
|
||||||
id: pubkeyText
|
id: pubkeyText
|
||||||
text: root.ensName !== "" ? root.username : root.pubkey
|
text: root.profileStore.ensName !== "" ? root.profileStore.username : root.profileStore.pubkey
|
||||||
anchors.bottom: profileImgContainer.bottom
|
anchors.bottom: profileImgContainer.bottom
|
||||||
anchors.left: profileName.left
|
anchors.left: profileName.left
|
||||||
anchors.bottomMargin: 4
|
anchors.bottomMargin: 4
|
||||||
|
@ -137,7 +134,7 @@ Item {
|
||||||
Image {
|
Image {
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
source: root.store.getQrCodeSource(pubkey)
|
source: root.profileStore.getQrCodeSource(root.profileStore.pubkey)
|
||||||
anchors.verticalCenterOffset: 20
|
anchors.verticalCenterOffset: 20
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
@ -156,12 +153,12 @@ Item {
|
||||||
|
|
||||||
StatusDescriptionListItem {
|
StatusDescriptionListItem {
|
||||||
title: qsTr("ENS username")
|
title: qsTr("ENS username")
|
||||||
subTitle: root.ensName
|
subTitle: root.profileStore.ensName
|
||||||
tooltip.text: qsTr("Copy to clipboard")
|
tooltip.text: qsTr("Copy to clipboard")
|
||||||
icon.name: "copy"
|
icon.name: "copy"
|
||||||
visible: !!root.ensName
|
visible: !!root.profileStore.ensName
|
||||||
iconButton.onClicked: {
|
iconButton.onClicked: {
|
||||||
root.store.copyToClipboard(root.ensName)
|
root.profileStore.copyToClipboard(root.profileStore.ensName)
|
||||||
tooltip.visible = !tooltip.visible
|
tooltip.visible = !tooltip.visible
|
||||||
}
|
}
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -169,14 +166,14 @@ Item {
|
||||||
|
|
||||||
StatusDescriptionListItem {
|
StatusDescriptionListItem {
|
||||||
title: qsTr("Chat key")
|
title: qsTr("Chat key")
|
||||||
subTitle: root.pubkey
|
subTitle: root.profileStore.pubkey
|
||||||
subTitleComponent.elide: Text.ElideMiddle
|
subTitleComponent.elide: Text.ElideMiddle
|
||||||
subTitleComponent.width: 320
|
subTitleComponent.width: 320
|
||||||
subTitleComponent.font.family: Theme.palette.monoFont.name
|
subTitleComponent.font.family: Theme.palette.monoFont.name
|
||||||
tooltip.text: qsTr("Copy to clipboard")
|
tooltip.text: qsTr("Copy to clipboard")
|
||||||
icon.name: "copy"
|
icon.name: "copy"
|
||||||
iconButton.onClicked: {
|
iconButton.onClicked: {
|
||||||
root.store.copyToClipboard(root.pubkey)
|
root.profileStore.copyToClipboard(root.profileStore.pubkey)
|
||||||
tooltip.visible = !tooltip.visible
|
tooltip.visible = !tooltip.visible
|
||||||
}
|
}
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -184,11 +181,11 @@ Item {
|
||||||
|
|
||||||
StatusDescriptionListItem {
|
StatusDescriptionListItem {
|
||||||
title: qsTr("Share Profile URL")
|
title: qsTr("Share Profile URL")
|
||||||
subTitle: `${Constants.userLinkPrefix}${root.ensName !== "" ? root.ensName : (root.pubkey.substring(0, 5) + "..." + root.pubkey.substring(root.pubkey.length - 5))}`
|
subTitle: `${Constants.userLinkPrefix}${root.profileStore.ensName !== "" ? root.profileStore.ensName : (root.profileStore.pubkey.substring(0, 5) + "..." + root.profileStore.pubkey.substring(root.profileStore.pubkey.length - 5))}`
|
||||||
tooltip.text: qsTr("Copy to clipboard")
|
tooltip.text: qsTr("Copy to clipboard")
|
||||||
icon.name: "copy"
|
icon.name: "copy"
|
||||||
iconButton.onClicked: {
|
iconButton.onClicked: {
|
||||||
root.store.copyToClipboard(Constants.userLinkPrefix + (root.ensName !== "" ? root.ensName : root.pubkey))
|
root.profileStore.copyToClipboard(Constants.userLinkPrefix + (root.profileStore.ensName !== "" ? root.profileStore.ensName : root.profileStore.pubkey))
|
||||||
tooltip.visible = !tooltip.visible
|
tooltip.visible = !tooltip.visible
|
||||||
}
|
}
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -9,7 +9,6 @@ QtObject {
|
||||||
readonly property ProfileStores.RootStore profileStore: ProfileStores.RootStore {}
|
readonly property ProfileStores.RootStore profileStore: ProfileStores.RootStore {}
|
||||||
|
|
||||||
property var mainModuleInst: mainModule
|
property var mainModuleInst: mainModule
|
||||||
property var profileModuleInst: profileModule
|
|
||||||
property var aboutModuleInst: aboutModule
|
property var aboutModuleInst: aboutModule
|
||||||
|
|
||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
|
|
Loading…
Reference in New Issue