Fixup, add authors to graph even if hidden

This commit is contained in:
Ladd Hoffman 2023-04-16 20:17:25 -05:00
parent b71649df97
commit 226e95cfba
1 changed files with 7 additions and 10 deletions

View File

@ -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);
}
}