1
0

GODT-1549: Add notification when address list changes.

This commit is contained in:
Jakub
2022-05-11 09:47:09 +02:00
parent 62499a5630
commit 415d08b411
4 changed files with 76 additions and 20 deletions

View File

@ -80,13 +80,13 @@ Popup {
} }
switch (root.notification.type) { switch (root.notification.type) {
case Notification.NotificationType.Info: case Notification.NotificationType.Info:
return root.colorScheme.signal_info return root.colorScheme.signal_info
case Notification.NotificationType.Success: case Notification.NotificationType.Success:
return root.colorScheme.signal_success return root.colorScheme.signal_success
case Notification.NotificationType.Warning: case Notification.NotificationType.Warning:
return root.colorScheme.signal_warning return root.colorScheme.signal_warning
case Notification.NotificationType.Danger: case Notification.NotificationType.Danger:
return root.colorScheme.signal_danger return root.colorScheme.signal_danger
} }
} }
@ -118,13 +118,13 @@ Popup {
} }
switch (root.notification.type) { switch (root.notification.type) {
case Notification.NotificationType.Info: case Notification.NotificationType.Info:
return "./icons/ic-info-circle-filled.svg" return "./icons/ic-info-circle-filled.svg"
case Notification.NotificationType.Success: case Notification.NotificationType.Success:
return "./icons/ic-info-circle-filled.svg" return "./icons/ic-info-circle-filled.svg"
case Notification.NotificationType.Warning: case Notification.NotificationType.Warning:
return "./icons/ic-exclamation-circle-filled.svg" return "./icons/ic-exclamation-circle-filled.svg"
case Notification.NotificationType.Danger: case Notification.NotificationType.Danger:
return "./icons/ic-exclamation-circle-filled.svg" return "./icons/ic-exclamation-circle-filled.svg"
} }
} }
@ -134,6 +134,7 @@ Popup {
colorScheme: root.colorScheme colorScheme: root.colorScheme
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.leftMargin: 16
color: root.colorScheme.text_invert color: root.colorScheme.text_invert
text: root.notification ? root.notification.description : "" text: root.notification ? root.notification.description : ""
@ -152,13 +153,13 @@ Popup {
} }
switch (root.notification.type) { switch (root.notification.type) {
case Notification.NotificationType.Info: case Notification.NotificationType.Info:
return root.colorScheme.signal_info_active return root.colorScheme.signal_info_active
case Notification.NotificationType.Success: case Notification.NotificationType.Success:
return root.colorScheme.signal_success_active return root.colorScheme.signal_success_active
case Notification.NotificationType.Warning: case Notification.NotificationType.Warning:
return root.colorScheme.signal_warning_active return root.colorScheme.signal_warning_active
case Notification.NotificationType.Danger: case Notification.NotificationType.Danger:
return root.colorScheme.signal_danger_active return root.colorScheme.signal_danger_active
} }
} }
@ -190,22 +191,22 @@ Popup {
var active var active
switch (root.notification.type) { switch (root.notification.type) {
case Notification.NotificationType.Info: case Notification.NotificationType.Info:
norm = root.colorScheme.signal_info norm = root.colorScheme.signal_info
hover = root.colorScheme.signal_info_hover hover = root.colorScheme.signal_info_hover
active = root.colorScheme.signal_info_active active = root.colorScheme.signal_info_active
break; break;
case Notification.NotificationType.Success: case Notification.NotificationType.Success:
norm = root.colorScheme.signal_success norm = root.colorScheme.signal_success
hover = root.colorScheme.signal_success_hover hover = root.colorScheme.signal_success_hover
active = root.colorScheme.signal_success_active active = root.colorScheme.signal_success_active
break; break;
case Notification.NotificationType.Warning: case Notification.NotificationType.Warning:
norm = root.colorScheme.signal_warning norm = root.colorScheme.signal_warning
hover = root.colorScheme.signal_warning_hover hover = root.colorScheme.signal_warning_hover
active = root.colorScheme.signal_warning_active active = root.colorScheme.signal_warning_active
break; break;
case Notification.NotificationType.Danger: case Notification.NotificationType.Danger:
norm = root.colorScheme.signal_danger norm = root.colorScheme.signal_danger
hover = root.colorScheme.signal_danger_hover hover = root.colorScheme.signal_danger_hover
active = root.colorScheme.signal_danger_active active = root.colorScheme.signal_danger_active

View File

@ -551,7 +551,12 @@ Window {
root.reportBugFinished() root.reportBugFinished()
root.bugReportSendSuccess() root.bugReportSendSuccess()
} }
} }
}
ColumnLayout {
spacing: 5
Button { Button {
text: "Bug report send error" text: "Bug report send error"
@ -609,6 +614,22 @@ Window {
root.notifyRebuildKeychain() root.notifyRebuildKeychain()
} }
} }
Button {
text: "Address changed"
colorScheme: root.colorScheme
onClicked: {
root.addressChanged("p@v.el")
}
}
Button {
text: "Address changed + Logout"
colorScheme: root.colorScheme
onClicked: {
root.addressChangedLogout("p@v.el")
}
}
} }
} }

View File

@ -74,7 +74,8 @@ QtObject {
root.resetBridge, root.resetBridge,
root.deleteAccount, root.deleteAccount,
root.noKeychain, root.noKeychain,
root.rebuildKeychain root.rebuildKeychain,
root.addressChanged
] ]
// Connection // Connection
@ -940,4 +941,37 @@ QtObject {
} }
] ]
} }
property Notification addressChanged: Notification {
title: qsTr("Address list changes")
description: qsTr("The address list for your account has changed. You might need to reconfigure your email client.")
brief: description
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration
Connections {
target: root.backend
onAddressChanged: {
root.addressChanged.description = qsTr("The address list for your account %1 has changed. You might need to reconfigure your email client.").arg(address)
root.addressChanged.active = true
}
onAddressChangedLogout: {
root.addressChanged.description = qsTr("The address list for your account %1 has changed. You have to reconfigure your email client.").arg(address)
root.addressChanged.active = true
}
}
action: [
Action {
text: qsTr("OK")
onTriggered: {
root.addressChanged.active = false
}
}
]
}
} }

View File

@ -375,7 +375,7 @@ func (loop *eventLoop) processAddresses(log *logrus.Entry, addressEvents []*pmap
for _, addressEvent := range addressEvents { for _, addressEvent := range addressEvents {
switch addressEvent.Action { switch addressEvent.Action {
case pmapi.EventCreate: case pmapi.EventCreate:
log.WithField("email", addressEvent.Address.Email).Debug("Address was created") log.WithField("email", addressEvent.Address.Email).Info("Address was created")
loop.listener.Emit(bridgeEvents.AddressChangedEvent, loop.user.GetPrimaryAddress()) loop.listener.Emit(bridgeEvents.AddressChangedEvent, loop.user.GetPrimaryAddress())
case pmapi.EventUpdate: case pmapi.EventUpdate:
@ -386,7 +386,7 @@ func (loop *eventLoop) processAddresses(log *logrus.Entry, addressEvents []*pmap
} }
email := oldAddress.Email email := oldAddress.Email
log.WithField("email", email).Debug("Address was updated") log.WithField("email", email).Info("Address was updated")
if addressEvent.Address.Receive != oldAddress.Receive { if addressEvent.Address.Receive != oldAddress.Receive {
loop.listener.Emit(bridgeEvents.AddressChangedLogoutEvent, email) loop.listener.Emit(bridgeEvents.AddressChangedLogoutEvent, email)
} }
@ -399,7 +399,7 @@ func (loop *eventLoop) processAddresses(log *logrus.Entry, addressEvents []*pmap
} }
email := oldAddress.Email email := oldAddress.Email
log.WithField("email", email).Debug("Address was deleted") log.WithField("email", email).Info("Address was deleted")
loop.user.CloseConnection(email) loop.user.CloseConnection(email)
loop.listener.Emit(bridgeEvents.AddressChangedLogoutEvent, email) loop.listener.Emit(bridgeEvents.AddressChangedLogoutEvent, email)
case pmapi.EventUpdateFlags: case pmapi.EventUpdateFlags: