From 52692ec4eccf694d8990b5084efd9707e0be45a9 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Sat, 19 Mar 2022 01:22:10 +0100 Subject: [PATCH] Also display orchestrator ens description and url if it is set --- src/components/OrchAddressViewer.js | 5 ++-- src/components/OrchInfoViewer.js | 43 ++++++++++++++++++++++++++++ src/components/eventButtonAddress.js | 2 ++ src/components/orchestratorViewer.js | 21 -------------- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/components/OrchAddressViewer.js b/src/components/OrchAddressViewer.js index c20fbeb..5dee54f 100644 --- a/src/components/OrchAddressViewer.js +++ b/src/components/OrchAddressViewer.js @@ -1,9 +1,6 @@ import React, { useState } from "react"; import { useSelector } from 'react-redux'; import { getEnsInfo } from "../actions/livepeer"; -import { - getOrchestratorInfo -} from "../actions/livepeer"; const Address = (obj) => { const livepeer = useSelector((state) => state.livepeerstate); @@ -25,6 +22,7 @@ const Address = (obj) => { getEnsInfo(obj.address); setRefresh(true); } + break; } } // If it was not cached at all @@ -47,6 +45,7 @@ const Address = (obj) => { getEnsInfo(obj.address); setRefresh(true); } + break; } } // If it was not cached at all diff --git a/src/components/OrchInfoViewer.js b/src/components/OrchInfoViewer.js index 9aab279..3a2e468 100644 --- a/src/components/OrchInfoViewer.js +++ b/src/components/OrchInfoViewer.js @@ -1,6 +1,7 @@ import React from "react"; import Stat from "./statViewer"; import Address from "./OrchAddressViewer"; +import { useSelector } from 'react-redux'; function updateClipboard(newClip) { navigator.clipboard.writeText(newClip).then( @@ -24,6 +25,7 @@ function copyLink(addr) { } const OrchInfoViewer = (obj) => { + const livepeer = useSelector((state) => state.livepeerstate); let rewardCut = 0; let feeCut = 0; let totalStake = 0; @@ -68,6 +70,45 @@ const OrchInfoViewer = (obj) => { shareUrl = thisFullPath + "?orchAddr=" + thisID; } + let thisDomain = null; + let thisInfo = null; + // Lookup domain in cache + if (livepeer.ensDomainMapping) { + for (const thisAddr of livepeer.ensDomainMapping) { + if (thisAddr.address === thisID) { + thisDomain = thisAddr; + break; + } + } + } + // Lookup current info in cache only if this addr has a mapped ENS domain + if (thisDomain && thisDomain.domain) { + for (const thisAddr of livepeer.ensInfoMapping) { + if (thisAddr.domain === thisDomain.domain) { + thisInfo = thisAddr; + break; + } + } + } + let ensDescription; + let ensUrl; + if (thisInfo) { + if (thisInfo.description) { + ensDescription = +
+ {thisInfo.description} +
+ } + if (thisInfo.url) { + ensUrl = + +
+ {thisInfo.url} +
+
+ } + } + return (
@@ -78,6 +119,8 @@ const OrchInfoViewer = (obj) => {
+ {ensUrl} + {ensDescription}
diff --git a/src/components/eventButtonAddress.js b/src/components/eventButtonAddress.js index dc3fab7..e22eccc 100644 --- a/src/components/eventButtonAddress.js +++ b/src/components/eventButtonAddress.js @@ -26,6 +26,7 @@ const EventButtonAddress = (obj) => { getEnsInfo(obj.address); setRefresh(true); } + break; } } // If it was not cached at all @@ -48,6 +49,7 @@ const EventButtonAddress = (obj) => { getEnsInfo(obj.address); setRefresh(true); } + break; } } // If it was not cached at all diff --git a/src/components/orchestratorViewer.js b/src/components/orchestratorViewer.js index 4afd54f..cfcf5b5 100644 --- a/src/components/orchestratorViewer.js +++ b/src/components/orchestratorViewer.js @@ -2,27 +2,6 @@ import React from "react"; import OrchDelegatorViewer from "./OrchDelegatorViewer"; import OrchInfoViewer from "./OrchInfoViewer"; -function updateClipboard(newClip) { - navigator.clipboard.writeText(newClip).then( - () => { - console.log("Copied!"); - }, - () => { - console.log("Copy failed!"); - } - ); -} - -function copyLink(addr) { - navigator.permissions - .query({ name: "clipboard-write" }) - .then((result) => { - if (result.state === "granted" || result.state === "prompt") { - updateClipboard(addr); - } - }); -} - const Orchestrator = (obj) => { if (obj.thisOrchestrator) { if (obj.forceVertical) {