Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Fix: Contact names not reactive to display name fetch (#508)

dev-rbb29e9d28d413
diff --git a/js/app/packages/core/user/contactService.ts b/js/app/packages/core/user/contactService.ts
index 02e0cbc4ea..3bfced6ec9 100644
--- a/js/app/packages/core/user/contactService.ts
+++ b/js/app/packages/core/user/contactService.ts
@@ -7,8 +7,6 @@ import { createSingletonRoot } from '@solid-primitives/rootless';
import { createMemo, createResource } from 'solid-js';
async function getContacts() {
- let allContacts: IUser[] = [];
-
if (!ENABLE_CONTACTS) {
console.error('Contacts disabled, returning empty list');
return [];
@@ -22,15 +20,7 @@ async function getContacts() {
const [, data] = result;
const { contacts } = data;
- allContacts = contacts.map((id) => {
- return {
- id: id,
- email: idToEmail(id),
- name: idToDisplayName(id),
- };
- });
-
- return allContacts;
+ return contacts;
}
const contactsResource = createSingletonRoot(() =>
@@ -43,7 +33,11 @@ export function useContacts() {
const [resource] = contactsResource();
return createMemo<IUser[]>(() => {
const result = resource.latest;
- return result ?? [];
+ return result.map((c) => ({
+ id: c,
+ email: idToEmail(c),
+ name: idToDisplayName(c),
+ }));
});
}
diff --git a/js/app/packages/core/user/displayName.ts b/js/app/packages/core/user/displayName.ts
index a2c27ec2f3..ac8628a6e6 100644
--- a/js/app/packages/core/user/displayName.ts
+++ b/js/app/packages/core/user/displayName.ts
@@ -84,11 +84,10 @@ async function batchFetchNames(ids: string[]) {
ids.length > 0 ? fetchDisplayNames(ids) : Promise.resolve([]),
]);
- const updates: DisplayNameStore = {};
-
- [...nameResults].forEach((result) => {
- updates[result.id] = result;
- });
+ const updates = nameResults.reduce((acc, result) => {
+ acc[result.id] = result;
+ return acc;
+ }, {} as DisplayNameStore);
setUserDisplayNames((prev) => ({ ...prev, ...updates }));
}