Skip to content

Commit

Permalink
Pinned posts for all!
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelharms6010 committed Dec 13, 2020
1 parent aadb2ec commit b4dcf01
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You'll find the built app in `/release/`
- [x] Rescan button
- [x] Render error message on failed send
- [x] Filter posts by amount (slider)
- [x] Pinned Post (highest value in last 14 days)
- [ ] address label/names
- [ ] refresh button
- [ ] sync/resync progress indicator (logfile in root can prolly be used for this?)
Expand Down
10 changes: 10 additions & 0 deletions app/components/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,14 @@ hr {

li {
width: 50px;
}

.pinnedpost {
background: pink;
width: 100%;
margin: 1%;
margin-bottom: 3%;
color: #333;
padding: 1%;
word-break: break-word;
}
18 changes: 16 additions & 2 deletions app/components/Thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ export default function Thread(props: Props) {
const [posts, setPosts] = useState(null)
const [technicolor, setTechnicolor] = useState(false)
const [threshold, setThreshold] = useState(0)
const [pinned, setPinned] = useState(null)

useEffect(() => {
ZcashLight.listReceivedByAddress(props.match.params.id, setPosts)
},[])

useEffect(() => {
if (posts) {
setPinned([...posts].sort((a,b) => b.amount - a.amount ).find(item => +item.datetime > ((Date.now() / 1000) - (60 * 60 * 24 * 14)) ) )
}
},[posts])

const handleChange = e => setThreshold(e.target.value)
const formatzat = value => value + ' zat'



return (
Expand All @@ -43,6 +48,15 @@ export default function Thread(props: Props) {
</div>
<ThreadReplyForm posts={posts} setPosts={setPosts} thread={props.match.params.id} />
<p className={styles.viewkey}>{props.match.params.id}</p>
{pinned &&
<>
<h3>Pinned Post</h3>
<div style={technicolor ? {color: `#${getColorFromAmount(pinned.amount)}`, background: `${invertColor(getColorFromAmount(pinned.amount))}` } : {}} key={pinned.memo + pinned.txid} className={styles.pinnedpost}>
<p>{pinned.memo.split("\\n").join("\n")}</p>
<p className={styles.amount}>{pinned.amount} Zats</p>
</div>
</>}
<h3>Thread</h3>
{posts
? posts.map(post =>
post.memo && post.amount >= threshold ?
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/light-zcash-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function listZaddrsWithNewZ(setZaddrs) {
}
exec(`${commandStartString}zecwallet-cli${extension} balance`, (err, stdout, stderr) => {
if (err) {
console.log(err, stderrr)
console.log(err, stderr)
return
}

Expand Down Expand Up @@ -100,7 +100,7 @@ function importViewKey(viewKey, success, setSuccess, birthday=1060000) {
function listZaddrs(setZaddrs) {
exec(`${commandStartString}zecwallet-cli${extension} balance`, (err, stdout, stderr) => {
if (err) {
console.log(err, stderrr)
console.log(err, stderr)
return
}

Expand All @@ -113,7 +113,7 @@ function listZaddrs(setZaddrs) {
function listTransactions(setTransactions) {
exec(`${commandStartString}zecwallet-cli${extension} list`, (err, stdout, stderr) => {
if (err) {
console.log(stderrr)
console.log(stderr)
return
}
let transactions = JSON.parse(stdout)
Expand All @@ -126,7 +126,7 @@ function listReceivedByAddress(zaddr, setPosts) {

exec(`${commandStartString}zecwallet-cli${extension} list`, (err, stdout, stderr) => {
if (err) {
console.log(stderrr)
console.log(stderr)
return
}
let transactions = JSON.parse(stdout)
Expand All @@ -138,7 +138,7 @@ function listReceivedByAddress(zaddr, setPosts) {
function getViewKey(zaddr, setExportedKey) {
exec(`${commandStartString}zecwallet-cli${extension} export ${zaddr}`, (err, stdout, stderr) => {
if (err) {
console.log(stderrr)
console.log(stderr)
return
}
let keys = JSON.parse(stdout)[0]
Expand Down

0 comments on commit b4dcf01

Please sign in to comment.