| … | … | @@ -621,6 +621,40 @@ export class Peer { |
| 621 | 621 | return out |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | /** |
| 625 | * MY OWN edges in one collection, whole — target components included. |
| 626 | * |
| 627 | * ⛔ `myReactions()` COLLAPSES TO targetId -> Set(value), which is right for rendering a page ("is |
| 628 | * this one liked?") and useless for projecting one: the targetId is a HASH, so the feed, collection |
| 629 | * and name that built it cannot be recovered from it, and a bridge needs those to name the subject |
| 630 | * on another network. |
| 631 | * |
| 632 | * ⚠ MY OWN FEED ONLY. Reading this across readable feeds would project somebody else's like as mine |
| 633 | * — the same reason myReactions is scoped that way. |
| 634 | */ |
| 635 | async ownEdges (collection) { |
| 636 | const out = [] |
| 637 | for (const row of await this.feed.list(collection)) { |
| 638 | const fm = (row.record && row.record.frontmatter) || {} |
| 639 | const target = Peer.normalizeTarget(fm.target) |
| 640 | // A row whose target will not normalise names nothing, so there is nothing to project. Skipped |
| 641 | // rather than thrown: one malformed record must not stop a projection pass. |
| 642 | if (!target) continue |
| 643 | out.push({ |
| 644 | name: row.key, |
| 645 | collection, |
| 646 | target, |
| 647 | value: fm.value || null, |
| 648 | createdAt: fm.createdAt || null, |
| 649 | body: (row.record && row.record.body) || '' |
| 650 | }) |
| 651 | } |
| 652 | // Oldest first: an edge is projected in the order it was made, so a reply lands after the thing |
| 653 | // it replies to when a whole history is projected at once. |
| 654 | out.sort((a, b) => String(a.createdAt || '') < String(b.createdAt || '') ? -1 : 1) |
| 655 | return out |
| 656 | } |
| 657 | |
| 624 | 658 | /** Have I liked this target? The single-target form, for a page that renders one post. */ |
| 625 | 659 | async likedByMe (target) { |
| 626 | 660 | const t = Peer.normalizeTarget(target) |