From b74e8d88e510cb384b5567f0b8a3dabe8be9605c Mon Sep 17 00:00:00 2001 From: Dillon Chen Date: Fri, 24 Apr 2020 02:15:23 -0400 Subject: [PATCH] Fix reaction tooltip for offchain communities (#33) Co-authored-by: Raymond Zhong --- client/scripts/controllers/server/reactions.ts | 1 + client/scripts/models/OffchainReaction.ts | 4 +++- client/scripts/views/components/reaction_button.ts | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/scripts/controllers/server/reactions.ts b/client/scripts/controllers/server/reactions.ts index c773964b10e..697e913d5ea 100644 --- a/client/scripts/controllers/server/reactions.ts +++ b/client/scripts/controllers/server/reactions.ts @@ -20,6 +20,7 @@ const modelFromServer = (reaction) => { reaction.reaction, reaction.thread_id, reaction.comment_id, + reaction.Address.chain, ); }; diff --git a/client/scripts/models/OffchainReaction.ts b/client/scripts/models/OffchainReaction.ts index eff14bc4eb7..fd0fb266d0d 100644 --- a/client/scripts/models/OffchainReaction.ts +++ b/client/scripts/models/OffchainReaction.ts @@ -8,8 +8,9 @@ class OffchainReaction { public readonly reaction: string; public readonly threadId: number | string; public readonly commentId: number | string; + public readonly author_chain: string; - constructor(id, author, chain, community, reaction, threadId, communityId) { + constructor(id, author, chain, community, reaction, threadId, communityId, author_chain) { this.id = id; this.author = author; this.chain = chain; @@ -17,6 +18,7 @@ class OffchainReaction { this.reaction = reaction; this.threadId = threadId; this.commentId = communityId; + this.author_chain = author_chain; } } diff --git a/client/scripts/views/components/reaction_button.ts b/client/scripts/views/components/reaction_button.ts index 1361a7d092e..fb1e6f825ec 100644 --- a/client/scripts/views/components/reaction_button.ts +++ b/client/scripts/views/components/reaction_button.ts @@ -43,7 +43,7 @@ const ReactionButton: m.Component = { if (hasReacted) hasReactedType = rxn.reaction; const reactors = (likes || dislikes).slice(0, MAX_VISIBLE_REACTING_ACCOUNTS).map((rxn_) => { - return m('.reacting-user', m(User, { user: [rxn_.author, app.activeChainId()], linkify: true })); + return m('.reacting-user', m(User, { user: [rxn_.author, rxn_.author_chain], linkify: true })); }); if (reactors.length < (likes || dislikes).length) { const diff = (likes || dislikes).length - reactors.length; @@ -58,6 +58,7 @@ const ReactionButton: m.Component = { e.preventDefault(); e.stopPropagation(); if (disabled) return; + // if it's a community use the app.vm.activeAccount.chain.id instead of author chain const chainId = app.activeCommunityId() ? null : app.activeChainId(); const communityId = app.activeCommunityId(); if (hasReacted) {