Skip to content

Commit

Permalink
client-web: refresh users on contact-list load
Browse files Browse the repository at this point in the history
  • Loading branch information
franzos committed Sep 22, 2023
1 parent 48d4af4 commit 00fda31
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/web/src/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ export class NWorker {
};
postMessage(msg);
}

await this.requestInformation(
{
source: "users",
idsOrKeys: contacts.map((c) => c.key),
},
{
timeoutIn: TEN_SECONDS_IN_MS,
}
);
}

/**
Expand Down Expand Up @@ -1389,13 +1399,16 @@ export class NWorker {
if (kind === NEVENT_KIND.METADATA) {
const newUser = new NUserBase();
newUser.fromEvent(ev);
const data = {
user: newUser,
relayUrls: [payload.meta.url],
};
if (userRecord) {
await this.db.updateUser(ev.pubkey, data);
await this.db.updateUser(ev.pubkey, {
...userRecord,
user: newUser,
});
} else {
const data = {
user: newUser,
relayUrls: [payload.meta.url],
};
await this.db.addUser(data);
}
}
Expand Down

0 comments on commit 00fda31

Please sign in to comment.