differentiate time on proposals list

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-03-03 13:33:58 +03:00
parent 670e85889b
commit 43620736cf
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
2 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "ghost-dao-interface", "name": "ghost-dao-interface",
"private": true, "private": true,
"version": "0.5.34", "version": "0.5.35",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@ -349,10 +349,11 @@ const ProposalFilterTrigger = ({ trigger, setTrigger }) => {
} }
const convertDeadline = (deadline, blockNumber, chainId) => { const convertDeadline = (deadline, blockNumber, chainId) => {
const diff = blockNumber > deadline ? blockNumber - deadline : deadline - blockNumber; const alreadyHappened = blockNumber > deadline;
const diff = alreadyHappened ? blockNumber - deadline : deadline - blockNumber;
const voteSeconds = Number(diff * networkAvgBlockSpeed(chainId)); const voteSeconds = Number(diff * networkAvgBlockSpeed(chainId));
const result = prettifySeconds(voteSeconds, "mins"); const result = prettifySeconds(voteSeconds, "min");
if (result === "now") { if (result === "now") {
return new Date(Date.now()).toLocaleDateString('en-US', { return new Date(Date.now()).toLocaleDateString('en-US', {
year: 'numeric', year: 'numeric',
@ -361,7 +362,10 @@ const convertDeadline = (deadline, blockNumber, chainId) => {
}); });
} }
return `in ${result}`; const prefix = alreadyHappened ? "" : "in ";
const postfix = alreadyHappened ? " ago" : "";
return `${prefix}${result}${postfix}`;
} }
export default ProposalsList; export default ProposalsList;