From 226e95cfba72913da2f720afc1b9d3613a621252 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Sun, 16 Apr 2023 20:17:25 -0500 Subject: [PATCH] Fixup, add authors to graph even if hidden --- forum-network/src/classes/dao/forum.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/forum-network/src/classes/dao/forum.js b/forum-network/src/classes/dao/forum.js index b7c76a7..1a861a6 100644 --- a/forum-network/src/classes/dao/forum.js +++ b/forum-network/src/classes/dao/forum.js @@ -123,9 +123,6 @@ export class Forum extends ReputationHolder { const addAuthorToGraph = (publicKey, weight, authorTokenId) => { // For graph display purposes, we want to use the existing Expert actors from the current scene. const author = this.scene.findActor(({ reputationPublicKey }) => reputationPublicKey === publicKey); - if (author.options.hide) { - return; - } author.setDisplayValue('reputation', () => author.getReputation()); const authorVertex = this.graph.getVertex(publicKey) ?? this.graph.addVertex(VertexTypes.AUTHOR, publicKey, author, author.getLabel(), { @@ -143,18 +140,18 @@ export class Forum extends ReputationHolder { // In the case of multiple authors, mint additional (empty) tokens. // If no authors are specified, treat the sender as the sole author. - // TODO: Verify that cumulative author weight == 1 + // TODO: Verify that cumulative author weight == 1. if (!post.authors?.length) { addAuthorToGraph(post.senderId, 1, tokenId); } else { - // TODO: Verify that author list includes the sender for (const { publicKey, weight } of post.authors) { // If the sender is also listed among the authors, do not mint them an additional token. - if (publicKey === post.senderId) { - addAuthorToGraph(publicKey, weight, tokenId); - } else { - addAuthorToGraph(publicKey, weight, this.dao.reputation.mint(this.id, 0)); - } + const authorTokenId = (publicKey === post.senderId) ? tokenId : this.dao.reputation.mint(this.id, 0); + addAuthorToGraph(publicKey, weight, authorTokenId); + } + // If the sender is not an author, they will end up with the minted token but with zero value. + if (!post.authors.find(({ publicKey }) => publicKey === post.senderId)) { + addAuthorToGraph(post.senderId, 0, tokenId); } }