diff --git a/components/alert/alert-container.tsx b/components/alert/alert-container.tsx index cb713f5..159cc0a 100644 --- a/components/alert/alert-container.tsx +++ b/components/alert/alert-container.tsx @@ -7,10 +7,10 @@ const AlertContainer: FC = () => { const { alerts } = useAlertContext(); return ( -
+
{alerts.map((alert: IAlert) => ( = ({ // Add a new alert to the list const addAlert = (message: string, alertOptions?: AlertOptions) => { + const newAlertList = ([] as IAlert[]).concat(alerts); + // Clean duplicates const idx = alerts.findIndex((a) => { if (a.message !== message) return false; else if (a.description !== alertOptions?.description) return false; else if (a.type !== alertOptions?.type) return false; - return true; }); - if (idx >= 0) removeAlert(idx); + if (idx >= 0) { + const [prevAlert] = newAlertList.splice(idx, 1); + clearTimeout(prevAlert.dismissTimeout); + const timeout = alertOptions?.timeout ?? DEFAULT_ALERT_TIMEOUT; + prevAlert.dismissTimeout = setTimeout( + () => removeAlert(prevAlert.id), + timeout + ); + setAlerts(newAlertList.concat(prevAlert)); + return; + } const newAlert: IAlert = { id: Date.now(), @@ -48,13 +59,12 @@ export const AlertProvider: React.FC<{ children: React.ReactNode }> = ({ newAlert.explorerLink = client.chain.blockExplorers?.default.url + "/tx/" + alertOptions.txHash; } - setAlerts(alerts.concat(newAlert)); - - // Schedule the clean-up const timeout = alertOptions?.timeout ?? DEFAULT_ALERT_TIMEOUT; - setTimeout(() => { - removeAlert(newAlert.id); - }, timeout); + newAlert.dismissTimeout = setTimeout( + () => removeAlert(newAlert.id), + timeout + ); + setAlerts(newAlertList.concat(newAlert)); }; // Function to remove an alert diff --git a/plugins/dualGovernance/components/proposal/description.tsx b/plugins/dualGovernance/components/proposal/description.tsx index 809b0e7..2d93d62 100644 --- a/plugins/dualGovernance/components/proposal/description.tsx +++ b/plugins/dualGovernance/components/proposal/description.tsx @@ -19,16 +19,14 @@ export default function ProposalDescription(proposal: Proposal) {

Actions

-
+

The proposal has no actions

{proposal.actions?.map?.((action, i) => ( - +
+ +
))}
diff --git a/plugins/dualGovernance/components/vote/vetoes-section.tsx b/plugins/dualGovernance/components/vote/vetoes-section.tsx index 2d2d8ab..f0726c3 100644 --- a/plugins/dualGovernance/components/vote/vetoes-section.tsx +++ b/plugins/dualGovernance/components/vote/vetoes-section.tsx @@ -2,7 +2,7 @@ import Blockies from "react-blockies"; import { VetoCastEvent } from "@/plugins/dualGovernance/utils/types"; import { formatUnits } from "viem"; import { AddressText } from "@/components/text/address"; -import { Card, Tag } from "@aragon/ods"; +import { Card } from "@aragon/ods"; import { compactNumber } from "@/utils/numbers"; import { If } from "@/components/if"; @@ -40,7 +40,6 @@ const VetoCard = function ({ veto }: { veto: VetoCastEvent }) {

- ); diff --git a/plugins/dualGovernance/pages/new.tsx b/plugins/dualGovernance/pages/new.tsx index e415a18..4c1f167 100644 --- a/plugins/dualGovernance/pages/new.tsx +++ b/plugins/dualGovernance/pages/new.tsx @@ -176,7 +176,7 @@ export default function Create() { className="pt-2" value={summary} onChange={setSummary} - placeholder="A detailed description for what the proposal is all about" + placeholder="A description for what the proposal is all about" />
@@ -291,16 +291,14 @@ export default function Create() {

Actions

-
- -

The proposal has no actions

-
+
{actions?.map?.((action, i) => ( - + > + +
))}
diff --git a/plugins/dualGovernance/pages/proposal.tsx b/plugins/dualGovernance/pages/proposal.tsx index 731df84..7c7d1ec 100644 --- a/plugins/dualGovernance/pages/proposal.tsx +++ b/plugins/dualGovernance/pages/proposal.tsx @@ -81,6 +81,7 @@ export default function ProposalDetail({ id: proposalId }: { id: string }) { {bottomSection === "description" ? "Description" : "Vetoes"} diff --git a/plugins/tokenVoting/components/proposal/description.tsx b/plugins/tokenVoting/components/proposal/description.tsx index 78545d5..4eed2af 100644 --- a/plugins/tokenVoting/components/proposal/description.tsx +++ b/plugins/tokenVoting/components/proposal/description.tsx @@ -19,16 +19,14 @@ export default function ProposalDescription(proposal: Proposal) {

Actions

-
+

The proposal has no actions

{proposal.actions?.map?.((action, i) => ( - +
+ +
))}
diff --git a/plugins/tokenVoting/pages/new.tsx b/plugins/tokenVoting/pages/new.tsx index 3304294..3578712 100644 --- a/plugins/tokenVoting/pages/new.tsx +++ b/plugins/tokenVoting/pages/new.tsx @@ -175,7 +175,7 @@ export default function Create() { className="pt-2" value={summary} onChange={setSummary} - placeholder="A detailed description for what the proposal is all about" + placeholder="A description for what the proposal is all about" />
@@ -290,16 +290,14 @@ export default function Create() {

Actions

-
- -

The proposal has no actions

-
+
{actions?.map?.((action, i) => ( - + > + +
))}
diff --git a/plugins/tokenVoting/pages/proposal.tsx b/plugins/tokenVoting/pages/proposal.tsx index 1badb18..2c35c50 100644 --- a/plugins/tokenVoting/pages/proposal.tsx +++ b/plugins/tokenVoting/pages/proposal.tsx @@ -149,6 +149,7 @@ export default function ProposalDetail({ id: proposalId }: { id: string }) { {bottomSection === "description" ? "Description" : "Votes"} diff --git a/utils/types.ts b/utils/types.ts index be83054..c57bf24 100644 --- a/utils/types.ts +++ b/utils/types.ts @@ -10,4 +10,5 @@ export interface IAlert { message: string; description?: string; explorerLink?: string; + dismissTimeout?: ReturnType; }