Skip to content

Commit

Permalink
fixed graphql query so ensure social links are obtained; made sure so…
Browse files Browse the repository at this point in the history
…cial links open in new tab (#121)
  • Loading branch information
krisbitney authored Jan 29, 2024
1 parent 559ff7c commit e608c46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 67 deletions.
20 changes: 10 additions & 10 deletions packages/app/src/components/ViewCollective.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,26 @@ function ViewCollective({ collective }: ViewCollectiveProps) {
<Text style={styles.description}>{ipfs.description}</Text>
<View style={[styles.icons, { position: 'absolute', bottom: 0, left: 25 }]}>
{collective.ipfs.website && (
<Link href={collective.ipfs.website}>
<Link href={collective.ipfs.website} isExternal>
<Image source={WebIcon} style={styles.rowIcon} />
</Link>
)}
{collective.ipfs.twitter && (
<Link href={collective.ipfs.twitter}>
<Link href={collective.ipfs.twitter} isExternal>
<Image source={TwitterIcon} style={styles.rowIcon} />
</Link>
)}
{collective.ipfs.instagram && (
<Link href={collective.ipfs.instagram}>
<Link href={collective.ipfs.instagram} isExternal>
<Image source={InstagramIcon} style={styles.rowIcon} />
</Link>
)}
{collective.ipfs.threads && (
<Link href={collective.ipfs.threads}>
<Link href={collective.ipfs.threads} isExternal>
<Image source={AtIcon} style={styles.rowIcon} />
</Link>
)}
<Link href={`https://explorer.celo.org/mainnet/address/${poolAddress}`}>
<Link href={`https://explorer.celo.org/mainnet/address/${poolAddress}`} isExternal>
<Image source={LastRowIcon} style={styles.rowIcon} />
</Link>
</View>
Expand Down Expand Up @@ -249,26 +249,26 @@ function ViewCollective({ collective }: ViewCollectiveProps) {
<Text style={styles.description}>{ipfs.description}</Text>
<View style={styles.icons}>
{collective.ipfs.website && (
<Link href={collective.ipfs.website}>
<Link href={collective.ipfs.website} isExternal>
<Image source={WebIcon} style={styles.rowIcon} />
</Link>
)}
{collective.ipfs.twitter && (
<Link href={collective.ipfs.twitter}>
<Link href={collective.ipfs.twitter} isExternal>
<Image source={TwitterIcon} style={styles.rowIcon} />
</Link>
)}
{collective.ipfs.instagram && (
<Link href={collective.ipfs.instagram}>
<Link href={collective.ipfs.instagram} isExternal>
<Image source={InstagramIcon} style={styles.rowIcon} />
</Link>
)}
{collective.ipfs.threads && (
<Link href={collective.ipfs.threads}>
<Link href={collective.ipfs.threads} isExternal>
<Image source={AtIcon} style={styles.rowIcon} />
</Link>
)}
<Link href={`https://explorer.celo.org/mainnet/address/${poolAddress}`}>
<Link href={`https://explorer.celo.org/mainnet/address/${poolAddress}`} isExternal>
<Image source={LastRowIcon} style={styles.rowIcon} />
</Link>
</View>
Expand Down
60 changes: 3 additions & 57 deletions packages/app/src/subgraph/useSubgraphCollective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { gql } from '@apollo/client';
import { CollectivesSubgraphResponse, useSubgraphData } from './useSubgraphData';
import { SubgraphCollective } from './subgraphModels';

export const collective = gql`
query COLLECTIVE($id: String) {
collectives(where: { id: $id }) {
export const collectivesById = gql`
query COLLECTIVES_BY_ID($ids: [String!]) {
collectives(where: { id_in: $ids }) {
id
ipfs {
id
Expand Down Expand Up @@ -49,60 +49,6 @@ export const collective = gql`
}
`;

export const collectivesById = gql`
query COLLECTIVES_BY_ID($ids: [String!]) {
collectives(where: { id_in: $ids }) {
id
ipfs {
id
name
description
headerImage
}
stewards {
id
steward {
id
}
collective {
id
}
actions
totalEarned
}
donors {
id
donor {
id
}
collective {
id
}
contribution
timestamp
flowRate
}
timestamp
paymentsMade
totalDonations
totalRewards
}
}
`;

export function useSubgraphCollective(id: string): SubgraphCollective | undefined {
const response = useSubgraphData(collective, {
variables: {
id: id,
},
});
const data = (response as CollectivesSubgraphResponse).collectives;
if (!data || data.length === 0) {
return undefined;
}
return data[0];
}

export function useSubgraphCollectivesById(ids: string[]): SubgraphCollective[] | undefined {
const response = useSubgraphData(collectivesById, {
variables: {
Expand Down

0 comments on commit e608c46

Please sign in to comment.