Skip to content

Commit ea82f85

Browse files
noeliaSDjrainville
authored andcommitted
feat(Privacy&Notifications): Added UI only status news setting to privacy and notification views
- Created new flag into `PrivacyStore`: `isStatusNewsViaRSSEnabled `. It MUST be connected to the corresponding backend property. - Created new property `notificationsSettings` into `NotificationsStore` and replaced the direct call to the `appSettings` backend property from `NotificationsView`. Now it uses the store as a bridge. - Added the needed UI components in `PrivacyAndSecurityView` + `NotificationsView` to configure the needed Status News related settings. TODO: Backend connections not ready here. Part of #17795
1 parent 8b41793 commit ea82f85

File tree

5 files changed

+85
-36
lines changed

5 files changed

+85
-36
lines changed

ui/app/AppLayouts/Profile/ProfileLayout.qml

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ StatusSectionLayout {
352352
implicitWidth: parent.width
353353
implicitHeight: parent.height
354354

355+
privacyStore: root.store.privacyStore
355356
notificationsStore: root.store.notificationsStore
356357
sectionTitle: settingsEntriesModel.getNameForSubsection(Constants.settingsSubsection.notifications)
357358
contentWidth: d.contentWidth
@@ -518,12 +519,15 @@ StatusSectionLayout {
518519
active: false
519520
asynchronous: true
520521
sourceComponent: PrivacyAndSecurityView {
522+
isStatusNewsViaRSSEnabled: root.store.privacyStore.isStatusNewsViaRSSEnabled
521523
isCentralizedMetricsEnabled: root.isCentralizedMetricsEnabled
522524
implicitWidth: parent.width
523525
implicitHeight: parent.height
524526

525527
sectionTitle: settingsEntriesModel.getNameForSubsection(Constants.settingsSubsection.privacyAndSecurity)
526528
contentWidth: d.contentWidth
529+
530+
onIsStatusNewsViaRSSEnabledChanged: root.store.privacyStore.isStatusNewsViaRSSEnabled = isStatusNewsViaRSSEnabled
527531
}
528532
}
529533
}

ui/app/AppLayouts/Profile/stores/NotificationsStore.qml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ QtObject {
55
id: root
66

77
property var notificationsModule
8+
property var notificationsSettings: appSettings /*TODO: Add appSettings.notifSettingStatusNews notifiable property in the backend*/
89

910
property var exemptionsModel: notificationsModule.exemptionsModel
1011

ui/app/AppLayouts/Profile/stores/PrivacyStore.qml

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ QtObject {
1010
property bool mnemonicBackedUp: privacyModule.mnemonicBackedUp
1111
readonly property string keyUid: userProfile.keyUid
1212

13+
// The following properties wrap Privacy and Security View related properties:
14+
property bool isStatusNewsViaRSSEnabled: true /*TODO: Connect it to the backend corresponding property*/
15+
16+
onIsStatusNewsViaRSSEnabledChanged: console.warn("TODO: Connect it to the backend corresponding setting: " + isStatusNewsViaRSSEnabled)
17+
1318
function changePassword(password, newPassword) {
1419
root.privacyModule.changePassword(password, newPassword)
1520
}

ui/app/AppLayouts/Profile/views/NotificationsView.qml

+63-36
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ SettingsContentBase {
2121
id: root
2222

2323
property NotificationsStore notificationsStore
24+
property PrivacyStore privacyStore
25+
26+
QtObject {
27+
id: d
28+
29+
readonly property var notificationsSettings: root.notificationsStore.notificationsSettings
30+
}
2431

2532
Component.onCompleted: root.notificationsStore.loadExemptions()
2633

@@ -189,9 +196,9 @@ SettingsContentBase {
189196
components: [
190197
StatusSwitch {
191198
id: allowNotifSwitch
192-
checked: appSettings.notifSettingAllowNotifications
199+
checked: d.notificationsSettings.notifSettingAllowNotifications
193200
onClicked: {
194-
appSettings.notifSettingAllowNotifications = !appSettings.notifSettingAllowNotifications
201+
d.notificationsSettings.notifSettingAllowNotifications = !d.notificationsSettings.notifSettingAllowNotifications
195202
}
196203
}
197204
]
@@ -213,10 +220,10 @@ SettingsContentBase {
213220
title: qsTr("1:1 Chats")
214221
components: [
215222
NotificationSelect {
216-
selected: appSettings.notifSettingOneToOneChats
217-
onSendAlertsClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.sendAlertsValue
218-
onDeliverQuietlyClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.deliverQuietlyValue
219-
onTurnOffClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.turnOffValue
223+
selected: d.notificationsSettings.notifSettingOneToOneChats
224+
onSendAlertsClicked: d.notificationsSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.sendAlertsValue
225+
onDeliverQuietlyClicked: d.notificationsSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.deliverQuietlyValue
226+
onTurnOffClicked: d.notificationsSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.turnOffValue
220227
}
221228
]
222229
}
@@ -226,10 +233,10 @@ SettingsContentBase {
226233
title: qsTr("Group Chats")
227234
components: [
228235
NotificationSelect {
229-
selected: appSettings.notifSettingGroupChats
230-
onSendAlertsClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.sendAlertsValue
231-
onDeliverQuietlyClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.deliverQuietlyValue
232-
onTurnOffClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.turnOffValue
236+
selected: d.notificationsSettings.notifSettingGroupChats
237+
onSendAlertsClicked: d.notificationsSettings.notifSettingGroupChats = Constants.settingsSection.notifications.sendAlertsValue
238+
onDeliverQuietlyClicked: d.notificationsSettings.notifSettingGroupChats = Constants.settingsSection.notifications.deliverQuietlyValue
239+
onTurnOffClicked: d.notificationsSettings.notifSettingGroupChats = Constants.settingsSection.notifications.turnOffValue
233240
}
234241
]
235242
}
@@ -240,10 +247,10 @@ SettingsContentBase {
240247
tertiaryTitle: qsTr("Messages containing @%1").arg(userProfile.name)
241248
components: [
242249
NotificationSelect {
243-
selected: appSettings.notifSettingPersonalMentions
244-
onSendAlertsClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.sendAlertsValue
245-
onDeliverQuietlyClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
246-
onTurnOffClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.turnOffValue
250+
selected: d.notificationsSettings.notifSettingPersonalMentions
251+
onSendAlertsClicked: d.notificationsSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.sendAlertsValue
252+
onDeliverQuietlyClicked: d.notificationsSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
253+
onTurnOffClicked: d.notificationsSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.turnOffValue
247254
}
248255
]
249256
}
@@ -254,10 +261,10 @@ SettingsContentBase {
254261
tertiaryTitle: qsTr("Messages containing @everyone")
255262
components: [
256263
NotificationSelect {
257-
selected: appSettings.notifSettingGlobalMentions
258-
onSendAlertsClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.sendAlertsValue
259-
onDeliverQuietlyClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
260-
onTurnOffClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.turnOffValue
264+
selected: d.notificationsSettings.notifSettingGlobalMentions
265+
onSendAlertsClicked: d.notificationsSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.sendAlertsValue
266+
onDeliverQuietlyClicked: d.notificationsSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
267+
onTurnOffClicked: d.notificationsSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.turnOffValue
261268
}
262269
]
263270
}
@@ -267,10 +274,10 @@ SettingsContentBase {
267274
title: qsTr("All Messages")
268275
components: [
269276
NotificationSelect {
270-
selected: appSettings.notifSettingAllMessages
271-
onSendAlertsClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.sendAlertsValue
272-
onDeliverQuietlyClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.deliverQuietlyValue
273-
onTurnOffClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.turnOffValue
277+
selected: d.notificationsSettings.notifSettingAllMessages
278+
onSendAlertsClicked: d.notificationsSettings.notifSettingAllMessages = Constants.settingsSection.notifications.sendAlertsValue
279+
onDeliverQuietlyClicked: d.notificationsSettings.notifSettingAllMessages = Constants.settingsSection.notifications.deliverQuietlyValue
280+
onTurnOffClicked: d.notificationsSettings.notifSettingAllMessages = Constants.settingsSection.notifications.turnOffValue
274281
}
275282
]
276283
}
@@ -288,10 +295,30 @@ SettingsContentBase {
288295
title: qsTr("Contact Requests")
289296
components: [
290297
NotificationSelect {
291-
selected: appSettings.notifSettingContactRequests
292-
onSendAlertsClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.sendAlertsValue
293-
onDeliverQuietlyClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.deliverQuietlyValue
294-
onTurnOffClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.turnOffValue
298+
selected: d.notificationsSettings.notifSettingContactRequests
299+
onSendAlertsClicked: d.notificationsSettings.notifSettingContactRequests = Constants.settingsSection.notifications.sendAlertsValue
300+
onDeliverQuietlyClicked: d.notificationsSettings.notifSettingContactRequests = Constants.settingsSection.notifications.deliverQuietlyValue
301+
onTurnOffClicked: d.notificationsSettings.notifSettingContactRequests = Constants.settingsSection.notifications.turnOffValue
302+
}
303+
]
304+
}
305+
306+
StatusListItem {
307+
Layout.preferredWidth: root.contentWidth
308+
title: qsTr("Status News")
309+
components: [
310+
StatusButton {
311+
visible: !root.privacyStore.isStatusNewsViaRSSEnabled
312+
text: qsTr("Enable RSS")
313+
314+
onClicked: root.privacyStore.isStatusNewsViaRSSEnabled = true
315+
},
316+
NotificationSelect {
317+
visible: root.privacyStore.isStatusNewsViaRSSEnabled
318+
selected: d.notificationsSettings.notifSettingStatusNews
319+
onSendAlertsClicked: d.notificationsSettings.notifSettingStatusNews = Constants.settingsSection.notifications.sendAlertsValue
320+
onDeliverQuietlyClicked: d.notificationsSettings.notifSettingStatusNews = Constants.settingsSection.notifications.deliverQuietlyValue
321+
onTurnOffClicked: d.notificationsSettings.notifSettingStatusNews = Constants.settingsSection.notifications.turnOffValue
295322
}
296323
]
297324
}
@@ -317,10 +344,10 @@ SettingsContentBase {
317344
notificationTitle: "Vitalik Buterin"
318345
notificationMessage: qsTr("Hi there! So EIP-1559 will defini...")
319346
buttonGroup: messageSetting
320-
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameAndMessage
347+
checked: d.notificationsSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameAndMessage
321348
onRadioCheckedChanged: {
322349
if (checked) {
323-
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameAndMessage
350+
d.notificationsSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameAndMessage
324351
}
325352
}
326353
}
@@ -332,10 +359,10 @@ SettingsContentBase {
332359
notificationTitle: "Vitalik Buterin"
333360
notificationMessage: qsTr("You have a new message")
334361
buttonGroup: messageSetting
335-
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameOnly
362+
checked: d.notificationsSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameOnly
336363
onRadioCheckedChanged: {
337364
if (checked) {
338-
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameOnly
365+
d.notificationsSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameOnly
339366
}
340367
}
341368
}
@@ -347,10 +374,10 @@ SettingsContentBase {
347374
notificationTitle: "Status"
348375
notificationMessage: qsTr("You have a new message")
349376
buttonGroup: messageSetting
350-
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewAnonymous
377+
checked: d.notificationsSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewAnonymous
351378
onRadioCheckedChanged: {
352379
if (checked) {
353-
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewAnonymous
380+
d.notificationsSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewAnonymous
354381
}
355382
}
356383
}
@@ -361,9 +388,9 @@ SettingsContentBase {
361388
components: [
362389
StatusSwitch {
363390
id: soundSwitch
364-
checked: appSettings.notificationSoundsEnabled
391+
checked: d.notificationsSettings.notificationSoundsEnabled
365392
onClicked: {
366-
appSettings.notificationSoundsEnabled = !appSettings.notificationSoundsEnabled
393+
d.notificationsSettings.notificationSoundsEnabled = !d.notificationsSettings.notificationSoundsEnabled
367394
}
368395
}
369396
]
@@ -397,11 +424,11 @@ SettingsContentBase {
397424
stepSize: 1
398425

399426
onValueChanged: {
400-
appSettings.volume = value
427+
d.notificationsSettings.volume = value
401428
}
402429

403430
Component.onCompleted: {
404-
value = appSettings.volume
431+
value = d.notificationsSettings.volume
405432
volumeSlider.valueChanged.connect(() => {
406433
// play a sound preview, but not on startup
407434
Global.playNotificationSound()

ui/app/AppLayouts/Profile/views/PrivacyAndSecurityView.qml

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import StatusQ.Controls 0.1
1010
SettingsContentBase {
1111
id: root
1212

13+
property alias isStatusNewsViaRSSEnabled: statusNewsSwitch.checked
1314
required property bool isCentralizedMetricsEnabled
1415

1516
function refreshSwitch() {
@@ -22,6 +23,17 @@ SettingsContentBase {
2223
}
2324

2425
ColumnLayout {
26+
StatusListItem {
27+
Layout.preferredWidth: root.contentWidth
28+
title: qsTr("Receive Status News via RSS")
29+
subTitle: qsTr("Fetches news from external sites which may expose your IP")
30+
components: [
31+
StatusSwitch {
32+
id: statusNewsSwitch
33+
}
34+
]
35+
onClicked: statusNewsSwitch.checked = !statusNewsSwitch.checked
36+
}
2537
StatusListItem {
2638
Layout.preferredWidth: root.contentWidth
2739
title: qsTr("Share usage data with Status")

0 commit comments

Comments
 (0)