Skip to content

Commit edc7400

Browse files
committed
Fix space child via params not being reconciled
Basically, we hoist this special content addition out of the creation branch and consider it as a normal property during reconciliation.
1 parent 1f5ea4f commit edc7400

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/modules/Reconciler.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,15 @@ export default class extends Module {
479479
const actual = structuredClone(space.children[id]?.content);
480480
if (!include) return actual && (await this.removeFromSpace(space, child));
481481

482-
const expected = { order, suggested };
482+
// TODO I just put [] here to get TypeScript to shut the fuck up about expected's type when we assign to via below
483+
// (And then I *still* had to cast it away from never[]... there's gotta be a better way??)
484+
const expected = { order, suggested, via: [] as string[] };
485+
486+
// `via` MUST have at least one value or the child is not considered part of the space,
487+
// but room v12 changes the ID format that this split relies on.
488+
// TODO is there any reason to not *always* just use this.plan.homeserver?
489+
const via = [id.split(":", 2)[1] ?? this.plan.homeserver];
490+
expected.via = via;
483491

484492
if (actual) {
485493
let changed = false;
@@ -501,12 +509,8 @@ export default class extends Module {
501509
await space.addChildRoom(id, actual);
502510
}
503511
} else {
504-
// `via` MUST have at least one value or the child is not considered part of the space,
505-
// but room v12 changes the ID format that this split relies on.
506-
// TODO is there any reason to not *always* just use this.plan.homeserver?
507-
const via = [id.split(":", 2)[1] ?? this.plan.homeserver];
508512
this.info("🏘️ Add to space", { space: space.room.local, child: local, via });
509-
await space.addChildRoom(id, { via, ...expected });
513+
await space.addChildRoom(id, expected);
510514
}
511515
if (space.room.private) this.#publicSpaceByChild.delete(id);
512516
else if (!this.#publicSpaceByChild.has(id))

0 commit comments

Comments
 (0)