Skip to content

Commit 8abd18f

Browse files
authored
fix: Deduplicate lite DAO cards when full DAO exists (#948)
* fix: deduplicate lite DAO cards when full DAO exists Filter out lite DAOs from the explorer list when they have a daoContract field matching a full (on-chain) DAO address, since the full DAO page already shows off-chain polls. * fix: navigate back to full DAO from off-chain poll detail When a user reaches an off-chain poll from a full DAO page, the "back to community" button now returns to the full DAO instead of the lite DAO community page. * fix: thread daoId through ProposalsList to ProposalTableRow The previous navigation fix didn't work because daoId was never passed from the full DAO proposals page through ProposalsList to ProposalTableRow, so route state.daoId was always undefined.
1 parent 8c125bd commit 8abd18f

7 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/modules/explorer/components/ProposalsList.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface Props {
4040
proposalStyle?: any
4141
showFullList?: boolean
4242
filters: undefined | Filters
43+
daoId?: string
4344
}
4445

4546
interface ProposalObj {
@@ -53,7 +54,8 @@ export const ProposalsList: React.FC<Props> = ({
5354
liteProposals,
5455
proposalStyle,
5556
showFullList = true,
56-
filters = undefined
57+
filters = undefined,
58+
daoId
5759
}) => {
5860
const [currentPage, setCurrentPage] = useState(0)
5961
const [offset, setOffset] = useState(0)
@@ -196,7 +198,7 @@ export const ProposalsList: React.FC<Props> = ({
196198
</CustomGrid>
197199
) : (
198200
<div style={{ width: "inherit", marginBottom: 16 }} key={`poll-${i}`}>
199-
<ProposalTableRow poll={p.proposal} />
201+
<ProposalTableRow poll={p.proposal} daoId={daoId} />
200202
</div>
201203
)
202204
)}

src/modules/explorer/pages/Proposals/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ const TezosProposals = () => {
307307
proposals={undefined}
308308
liteProposals={polls}
309309
filters={filters}
310+
daoId={daoId}
310311
/>
311312
)}
312313
{!(polls && polls.length > 0) ? (

src/modules/explorer/pages/User/components/UserMovements.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export const UserMovements: React.FC<{
280280
liteProposals={showActivity ? pollsPosted : pollsPosted?.slice(0, 2)}
281281
showFullList={showActivity}
282282
filters={filters}
283+
daoId={daoId}
283284
/>
284285
)}
285286
{!(proposalsCreated && proposalsCreated.length > 0) && !(pollsPosted && pollsPosted.length > 0) ? (
@@ -304,6 +305,7 @@ export const UserMovements: React.FC<{
304305
liteProposals={showActivity ? votedPolls : votedPolls.slice(0, 2)}
305306
showFullList={showActivity}
306307
filters={filters}
308+
daoId={daoId}
307309
/>
308310
)}
309311
{!(proposalsVoted && proposalsVoted.length > 0) && !(votedPolls && votedPolls.length > 0) ? (

src/modules/lite/explorer/pages/ProposalDetails/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ export const ProposalDetails: React.FC<{ id: string }> = ({ id }) => {
9191
const [isLoading, setIsLoading] = useState(false)
9292

9393
const navigateToDao = () => {
94-
if (historyLength > 1) {
94+
if (state?.daoId) {
95+
navigate.push(`/explorer/dao/${state.daoId}`)
96+
} else if (historyLength > 1) {
9597
navigate.goBack()
9698
} else {
9799
const daoUrl = pathname?.replace(`proposal/${proposalId}`, "")

src/services/services/dao/hooks/useAllDAOs.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ export const useAllDAOs = (network: Network) => {
6565
lite_daos = []
6666
}
6767

68-
return [...homebase_daos, ...lite_daos]
68+
// Filter out lite DAOs that already have a corresponding full (on-chain) DAO,
69+
// since the full DAO page already displays their off-chain polls.
70+
const fullDaoAddresses = new Set(homebase_daos.map((dao: any) => dao.address))
71+
const dedupedLiteDaos = lite_daos.filter((dao: any) => !dao.daoContract || !fullDaoAddresses.has(dao.daoContract))
72+
73+
return [...homebase_daos, ...dedupedLiteDaos]
6974
},
7075
{
7176
// Always create the hook; let the fetcher short-circuit for Etherlink networks.

src/services/services/lite/lite-services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const getLiteDAOs = async (network: string) => {
6868
},
6969
votingAddressesCount: dao.votingAddressesCount,
7070
allowPublicAccess: dao.allowPublicAccess,
71+
daoContract: dao.daoContract,
7172
ledgers: dao.members.map(member => {
7273
return {
7374
holder: {

src/services/services/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export interface DAOListItem {
203203
token: TokenDTO
204204
votingAddressesCount: number
205205
allowPublicAccess: boolean
206+
daoContract?: string
206207
}
207208

208209
export type FetchedDAO = DAODTO & {
@@ -251,4 +252,5 @@ export interface Community {
251252
decimals: string
252253
network: Network
253254
votingAddressesCount: number
255+
daoContract?: string
254256
}

0 commit comments

Comments
 (0)