Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: Dynamically create order page match cards #1864

Merged
merged 4 commits into from Oct 3, 2022

Conversation

martonp
Copy link
Contributor

@martonp martonp commented Sep 23, 2022

Updates the order page to dynamically create match cards instead of creating them with the template. This allows the user to see new matches without having to reload the page.

Updates the order page to dynamically create match cards instead
of creating them with template. This allows the user to see new
matches without having to reload the page.
Copy link
Member

@buck54321 buck54321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! A couple of observations from a cursory scan.

Comment on lines 43 to 44
page.matchCardTmpl.removeAttribute('id')
page.matchCardTmpl.remove()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also Doc.cleanTemplates.

Comment on lines 110 to 114
this.start().then(
() => {
this.showMatchCards()
}
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just put this.showMatchCards() at the end of start?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True

Comment on lines 148 to 154
Doc.tmplElement(matchCard, 'matchID').textContent = match.matchID

const time = new Date(match.stamp)
Doc.tmplElement(matchCard, 'matchTime').textContent = time.toLocaleTimeString('en-GB', {
year: 'numeric',
month: 'short',
day: 'numeric'
Copy link
Member

@buck54321 buck54321 Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const tmpl = Doc.parseTemplate(matchCard)
tmpl.matchID.textContent = ...

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@JoeGruffins
Copy link
Member

JoeGruffins commented Sep 26, 2022

The accelerate button does not seem to be showing up for the orders page most of the time. Do you also see, or not see, this? I can make an issue or you can if so. Unless its an easy fix.

I can't remember, but do the accelerations handle accelerations for different matches for the same order? I don't remember being able to choose. You could have a booked order match half and start settling then match with another person and you need to accelerate both?

I guess the second match uses the change from the first, so can only accelerate in order?

@chappjc
Copy link
Member

chappjc commented Sep 26, 2022

I can't remember, but do the accelerations handle accelerations for different matches for the same order?

Acceleration is at the level of the order, not the match, because they are all in a chain, spending change to fund subsequent matches, as you noted.

Comment on lines 432 to 435
return readers
}

// IsMaker returns if the user is the maker in this match.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me like the rest of matchReader can go now. There are no invocations of (*OrderReader).MatchReaders remaining, and the remaining methods aren't used (some share names with OrderReader methods, but the matchReader variants aren't used.)

Comment on lines 305 to 320
const showMakerSwap = !m.isCancel && (makerSwapCoin(m) || !m.revoked)
const showTakerSwap = !m.isCancel && (takerSwapCoin(m) || !m.revoked)
const showMakerRedeem = !m.isCancel && (makerRedeemCoin(m) || !m.revoked)
const showTakerRedeem = !m.isCancel && (m.side !== OrderUtil.Maker) && (takerRedeemCoin(m) || !m.revoked)
const showRefund = !m.isCancel && (m.refund || (m.revoked && m.active))

if (showMakerSwap) Doc.show(tmpl.makerSwap)
else Doc.hide(tmpl.makerSwap)
if (showTakerSwap) Doc.show(tmpl.takerSwap)
else Doc.hide(tmpl.takerSwap)
if (showMakerRedeem) Doc.show(tmpl.makerRedeem)
else Doc.hide(tmpl.makerRedeem)
if (showTakerRedeem) Doc.show(tmpl.takerRedeem)
else Doc.hide(tmpl.takerRedeem)
if (showRefund) Doc.show(tmpl.refund)
else Doc.hide(tmpl.refund)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the existing code here is clearly from very early development. There is also Doc.setVis now, so you could do 1 or 2 lines per element, e.g.

Doc.setVis(!m.isCancel && (makerSwapCoin(m) || !m.revoked), tmpl.makerSwap)

@chappjc chappjc merged commit a461a3b into decred:master Oct 3, 2022
@martonp martonp deleted the dynamicMatchCard branch December 20, 2022 22:08
@chappjc chappjc added this to the 0.6 milestone Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants