-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: space user proposals page (#606)
* feat: enable route to proposals tab * feat: list space user proposals * fix(ux): make the sticky header optional * fix: set page title
- Loading branch information
Showing
4 changed files
with
114 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,80 @@ | ||
<script setup lang="ts"></script> | ||
<script setup lang="ts"> | ||
import { getNetwork } from '@/networks'; | ||
import { Proposal, Space, User } from '@/types'; | ||
const props = defineProps<{ space: Space; user: User }>(); | ||
const PROPOSALS_LIMIT = 20; | ||
const metaStore = useMetaStore(); | ||
const { setTitle } = useTitle(); | ||
const loaded = ref(false); | ||
const loadingMore = ref(false); | ||
const hasMore = ref(false); | ||
const proposals = ref<Proposal[]>([]); | ||
const network = computed(() => getNetwork(props.space.network)); | ||
async function fetch() { | ||
loaded.value = false; | ||
proposals.value = await network.value.api.loadProposals( | ||
[props.space.id], | ||
{ | ||
limit: PROPOSALS_LIMIT | ||
}, | ||
metaStore.getCurrent(props.space.network) || 0, | ||
{ author: props.user.id } | ||
); | ||
hasMore.value = proposals.value.length === PROPOSALS_LIMIT; | ||
loaded.value = true; | ||
} | ||
async function fetchMore() { | ||
loadingMore.value = true; | ||
const moreProposals = await network.value.api.loadProposals( | ||
[props.space.id], | ||
{ | ||
limit: PROPOSALS_LIMIT, | ||
skip: proposals.value.length | ||
}, | ||
metaStore.getCurrent(props.space.network) || 0, | ||
{ author: props.user.id } | ||
); | ||
proposals.value = [...proposals.value, ...moreProposals]; | ||
hasMore.value = moreProposals.length === PROPOSALS_LIMIT; | ||
loadingMore.value = false; | ||
} | ||
async function handleEndReached() { | ||
if (!hasMore.value) return; | ||
fetchMore(); | ||
} | ||
onMounted(() => { | ||
fetch(); | ||
}); | ||
watchEffect(() => | ||
setTitle( | ||
`${props.user.name || props.user.id} ${props.space.name}'s proposals` | ||
) | ||
); | ||
</script> | ||
|
||
<template> | ||
<div></div> | ||
<ProposalsList | ||
limit="off" | ||
:loading="!loaded" | ||
:loading-more="loadingMore" | ||
:proposals="proposals" | ||
:show-author="false" | ||
@end-reached="handleEndReached" | ||
/> | ||
</template> |