toggle switch to control if status should be broadcasted or not

This commit is contained in:
Richard Ramos 2021-07-11 18:40:06 -04:00 committed by Iuri Matias
parent 6849091460
commit 7aaca9ec4d
7 changed files with 43 additions and 5 deletions

View File

@ -40,10 +40,12 @@ proc init*(self: ProfileController, account: Account) =
let network = self.status.settings.getSetting[:string](Setting.Networks_CurrentNetwork, DEFAULT_NETWORK_NAME)
let appearance = self.status.settings.getSetting[:int](Setting.Appearance)
let messagesFromContactsOnly = self.status.settings.getSetting[:bool](Setting.MessagesFromContactsOnly)
let sendUserStatus = self.status.settings.getSetting[:bool](Setting.SendUserStatus)
profile.appearance = appearance
profile.id = pubKey
profile.address = account.keyUid
profile.messagesFromContactsOnly = messagesFromContactsOnly
profile.sendUserStatus = sendUserStatus
let identityImage = self.status.profile.getIdentityImage(profile.address)

View File

@ -179,3 +179,10 @@ 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)

View File

@ -14,6 +14,7 @@ QtObject:
appearance*: int
ensVerified*: bool
messagesFromContactsOnly*: bool
sendUserStatus*: bool
proc setup(self: ProfileInfoView) =
self.QObject.setup
@ -31,6 +32,7 @@ QtObject:
result.identityImage = IdentityImage()
result.ensVerified = false
result.messagesFromContactsOnly = false
result.sendUserStatus = false
result.setup
proc profileChanged*(self: ProfileInfoView) {.signal.}
@ -46,6 +48,7 @@ QtObject:
self.ensVerified = profile.ensVerified
self.identityImage = profile.identityImage
self.messagesFromContactsOnly = profile.messagesFromContactsOnly
self.sendUserStatus = profile.sendUserStatus
self.profileChanged()
proc setIdentityImage*(self: ProfileInfoView, identityImage: IdentityImage) =
@ -130,3 +133,14 @@ QtObject:
QtProperty[bool] ensVerified:
read = ensVerified
notify = profileChanged
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.profileChanged()
QtProperty[bool] sendUserStatus:
read = sendUserStatus
write = setSendUserStatus
notify = profileChanged

View File

@ -5,6 +5,7 @@ type Profile* = ref object
id*, alias*, username*, identicon*, address*, ensName*, localNickname*: string
ensVerified*: bool
messagesFromContactsOnly*: bool
sendUserStatus*: bool
identityImage*: IdentityImage
appearance*: int
systemTags*: seq[string]

View File

@ -197,6 +197,7 @@ type
VisibleTokens = "wallet/visible-tokens"
PinnedMailservers = "pinned-mailservers"
WakuBloomFilterMode = "waku-bloom-filter-mode"
SendUserStatus = "send-status-updates?"
UpstreamConfig* = ref object
enabled* {.serializedFieldName("Enabled").}: bool

View File

@ -42,8 +42,7 @@ Rectangle {
property string nickname: appMain.getUserNickname(model.pubKey)
publicKey: model.pubKey
name: chatsModel.communities.activeCommunity.memberLastSeen(model.pubKey) + "--" + ( !model.userName.endsWith(".eth") && !!nickname ?
nickname : Utils.removeStatusEns(model.userName))
name: !model.userName.endsWith(".eth") && !!nickname ? nickname : Utils.removeStatusEns(model.userName)
identicon: model.identicon
lastSeen: chatsModel.communities.activeCommunity.memberLastSeen(model.pubKey)
currentTime: svRoot.currentTime

View File

@ -126,8 +126,8 @@ Item {
}
StatusSettingsLineButton {
//% "Online users"
text: qsTrId("online-users")
id: onlineUsers
text: qsTr("Online users")
isSwitch: true
switchChecked: appSettings.showOnlineUsers
onClicked: {
@ -135,6 +135,20 @@ Item {
}
}
Loader {
active: onlineUsers.switchChecked
anchors.left: parent.left
anchors.right: parent.right
sourceComponent: StatusSettingsLineButton {
text: qsTr("Broadcast user status")
isSwitch: true
switchChecked: profileModel.profile.sendUserStatus
onClicked: function (checked) {
profileModel.setSendUserStatus(checked)
}
}
}
StatusSectionHeadline {
text: qsTr("Bloom filter level")
topPadding: Style.current.bigPadding
@ -212,7 +226,7 @@ Item {
}
}
}
}
}
// StatusSettingsLineButton {
// //% "Node Management"