fix: set display name issue (#4642)

This commit is contained in:
Mohsen 2024-02-01 19:13:41 +03:30 committed by GitHub
parent f31808d938
commit 9879b1ea77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 2 deletions

View File

@ -1 +1 @@
0.172.10
0.172.11

View File

@ -320,6 +320,11 @@ func (db *Database) SaveAccount(account Account) error {
return db.StoreIdentityImages(account.KeyUID, account.Images, false)
}
func (db *Database) UpdateDisplayName(keyUID string, displayName string) error {
_, err := db.db.Exec("UPDATE accounts SET name = ? WHERE keyUid = ?", displayName, keyUID)
return err
}
func (db *Database) UpdateAccount(account Account) error {
colorHash, err := json.Marshal(account.ColorHash)
if err != nil {

View File

@ -67,7 +67,7 @@ func (m *Messenger) SetDisplayName(displayName string) error {
}
m.account.Name = displayName
err = m.multiAccounts.SaveAccount(*m.account)
err = m.multiAccounts.UpdateDisplayName(m.account.KeyUID, displayName)
if err != nil {
return err
}

View File

@ -42,6 +42,9 @@ func (s *MessengerProfileDisplayNameHandlerSuite) TestDisplayNameChange() {
s.Require().NoError(err)
s.Require().True(accounts.SameKeypairs(profileKp, dbProfileKp))
// save account will create the account
err = s.m.multiAccounts.SaveAccount(*s.m.account)
s.Require().NoError(err)
// set new display name
err = s.m.SetDisplayName(testDisplayName)
s.Require().NoError(err)