feat(secret): store updated account info

no point in keeping the initial display_name and avatar if the user has updated them
This commit is contained in:
Evangelos Paterakis 2023-02-26 08:21:08 +02:00
parent bb38f7ff0e
commit 8c908a05a7
No known key found for this signature in database
GPG Key ID: FE5185F095BFC8C9
1 changed files with 16 additions and 12 deletions

View File

@ -35,19 +35,23 @@ public class Tooth.SecretAccountStore : AccountStore {
secrets.foreach (item => {
var account = secret_to_account (item);
if (account != null) {
new Request.GET (@"/api/v1/accounts/$(account.id)")
.with_account (account)
.then ((sess, msg) => {
var node = network.parse_node (msg);
var acc = API.Account.from (node);
if (account != null && account.id != "") {
new Request.GET (@"/api/v1/accounts/$(account.id)")
.with_account (account)
.then ((sess, msg) => {
var node = network.parse_node (msg);
var acc = API.Account.from (node);
account.display_name = acc.display_name;
account.avatar = acc.avatar;
})
.exec ();
saved.add (account);
account.added ();
if (account.display_name != acc.display_name || account.avatar != acc.avatar) {
account.display_name = acc.display_name;
account.avatar = acc.avatar;
account_to_secret (account);
}
})
.exec ();
saved.add (account);
account.added ();
}
});
changed (saved);