Check hierarchy instead of m.space.child

This commit is contained in:
Cadence Ember
2025-06-22 18:38:20 +12:00
parent efaa59ca92
commit 50a047249b
4 changed files with 84 additions and 82 deletions

View File

@@ -181,6 +181,23 @@ async function getFullHierarchy(roomID) {
return rooms
}
/**
* Like `getFullHierarchy` but reveals a page at a time through an async iterator.
* @param {string} roomID
*/
async function* generateFullHierarchy(roomID) {
/** @type {string | undefined} */
let nextBatch = undefined
do {
/** @type {Ty.HierarchyPagination<Ty.R.Hierarchy>} */
const res = await getHierarchy(roomID, {from: nextBatch})
for (const room of res.rooms) {
yield room
}
nextBatch = res.next_batch
} while (nextBatch)
}
/**
* @param {string} roomID
* @param {string} eventID
@@ -442,6 +459,7 @@ module.exports.getJoinedMembers = getJoinedMembers
module.exports.getMembers = getMembers
module.exports.getHierarchy = getHierarchy
module.exports.getFullHierarchy = getFullHierarchy
module.exports.generateFullHierarchy = generateFullHierarchy
module.exports.getRelations = getRelations
module.exports.getFullRelations = getFullRelations
module.exports.sendState = sendState