Skip to content

Commit 66ac577

Browse files
committed
Sort by pool ticker in Discord format code block modal
Then by party id if they're equal of missing. Also don't show strong text markup if the pool ticker is missing.
1 parent 5137859 commit 66ac577

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

mithril-explorer/src/components/RegistrationDiscordFormatModal.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,33 @@ export default function RegistrationDiscordFormatModal({ registrations, onClose,
2828
}
2929

3030
text += `Since epoch **#${epoch}**:\n`;
31-
for (const signer of signers) {
32-
const pollTicker =
33-
allPools?.find((pool) => pool.party_id === signer.party_id)?.pool_ticker ?? "";
34-
text += `* ${signer.party_id} **${pollTicker}**\n`;
31+
for (const signer of signers
32+
.map((s) => ({
33+
party_id: s.party_id,
34+
pool_ticker: allPools?.find((p) => p.party_id === s.party_id)?.pool_ticker ?? "",
35+
}))
36+
.sort(compareSigners)) {
37+
text += `* ${signer.party_id}`;
38+
39+
if (signer.pool_ticker !== "") {
40+
text += ` **${signer.pool_ticker}**`;
41+
}
42+
43+
text += `\n`;
3544
}
3645
}
3746

3847
setTextToCopy(text);
3948
}, [registrations, mode, allPools]);
4049

50+
function compareSigners(left, right) {
51+
// Sort by pool_ticker then party_id
52+
return (
53+
left.pool_ticker.localeCompare(right.pool_ticker) ||
54+
left.party_id.localeCompare(right.party_id)
55+
);
56+
}
57+
4158
function handleModalClose() {
4259
onClose();
4360
}

0 commit comments

Comments
 (0)