This repository has been archived by the owner on Mar 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
269 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script setup lang="ts"> | ||
import { provideApolloClient, useQuery } from '@vue/apollo-composable' | ||
import { ApolloClient } from '@apollo/client/core' | ||
import gql from 'graphql-tag' | ||
import { getClientOptions } from 'src/apollo' | ||
import { useBlockStore } from 'src/stores/block' | ||
import { useReviewStore } from 'src/stores/review' | ||
import { computed, onMounted, watch } from 'vue' | ||
import { targetChain } from 'src/stores/chain' | ||
import { useApplicationStore } from 'src/stores/application' | ||
const block = useBlockStore() | ||
const blockHeight = computed(() => block.blockHeight) | ||
const review = useReviewStore() | ||
const application = useApplicationStore() | ||
const reviewApp = computed(() => application.reviewApp) | ||
const options = /* await */ getClientOptions(/* {app, router ...} */) | ||
const apolloClient = new ApolloClient(options) | ||
const ready = () => { | ||
return targetChain.value?.length > 0 && reviewApp.value?.length > 0 | ||
} | ||
const getActivityApplicationsKeys = () => { | ||
const { /* result, refetch, fetchMore, */ onResult /*, onError */ } = provideApolloClient(apolloClient)(() => useQuery(gql` | ||
query getActivityApplicationsKeys { | ||
activityApplicationsKeys | ||
} | ||
`, { | ||
endpoint: 'review', | ||
chainId: targetChain.value | ||
}, { | ||
fetchPolicy: 'network-only' | ||
})) | ||
onResult((res) => { | ||
if (res.loading) return | ||
review.activityApplicationsKeys = (res.data as Record<string, Array<number>>).activityApplicationsKeys | ||
}) | ||
} | ||
watch(blockHeight, () => { | ||
if (!ready()) return | ||
getActivityApplicationsKeys() | ||
}) | ||
watch(reviewApp, () => { | ||
if (!ready()) return | ||
getActivityApplicationsKeys() | ||
}) | ||
watch(targetChain, () => { | ||
if (!ready()) return | ||
getActivityApplicationsKeys() | ||
}) | ||
onMounted(() => { | ||
if (!ready()) return | ||
getActivityApplicationsKeys() | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<script setup lang="ts"> | ||
import { provideApolloClient, useQuery } from '@vue/apollo-composable' | ||
import { ApolloClient } from '@apollo/client/core' | ||
import gql from 'graphql-tag' | ||
import { getClientOptions } from 'src/apollo' | ||
import { useReviewStore, Activity } from 'src/stores/review' | ||
import { computed, watch, ref, onMounted } from 'vue' | ||
import { useBlockStore } from 'src/stores/block' | ||
import { targetChain } from 'src/stores/chain' | ||
const review = useReviewStore() | ||
const activityApplicationsKeys = computed(() => review.activityApplicationsKeys) | ||
const activityApplications = computed(() => review.activityApplications) | ||
const activityMutateKeys = computed(() => review.activityMutateKeys) | ||
const activityIndex = ref(-1) | ||
const activityApplicationKey = computed(() => activityIndex.value >= 0 ? activityApplicationsKeys.value[activityIndex.value] : undefined) | ||
const block = useBlockStore() | ||
const blockHeight = computed(() => block.blockHeight) | ||
const options = /* await */ getClientOptions(/* {app, router ...} */) | ||
const apolloClient = new ApolloClient(options) | ||
const getActivityApplication = (activityApplicationKey: number, done?: () => void) => { | ||
const { result /*, fetchMore, onResult, onError */ } = provideApolloClient(apolloClient)(() => useQuery(gql` | ||
query getActivityApplication($activityApplicationKey: Int!) { | ||
activityApplications(u64: $activityApplicationKey) { | ||
activityId | ||
budgetAmount | ||
reviewers | ||
approved | ||
rejected | ||
createdAt | ||
} | ||
} | ||
`, { | ||
activityApplicationKey, | ||
endpoint: 'review', | ||
chainId: targetChain.value | ||
}, { | ||
fetchPolicy: 'network-only' | ||
})) | ||
watch(result, () => { | ||
activityApplications.value.set(activityApplicationKey, (result.value as Record<string, Activity>).activityApplications) | ||
done?.() | ||
}) | ||
} | ||
watch(activityApplicationKey, () => { | ||
if (!activityApplicationKey.value) { | ||
return | ||
} | ||
const index = activityMutateKeys.value.findIndex((el) => el === activityApplicationKey.value) | ||
if (activityApplications.value.get(activityApplicationKey.value) && index < 0) { | ||
activityIndex.value++ | ||
return | ||
} | ||
getActivityApplication(activityApplicationKey.value, () => { | ||
activityIndex.value++ | ||
activityMutateKeys.value.splice(index, 1) | ||
}) | ||
}) | ||
watch(activityApplicationsKeys, () => { | ||
if (activityApplicationsKeys.value.length === 0) { | ||
return | ||
} | ||
activityIndex.value = 0 | ||
}) | ||
watch(blockHeight, () => { | ||
if (activityApplicationsKeys.value.length === 0) { | ||
return | ||
} | ||
activityIndex.value = 0 | ||
}) | ||
onMounted(() => { | ||
activityMutateKeys.value.forEach((activityKey) => { | ||
getActivityApplication(activityKey) | ||
}) | ||
review.activityMutateKeys = [] | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.