Skip to content

Commit 75f4eab

Browse files
authored
use space name for spaces list (#234)
1 parent 9003282 commit 75f4eab

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

apps/events/src/routes/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ function Index() {
7575
<div className="flex flex-row gap-2 justify-between items-center">
7676
<Input value={spaceName} onChange={(e) => setSpaceName(e.target.value)} />
7777
<Button
78+
disabled={true} // disabled until we have delegation for creating a space
7879
onClick={async (event) => {
7980
event.preventDefault();
8081
// const smartAccountWalletClient = await getSmartAccountWalletClient();
@@ -96,7 +97,7 @@ function Index() {
9697
<Link to="/space/$spaceId" params={{ spaceId: space.id }}>
9798
<Card>
9899
<CardHeader>
99-
<CardTitle>{space.id}</CardTitle>
100+
<CardTitle>{space.name}</CardTitle>
100101
</CardHeader>
101102
</Card>
102103
</Link>

apps/server/src/handlers/getSpace.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const getSpace = async ({ spaceId, accountAddress }: Params) => {
6565

6666
return {
6767
id: space.id,
68+
name: space.name,
6869
events: space.events.map((wrapper) => JSON.parse(wrapper.event)),
6970
keyBoxes,
7071
inboxes: space.inboxes.map((inbox) => ({

packages/hypergraph-react/src/HypergraphAppContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ export function HypergraphAppProvider({
380380
store.send({
381381
type: 'setSpaceFromList',
382382
spaceId: space.id,
383+
name: space.name,
383384
});
384385
});
385386
break;
@@ -432,6 +433,7 @@ export function HypergraphAppProvider({
432433

433434
store.send({
434435
type: 'setSpace',
436+
name: response.name,
435437
spaceId: response.id,
436438
updates: response.updates as Messages.Updates,
437439
events: response.events as Array<SpaceEvents.SpaceEvent>,

packages/hypergraph/src/messages/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ export const ResponseListSpaces = Schema.Struct({
277277
spaces: Schema.Array(
278278
Schema.Struct({
279279
id: Schema.String,
280+
name: Schema.String,
280281
}),
281282
),
282283
});
@@ -347,6 +348,7 @@ export type ResponseAccountInbox = Schema.Schema.Type<typeof ResponseAccountInbo
347348
export const ResponseSpace = Schema.Struct({
348349
type: Schema.Literal('space'),
349350
id: Schema.String,
351+
name: Schema.String,
350352
events: Schema.Array(SpaceEvent),
351353
keyBoxes: Schema.Array(KeyBoxWithKeyId),
352354
updates: Schema.optional(Updates),

packages/hypergraph/src/store-connect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ type StoreEvent =
127127
| {
128128
type: 'setSpace';
129129
spaceId: string;
130+
name: string;
130131
updates?: Updates;
131132
events: SpaceEvent[];
132133
inboxes?: SpaceInboxStorageEntry[];

packages/hypergraph/src/store.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type AccountInboxStorageEntry = {
4343

4444
export type SpaceStorageEntry = {
4545
id: string;
46+
name: string;
4647
events: SpaceEvent[];
4748
state: SpaceState | undefined;
4849
keys: { id: string; key: string }[];
@@ -89,7 +90,7 @@ type StoreEvent =
8990
| { type: 'reset' }
9091
| { type: 'addUpdateInFlight'; updateId: string }
9192
| { type: 'removeUpdateInFlight'; updateId: string }
92-
| { type: 'setSpaceFromList'; spaceId: string }
93+
| { type: 'setSpaceFromList'; spaceId: string; name: string }
9394
| { type: 'applyEvent'; spaceId: string; event: SpaceEvent; state: SpaceState }
9495
| { type: 'updateConfirmed'; spaceId: string; clock: number }
9596
| { type: 'applyUpdate'; spaceId: string; firstUpdateClock: number; lastUpdateClock: number }
@@ -126,6 +127,7 @@ type StoreEvent =
126127
| {
127128
type: 'setSpace';
128129
spaceId: string;
130+
name: string;
129131
updates?: Updates;
130132
events: SpaceEvent[];
131133
inboxes?: SpaceInboxStorageEntry[];
@@ -180,7 +182,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
180182
updatesInFlight: context.updatesInFlight.filter((id) => id !== event.updateId),
181183
};
182184
},
183-
setSpaceFromList: (context, event: { spaceId: string }) => {
185+
setSpaceFromList: (context, event: { spaceId: string; name: string }) => {
184186
if (!context.repo) {
185187
return context;
186188
}
@@ -198,6 +200,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
198200
if (existingSpace.id === event.spaceId) {
199201
const newSpace: SpaceStorageEntry = {
200202
id: existingSpace.id,
203+
name: existingSpace.name,
201204
events: existingSpace.events ?? [],
202205
state: existingSpace.state,
203206
keys: existingSpace.keys ?? [],
@@ -220,6 +223,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
220223
...context.spaces,
221224
{
222225
id: event.spaceId,
226+
name: event.name,
223227
events: [],
224228
state: undefined,
225229
keys: [],
@@ -408,6 +412,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
408412
context,
409413
event: {
410414
spaceId: string;
415+
name: string;
411416
updates?: Updates;
412417
inboxes?: SpaceInboxStorageEntry[];
413418
events: SpaceEvent[];
@@ -425,6 +430,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
425430
result.handle.doneLoading();
426431

427432
const newSpace: SpaceStorageEntry = {
433+
name: event.name,
428434
id: event.spaceId,
429435
events: event.events,
430436
state: event.spaceState,

0 commit comments

Comments
 (0)