mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 21:26:50 +00:00
GODT-1325: Add "already logged in" notification
This commit is contained in:
@ -26,6 +26,7 @@ ColumnLayout {
|
||||
id: root
|
||||
|
||||
property var user
|
||||
property var userIndex
|
||||
property var backend
|
||||
|
||||
spacing : 5
|
||||
@ -250,7 +251,25 @@ ColumnLayout {
|
||||
id: loginFinishedIndex
|
||||
colorScheme: root.colorScheme
|
||||
label: "Index:"
|
||||
text: "0"
|
||||
text: root.userIndex
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Button {
|
||||
colorScheme: root.colorScheme
|
||||
text: "Already logged in"
|
||||
|
||||
onClicked: {
|
||||
root.backend.loginAlreadyLoggedIn(0+loginAlreadyLoggedInIndex.text)
|
||||
user.resetLoginRequests()
|
||||
}
|
||||
}
|
||||
TextField {
|
||||
id: loginAlreadyLoggedInIndex
|
||||
colorScheme: root.colorScheme
|
||||
label: "Index:"
|
||||
text: root.userIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -436,6 +436,7 @@ Window {
|
||||
colorScheme: root.colorScheme
|
||||
backend: root
|
||||
user: ((root.usersTest.count > usersListView.currentIndex) && usersListView.currentIndex != -1) ? root.usersTest.get(usersListView.currentIndex) : undefined
|
||||
userIndex: usersListView.currentIndex - 1 // -1 because 0 index is fake user
|
||||
}
|
||||
}
|
||||
|
||||
@ -671,6 +672,7 @@ Window {
|
||||
signal login2PasswordError(string errorMsg)
|
||||
signal login2PasswordErrorAbort(string errorMsg)
|
||||
signal loginFinished(int index)
|
||||
signal loginAlreadyLoggedIn(int index)
|
||||
|
||||
signal internetOff()
|
||||
signal internetOn()
|
||||
@ -849,6 +851,9 @@ Window {
|
||||
onLoginFinished: {
|
||||
console.debug("<- loginFinished", index)
|
||||
}
|
||||
onLoginAlreadyLoggedIn: {
|
||||
console.debug("<- loginAlreadyLoggedIn", index)
|
||||
}
|
||||
|
||||
onInternetOff: {
|
||||
console.debug("<- internetOff")
|
||||
|
||||
@ -377,6 +377,7 @@ Item {
|
||||
target: root.backend
|
||||
|
||||
onLoginFinished: rightContent.showAccount(index)
|
||||
onLoginAlreadyLoggedIn: rightContent.showAccount(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,6 +57,7 @@ QtObject {
|
||||
root.updateIsLatestVersion,
|
||||
root.loginConnectionError,
|
||||
root.onlyPaidUsers,
|
||||
root.alreadyLoggedIn,
|
||||
root.enableBeta,
|
||||
root.bugReportSendSuccess,
|
||||
root.bugReportSendError,
|
||||
@ -414,6 +415,29 @@ QtObject {
|
||||
]
|
||||
}
|
||||
|
||||
property Notification alreadyLoggedIn: Notification {
|
||||
text: qsTr("This account is already signed it.")
|
||||
icon: "./icons/ic-exclamation-circle-filled.svg"
|
||||
type: Notification.NotificationType.Info
|
||||
group: Notifications.Group.Configuration
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onLoginAlreadyLoggedIn: {
|
||||
root.alreadyLoggedIn.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("OK")
|
||||
onTriggered: {
|
||||
root.alreadyLoggedIn.active = false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// Bug reports
|
||||
property Notification bugReportSendSuccess: Notification {
|
||||
text: qsTr("Thank you for the report. We'll get back to you as soon as we can.")
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//go:build build_qt
|
||||
// +build build_qt
|
||||
|
||||
package qt
|
||||
@ -145,6 +146,7 @@ func (f *FrontendQt) finishLogin() {
|
||||
defer f.eventListener.Remove(events.UserChangeDone, done)
|
||||
|
||||
user, err := f.bridge.FinishLogin(f.authClient, f.auth, f.password)
|
||||
|
||||
if err != nil && err != users.ErrUserAlreadyConnected {
|
||||
f.log.WithError(err).Errorf("Finish login failed")
|
||||
f.qml.Login2PasswordErrorAbort(err.Error())
|
||||
@ -158,8 +160,12 @@ func (f *FrontendQt) finishLogin() {
|
||||
|
||||
index := f.qml.Users().indexByID(user.ID())
|
||||
f.log.WithField("index", index).Debug("Login finished")
|
||||
|
||||
defer f.qml.LoginFinished(index)
|
||||
|
||||
if err == users.ErrUserAlreadyConnected {
|
||||
f.log.WithError(err).Error("User already logged in")
|
||||
f.qml.LoginAlreadyLoggedIn(index)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FrontendQt) waitForUserChangeDone(done <-chan string, userID string) {
|
||||
|
||||
@ -65,6 +65,7 @@ type QMLBackend struct {
|
||||
_ func(errorMsg string) `signal:"login2PasswordError"`
|
||||
_ func(errorMsg string) `signal:"login2PasswordErrorAbort"`
|
||||
_ func(index int) `signal:"loginFinished"`
|
||||
_ func(index int) `signal:"loginAlreadyLoggedIn"`
|
||||
|
||||
_ func() `signal:"internetOff"`
|
||||
_ func() `signal:"internetOn"`
|
||||
|
||||
Reference in New Issue
Block a user