diff --git a/src/app/app.ts b/src/app/app.ts index b79a940..ca8c339 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -165,14 +165,30 @@ export default class Enclave
{
return;
case "Messages":
- Object.entries(msg.messages).forEach(([channelId, messages]) => {
- if (!server.messages[channelId]) {
- server.messages[channelId] = {};
- }
+ const authors = Object.entries(msg.messages).flatMap(
+ ([channelId, messages]) => {
+ if (!server.messages[channelId]) {
+ server.messages[channelId] = {};
+ }
- messages.forEach((message) => {
- server.messages[channelId][message.id] = message;
- });
+ return messages.map((message) => {
+ server.messages[channelId][message.id] = message;
+ return message.author;
+ });
+ },
+ );
+
+ const dedupedAuthors = Array.from(new Set(authors));
+
+ this.server?.getUsers(dedupedAuthors);
+
+ this.forceRender();
+
+ return;
+
+ case "Users":
+ Object.entries(msg.users).forEach(([pubKey, user]) => {
+ server.users[pubKey] = user;
});
this.forceRender();
diff --git a/src/app/protocol.ts b/src/app/protocol.ts
index ed48003..69b5777 100644
--- a/src/app/protocol.ts
+++ b/src/app/protocol.ts
@@ -15,6 +15,10 @@ export type ClientMethod =
| {
method: "Messages";
messages: Record