add auto polling in frontend for contributions list, default off

This commit is contained in:
einhornimmond 2025-05-13 11:46:13 +02:00
parent 2c9e4d5bde
commit 7c991efbb8
5 changed files with 21 additions and 3 deletions

View File

@ -29,13 +29,14 @@
</div>
</template>
<script setup>
import { ref, computed, watch, watchEffect, onMounted } from 'vue'
import { ref, computed } from 'vue'
import ContributionListItem from '@/components/Contributions/ContributionListItem.vue'
import { listContributions, listAllContributions } from '@/graphql/contributions.graphql'
import { useQuery } from '@vue/apollo-composable'
import { PAGE_SIZE } from '@/constants'
import { useAppToast } from '@/composables/useToast'
import { useI18n } from 'vue-i18n'
import CONFIG from '@/config'
const props = defineProps({
allContribution: {
@ -56,6 +57,7 @@ const { t } = useI18n()
// constants
const pageSize = PAGE_SIZE
const pollInterval = CONFIG.AUTO_POLL_INTERVAL || undefined
// refs
const currentPage = ref(1)
@ -78,7 +80,7 @@ const { result, loading, refetch } = useQuery(
}
: undefined,
}),
{ fetchPolicy: 'cache-and-network' },
{ fetchPolicy: 'cache-and-network', pollInterval },
)
// events
@ -94,7 +96,7 @@ const contributionCount = computed(() => {
return contributionListResult.value?.contributionCount || 0
})
const items = computed(() => {
return contributionListResult.value?.contributionList || []
return [...(contributionListResult.value?.contributionList || [])]
})
const isPaginationVisible = computed(() => {
return contributionCount.value > pageSize

View File

@ -230,6 +230,13 @@ watch(
{ immediate: true },
)
watch(
() => props.contributionStatus,
() => {
localStatus.value = props.contributionStatus
},
)
const statusMapping = {
CONFIRMED: { variant: 'success', icon: 'check' },
DELETED: { variant: 'danger', icon: 'trash' },

View File

@ -40,6 +40,7 @@ if (process.env.FRONTEND_HOSTING === 'nodejs') {
const features = {
GMS_ACTIVE: process.env.GMS_ACTIVE === 'true',
HUMHUB_ACTIVE: process.env.HUMHUB_ACTIVE === 'true',
AUTO_POLL_INTERVAL: Number.parseInt(process.env.AUTO_POLL_INTERVAL) ?? 0,
}
const environment = {

View File

@ -42,6 +42,13 @@ module.exports = Joi.object({
.default('http://0.0.0.0/admin/authenticate?token=')
.required(),
AUTO_POLL_INTERVAL: Joi.number()
.integer()
.min(0)
.max(600000)
.description('Auto Polling for new data in ms. 0 = disabled = default. Experimental!')
.default(0),
COMMUNITY_REGISTER_URL: Joi.string()
.uri({ scheme: ['http', 'https'] })
.description('URL for Register a new Account in frontend.')

View File

@ -97,6 +97,7 @@ export default defineConfig(async ({ command }) => {
autoInstall: true,
}),
EnvironmentPlugin({
AUTO_POLL_INTERVAL: CONFIG.AUTO_POLL_INTERVAL,
GMS_ACTIVE: CONFIG.GMS_ACTIVE,
HUMHUB_ACTIVE: CONFIG.HUMHUB_ACTIVE,
DEFAULT_PUBLISHER_ID: null,