Fixup, add authors to graph even if hidden
This commit is contained in:
parent
b71649df97
commit
226e95cfba
|
@ -123,9 +123,6 @@ export class Forum extends ReputationHolder {
|
||||||
const addAuthorToGraph = (publicKey, weight, authorTokenId) => {
|
const addAuthorToGraph = (publicKey, weight, authorTokenId) => {
|
||||||
// For graph display purposes, we want to use the existing Expert actors from the current scene.
|
// For graph display purposes, we want to use the existing Expert actors from the current scene.
|
||||||
const author = this.scene.findActor(({ reputationPublicKey }) => reputationPublicKey === publicKey);
|
const author = this.scene.findActor(({ reputationPublicKey }) => reputationPublicKey === publicKey);
|
||||||
if (author.options.hide) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
author.setDisplayValue('reputation', () => author.getReputation());
|
author.setDisplayValue('reputation', () => author.getReputation());
|
||||||
const authorVertex = this.graph.getVertex(publicKey)
|
const authorVertex = this.graph.getVertex(publicKey)
|
||||||
?? this.graph.addVertex(VertexTypes.AUTHOR, publicKey, author, author.getLabel(), {
|
?? 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.
|
// In the case of multiple authors, mint additional (empty) tokens.
|
||||||
// If no authors are specified, treat the sender as the sole author.
|
// 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) {
|
if (!post.authors?.length) {
|
||||||
addAuthorToGraph(post.senderId, 1, tokenId);
|
addAuthorToGraph(post.senderId, 1, tokenId);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Verify that author list includes the sender
|
|
||||||
for (const { publicKey, weight } of post.authors) {
|
for (const { publicKey, weight } of post.authors) {
|
||||||
// If the sender is also listed among the authors, do not mint them an additional token.
|
// If the sender is also listed among the authors, do not mint them an additional token.
|
||||||
if (publicKey === post.senderId) {
|
const authorTokenId = (publicKey === post.senderId) ? tokenId : this.dao.reputation.mint(this.id, 0);
|
||||||
addAuthorToGraph(publicKey, weight, tokenId);
|
addAuthorToGraph(publicKey, weight, authorTokenId);
|
||||||
} else {
|
|
||||||
addAuthorToGraph(publicKey, weight, this.dao.reputation.mint(this.id, 0));
|
|
||||||
}
|
}
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue