parent
c0450f0580
commit
484748314f
|
@ -309,7 +309,8 @@ proc buildAndRegisterUserProfile(self: AppController) =
|
|||
|
||||
let pubKey = self.settingsService.getPubKey()
|
||||
let sendUserStatus = self.settingsService.getSendUserStatus()
|
||||
let currentUserStatus = self.settingsService.getCurrentUserStatus()
|
||||
## This is still not in use. Read a comment in UserProfile.
|
||||
## let currentUserStatus = self.settingsService.getCurrentUserStatus()
|
||||
let obj = self.settingsService.getIdentityImage(loggedInAccount.keyUid)
|
||||
|
||||
singletonInstance.userProfile.setFixedData(loggedInAccount.name, loggedInAccount.keyUid, loggedInAccount.identicon,
|
||||
|
@ -317,7 +318,6 @@ proc buildAndRegisterUserProfile(self: AppController) =
|
|||
singletonInstance.userProfile.setEnsName("") # in this moment we don't know ens name
|
||||
singletonInstance.userProfile.setThumbnailImage(obj.thumbnail)
|
||||
singletonInstance.userProfile.setLargeImage(obj.large)
|
||||
singletonInstance.userProfile.setSendUserStatus(sendUserStatus)
|
||||
singletonInstance.userProfile.setCurrentUserStatus(currentUserStatus)
|
||||
singletonInstance.userProfile.setUserStatus(sendUserStatus)
|
||||
|
||||
singletonInstance.engine.setRootContextProperty("userProfile", self.userProfileVariant)
|
||||
|
|
|
@ -11,7 +11,7 @@ QtObject:
|
|||
ensName: string
|
||||
thumbnailImage: string
|
||||
largeImage: string
|
||||
sendUserStatus: bool
|
||||
userStatus: bool
|
||||
currentUserStatus: int
|
||||
|
||||
proc setup(self: UserProfile) =
|
||||
|
@ -112,35 +112,49 @@ QtObject:
|
|||
notify = largeImageChanged
|
||||
|
||||
|
||||
proc sendUserStatusChanged*(self: UserProfile) {.signal.}
|
||||
proc userStatusChanged*(self: UserProfile) {.signal.}
|
||||
|
||||
proc getSendUserStatus*(self: UserProfile): bool {.slot.} =
|
||||
self.sendUserStatus
|
||||
proc getUserStatus*(self: UserProfile): bool {.slot.} =
|
||||
self.userStatus
|
||||
|
||||
# this is not a slot
|
||||
proc setSendUserStatus*(self: UserProfile, status: bool) =
|
||||
if(self.sendUserStatus == status):
|
||||
proc setUserStatus*(self: UserProfile, status: bool) =
|
||||
if(self.userStatus == status):
|
||||
return
|
||||
self.sendUserStatus = status
|
||||
self.sendUserStatusChanged()
|
||||
self.userStatus = status
|
||||
self.userStatusChanged()
|
||||
|
||||
QtProperty[bool] sendUserStatus:
|
||||
read = getSendUserStatus
|
||||
notify = sendUserStatusChanged
|
||||
QtProperty[bool] userStatus:
|
||||
read = getUserStatus
|
||||
notify = userStatusChanged
|
||||
|
||||
|
||||
proc currentUserStatusChanged*(self: UserProfile) {.signal.}
|
||||
## This is still not in use.
|
||||
## Once we decide to differ more than Online/Offline statuses we shouldn't use this code below,
|
||||
## but update current `userStatus` which is a bool to something like the code bellow (`currentUserStatus`).
|
||||
##
|
||||
## Proposal - some statuses we may have:
|
||||
## type
|
||||
## OnlineStatus* {.pure.} = enum
|
||||
## Online = 0
|
||||
## Idle
|
||||
## DoNotDisturb
|
||||
## Invisible
|
||||
## Offline
|
||||
##
|
||||
##
|
||||
## proc currentUserStatusChanged*(self: UserProfile) {.signal.}
|
||||
|
||||
proc getCurrentUserStatus*(self: UserProfile): int {.slot.} =
|
||||
self.currentUserStatus
|
||||
## proc getCurrentUserStatus*(self: UserProfile): int {.slot.} =
|
||||
## self.currentUserStatus
|
||||
|
||||
# this is not a slot
|
||||
proc setCurrentUserStatus*(self: UserProfile, status: int) =
|
||||
if(self.currentUserStatus == status):
|
||||
return
|
||||
self.currentUserStatus = status
|
||||
self.currentUserStatusChanged()
|
||||
## # this is not a slot
|
||||
## proc setCurrentUserStatus*(self: UserProfile, status: int) =
|
||||
## if(self.currentUserStatus == status):
|
||||
## return
|
||||
## self.currentUserStatus = status
|
||||
## self.currentUserStatusChanged()
|
||||
|
||||
QtProperty[int] currentUserStatus:
|
||||
read = getCurrentUserStatus
|
||||
notify = currentUserStatusChanged
|
||||
## QtProperty[int] currentUserStatus:
|
||||
## read = getCurrentUserStatus
|
||||
## notify = currentUserStatusChanged
|
||||
|
|
|
@ -2,6 +2,7 @@ import controller_interface
|
|||
import io_interface
|
||||
import ../../core/global_singleton
|
||||
|
||||
import ../../../app_service/service/settings/service_interface as settings_service
|
||||
import ../../../app_service/service/keychain/service as keychain_service
|
||||
import ../../../app_service/service/accounts/service_interface as accounts_service
|
||||
import ../../../app_service/service/community/service as community_service
|
||||
|
@ -15,12 +16,14 @@ type
|
|||
Controller* = ref object of controller_interface.AccessInterface
|
||||
delegate: io_interface.AccessInterface
|
||||
events: EventEmitter
|
||||
settingsService: settings_service.ServiceInterface
|
||||
keychainService: keychain_service.Service
|
||||
accountsService: accounts_service.ServiceInterface
|
||||
communityService: community_service.ServiceInterface
|
||||
|
||||
proc newController*(delegate: io_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
settingsService: settings_service.ServiceInterface,
|
||||
keychainService: keychain_service.Service,
|
||||
accountsService: accounts_service.ServiceInterface,
|
||||
communityService: community_service.ServiceInterface):
|
||||
|
@ -28,6 +31,7 @@ proc newController*(delegate: io_interface.AccessInterface,
|
|||
result = Controller()
|
||||
result.delegate = delegate
|
||||
result.events = events
|
||||
result.settingsService = settingsService
|
||||
result.keychainService = keychainService
|
||||
result.accountsService = accountsService
|
||||
result.communityService = communityService
|
||||
|
@ -75,4 +79,8 @@ method storePassword*(self: Controller, password: string) =
|
|||
if (value != LS_VALUE_STORE or account.name.len == 0):
|
||||
return
|
||||
|
||||
self.keychainService.storePassword(account.name, password)
|
||||
self.keychainService.storePassword(account.name, password)
|
||||
|
||||
method setUserStatus*(self: Controller, status: bool) =
|
||||
self.settingsService.setSendUserStatus(status)
|
||||
singletonInstance.userProfile.setUserStatus(status)
|
||||
|
|
|
@ -19,3 +19,6 @@ method checkForStoringPassword*(self: AccessInterface) {.base.} =
|
|||
|
||||
method storePassword*(self: AccessInterface, password: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setUserStatus*(self: AccessInterface, status: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -83,8 +83,8 @@ proc newModule*[T](
|
|||
result.delegate = delegate
|
||||
result.view = view.newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController(result, events, keychainService,
|
||||
accountsService, communityService)
|
||||
result.controller = controller.newController(result, events, settingsService, keychainService, accountsService,
|
||||
communityService)
|
||||
result.moduleLoaded = false
|
||||
|
||||
# Submodules
|
||||
|
@ -207,4 +207,7 @@ method emitStoringPasswordError*[T](self: Module[T], errorDescription: string) =
|
|||
self.view.emitStoringPasswordError(errorDescription)
|
||||
|
||||
method emitStoringPasswordSuccess*[T](self: Module[T]) =
|
||||
self.view.emitStoringPasswordSuccess()
|
||||
self.view.emitStoringPasswordSuccess()
|
||||
|
||||
method setUserStatus*[T](self: Module[T], status: bool) =
|
||||
self.controller.setUserStatus(status)
|
|
@ -2,4 +2,7 @@ method viewDidLoad*(self: AccessInterface) {.base.} =
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method storePassword*(self: AccessInterface, password: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setUserStatus*(self: AccessInterface, status: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -49,8 +49,8 @@ method getProfile*[T](self: Controller[T]): item.Item =
|
|||
ensVerified: false,
|
||||
localNickname: "",
|
||||
messagesFromContactsOnly: messagesFromContactsOnly,
|
||||
sendUserStatus: singletonInstance.userProfile.getSendUserStatus(),
|
||||
currentUserStatus: singletonInstance.userProfile.getCurrentUserStatus(),
|
||||
sendUserStatus: singletonInstance.userProfile.getUserStatus(),
|
||||
currentUserStatus: 1, # This is still not in use. Read a comment in UserProfile.
|
||||
identityImage: identityImage,
|
||||
appearance: appearance,
|
||||
added: false,
|
||||
|
|
|
@ -139,28 +139,4 @@ QtObject:
|
|||
|
||||
QtProperty[bool] hasIdentityImage:
|
||||
read = hasIdentityImage
|
||||
notify = identityImageChanged
|
||||
|
||||
proc sendUserStatus*(self: Model): bool {.slot.} = result = self.sendUserStatus
|
||||
proc setSendUserStatus*(self: Model, sendUserStatus: bool) {.slot.} =
|
||||
if self.sendUserStatus == sendUserStatus:
|
||||
return
|
||||
self.sendUserStatus = sendUserStatus
|
||||
self.sendUserStatusChanged()
|
||||
|
||||
QtProperty[bool] sendUserStatus:
|
||||
read = sendUserStatus
|
||||
write = setSendUserStatus
|
||||
notify = sendUserStatusChanged
|
||||
|
||||
proc currentUserStatus*(self: Model): int {.slot.} = result = self.currentUserStatus
|
||||
proc setCurrentUserStatus*(self: Model, currentUserStatus: int) {.slot.} =
|
||||
if self.currentUserStatus == currentUserStatus:
|
||||
return
|
||||
self.currentUserStatus = currentUserStatus
|
||||
self.currentUserStatusChanged()
|
||||
|
||||
QtProperty[int] currentUserStatus:
|
||||
read = currentUserStatus
|
||||
write = setCurrentUserStatus
|
||||
notify = currentUserStatusChanged
|
||||
notify = identityImageChanged
|
|
@ -53,4 +53,7 @@ QtObject:
|
|||
proc storingPasswordSuccess*(self:View) {.signal.}
|
||||
|
||||
proc emitStoringPasswordSuccess*(self: View) =
|
||||
self.storingPasswordSuccess()
|
||||
self.storingPasswordSuccess()
|
||||
|
||||
proc setUserStatus*(self: View, status: bool) {.slot.} =
|
||||
self.delegate.setUserStatus(status)
|
||||
|
|
|
@ -185,12 +185,6 @@ QtObject:
|
|||
QtProperty[QVariant] mutedChats:
|
||||
read = getMutedChats
|
||||
|
||||
proc setSendUserStatus*(self: ProfileView, sendUserStatus: bool) {.slot.} =
|
||||
if (sendUserStatus == self.profile.sendUserStatus):
|
||||
return
|
||||
self.profile.setSendUserStatus(sendUserStatus)
|
||||
self.status.saveSetting(Setting.SendUserStatus, sendUserStatus)
|
||||
|
||||
proc showOSNotification*(self: ProfileView, title: string, message: string,
|
||||
notificationType: int, useOSNotifications: bool) {.slot.} =
|
||||
|
||||
|
|
|
@ -33,12 +33,9 @@ QtObject:
|
|||
result.identityImage = IdentityImage()
|
||||
result.ensVerified = false
|
||||
result.messagesFromContactsOnly = false
|
||||
result.sendUserStatus = false
|
||||
result.currentUserStatus = 0
|
||||
result.setup
|
||||
|
||||
proc identityImageChanged*(self: ProfileInfoView) {.signal.}
|
||||
proc sendUserStatusChanged*(self: ProfileInfoView) {.signal.}
|
||||
proc currentUserStatusChanged*(self: ProfileInfoView) {.signal.}
|
||||
proc appearanceChanged*(self: ProfileInfoView) {.signal.}
|
||||
proc messagesFromContactsOnlyChanged*(self: ProfileInfoView) {.signal.}
|
||||
|
@ -52,8 +49,6 @@ QtObject:
|
|||
self.ensVerified = profile.ensVerified
|
||||
self.identityImage = profile.identityImage
|
||||
self.messagesFromContactsOnly = profile.messagesFromContactsOnly
|
||||
self.sendUserStatus = profile.sendUserStatus
|
||||
self.currentUserStatus = profile.currentUserStatus
|
||||
|
||||
proc username*(self: ProfileInfoView): string {.slot.} = result = self.username
|
||||
|
||||
|
@ -139,26 +134,3 @@ QtObject:
|
|||
read = hasIdentityImage
|
||||
notify = identityImageChanged
|
||||
|
||||
proc sendUserStatus*(self: ProfileInfoView): bool {.slot.} = result = self.sendUserStatus
|
||||
proc setSendUserStatus*(self: ProfileInfoView, sendUserStatus: bool) {.slot.} =
|
||||
if self.sendUserStatus == sendUserStatus:
|
||||
return
|
||||
self.sendUserStatus = sendUserStatus
|
||||
self.sendUserStatusChanged()
|
||||
|
||||
QtProperty[bool] sendUserStatus:
|
||||
read = sendUserStatus
|
||||
write = setSendUserStatus
|
||||
notify = sendUserStatusChanged
|
||||
|
||||
proc currentUserStatus*(self: ProfileInfoView): int {.slot.} = result = self.currentUserStatus
|
||||
proc setCurrentUserStatus*(self: ProfileInfoView, currentUserStatus: int) {.slot.} =
|
||||
if self.currentUserStatus == currentUserStatus:
|
||||
return
|
||||
self.currentUserStatus = currentUserStatus
|
||||
self.currentUserStatusChanged()
|
||||
|
||||
QtProperty[int] currentUserStatus:
|
||||
read = currentUserStatus
|
||||
write = setCurrentUserStatus
|
||||
notify = currentUserStatusChanged
|
||||
|
|
|
@ -54,6 +54,10 @@ method getMessagesFromContactsOnly*(self: Service): bool =
|
|||
method getSendUserStatus*(self: Service): bool =
|
||||
return status_go_settings.getSetting[bool](Setting.SendUserStatus)
|
||||
|
||||
method setSendUserStatus*(self: Service, value: bool) =
|
||||
# this will be done in a proper way in `base_bc`, so far this is just a fix
|
||||
discard status_go_settings.saveSetting(Setting.SendUserStatus, value)
|
||||
|
||||
method getCurrentUserStatus*(self: Service): int =
|
||||
let userStatus = status_go_settings.getSetting[JsonNode](Setting.CurrentUserStatus)
|
||||
return userStatus{"statusType"}.getInt()
|
||||
|
|
|
@ -33,6 +33,9 @@ method getMessagesFromContactsOnly*(self: ServiceInterface): bool {.base.} =
|
|||
method getSendUserStatus*(self: ServiceInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setSendUserStatus*(self: ServiceInterface, value: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getCurrentUserStatus*(self: ServiceInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ StatusAppThreePanelLayout {
|
|||
community: root.rootStore.chatsModelInst.communities.activeCommunity
|
||||
currentUserName: Utils.removeStatusEns(root.rootStore.profileModelInst.ens.preferredUsername
|
||||
|| root.rootStore.profileModelInst.profile.username)
|
||||
currentUserOnline: root.rootStore.profileModelInst.profile.sendUserStatus
|
||||
currentUserOnline: root.store.userProfileInst.userStatus
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ QtObject {
|
|||
property var walletModelInst: walletModel
|
||||
property var profileModelInst: profileModel
|
||||
property var profileModuleInst: profileModule
|
||||
property var userProfileInst: userProfile
|
||||
|
||||
property bool isDebugEnabled: profileSectionModule.isDebugEnabled
|
||||
|
||||
|
|
|
@ -2,12 +2,17 @@ import QtQuick 2.13
|
|||
|
||||
QtObject {
|
||||
id: root
|
||||
property var mainModuleInst: mainModule
|
||||
property var profileModuleInst: profileModule
|
||||
|
||||
property var chatsModelInst: chatsModel
|
||||
property var walletModelInst: walletModel
|
||||
property var userProfileInst: userProfile
|
||||
|
||||
property var accounts: walletSectionAccounts.model
|
||||
property var currentAccount: walletSectionCurrent
|
||||
property var profileModelInst: profileModel
|
||||
|
||||
property var assets: walletSectionAccountTokens.model
|
||||
property MessageStore messageStore: MessageStore { }
|
||||
|
||||
|
|
|
@ -361,19 +361,18 @@ Item {
|
|||
badge.implicitHeight: 15
|
||||
badge.implicitWidth: 15
|
||||
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusAppNavBar.backgroundColor
|
||||
badge.color: {
|
||||
return userProfile.sendUserStatus ? Style.current.green : Style.current.midGrey
|
||||
/*
|
||||
// Use this code once support for custom user status is added
|
||||
switch(userProfile.currentUserStatus){
|
||||
case Constants.statusType_Online:
|
||||
return Style.current.green;
|
||||
case Constants.statusType_DoNotDisturb:
|
||||
return Style.current.red;
|
||||
default:
|
||||
return Style.current.midGrey;
|
||||
}*/
|
||||
}
|
||||
/*
|
||||
//This is still not in use. Read a comment for `currentUserStatus` in UserProfile on the nim side.
|
||||
// Use this code once support for custom user status is added
|
||||
switch(userProfile.currentUserStatus){
|
||||
case Constants.statusType_Online:
|
||||
return Style.current.green;
|
||||
case Constants.statusType_DoNotDisturb:
|
||||
return Style.current.red;
|
||||
default:
|
||||
return Style.current.midGrey;
|
||||
}*/
|
||||
badge.color: appMain.rootStore.userProfileInst.userStatus ? Style.current.green : Style.current.midGrey
|
||||
badge.border.width: 3
|
||||
onClicked: {
|
||||
userStatusContextMenu.opened ?
|
||||
|
|
|
@ -35,7 +35,7 @@ PopupMenu {
|
|||
}
|
||||
StyledText {
|
||||
id: username
|
||||
text: Utils.removeStatusEns(profileModel.ens.preferredUsername || userProfile.username)
|
||||
text: Utils.removeStatusEns(root.store.profileModelInst.ens.preferredUsername || root.store.userProfileInst.username)
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 3
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
@ -71,7 +71,7 @@ PopupMenu {
|
|||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
openProfilePopup(userProfile.username, userProfile.pubKey, userProfile.thumbnailImage);
|
||||
openProfilePopup(root.store.userProfileInst.username, root.store.userProfileInst.pubKey, root.store.userProfileInst.thumbnailImage)
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
|
@ -86,10 +86,10 @@ PopupMenu {
|
|||
Action {
|
||||
text: qsTr("Online")
|
||||
onTriggered: {
|
||||
if (userProfile.sendUserStatus != true) {
|
||||
root.store.profileModelInst.profile.setSendUserStatus(true)
|
||||
if (!root.store.userProfileInst.sendUserStatus) {
|
||||
root.store.mainModuleInst.setUserStatus(true)
|
||||
}
|
||||
root.close()
|
||||
root.close();
|
||||
}
|
||||
icon.color: Style.current.green
|
||||
icon.source: Style.svg("online")
|
||||
|
@ -100,10 +100,10 @@ PopupMenu {
|
|||
Action {
|
||||
text: qsTr("Offline")
|
||||
onTriggered: {
|
||||
if (userProfile.sendUserStatus != false) {
|
||||
root.store.profileModelInst.profile.setSendUserStatus(false)
|
||||
if (root.store.userProfileInst.userStatus) {
|
||||
root.store.mainModuleInst.setUserStatus(false)
|
||||
}
|
||||
root.close()
|
||||
root.close();
|
||||
}
|
||||
|
||||
icon.color: Style.current.midGrey
|
||||
|
|
Loading…
Reference in New Issue