Merge pull request #3476 from gradido/fix_frontend_community_messsages_reload

fix(frontend): community messsages reload
This commit is contained in:
einhornimmond 2025-04-29 20:38:39 +02:00 committed by GitHub
commit 467aeaed23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 4 deletions

View File

@ -67,6 +67,7 @@ const props = defineProps({
})
const emit = defineEmits([
'close-all-open-collapse',
'update-list-contributions',
'update-contribution-form',
'delete-contribution',

View File

@ -14,6 +14,7 @@ vi.mock('@vue/apollo-composable', () => ({
onResult: vi.fn(),
onError: vi.fn(),
load: vi.fn(),
refetch: vi.fn(),
})),
useMutation: vi.fn(() => ({
mutate: vi.fn(),

View File

@ -246,7 +246,7 @@ function deleteContribution(item) {
}
}
const { onResult, onError, load } = useLazyQuery(listContributionMessages, {
const { onResult, onError, load, refetch } = useLazyQuery(listContributionMessages, {
contributionId: props.contributionId,
})
@ -254,9 +254,15 @@ function getListContributionMessages(closeCollapse = true) {
if (closeCollapse) {
emit('close-all-open-collapse')
}
load(listContributionMessages, {
const variables = {
contributionId: props.contributionId,
})
}
// load works only once and return false on second call
if (!load(listContributionMessages, variables)) {
// update list data every time getListContributionMessages is called
// because it could be added new messages
refetch(variables)
}
}
onResult((resultValue) => {

View File

@ -29,7 +29,7 @@
:show-pagination="true"
:page-size="pageSize"
@close-all-open-collapse="closeAllOpenCollapse"
@update-list-contributions="handleUpdateListAllContributions"
@update-list-contributions="handleUpdateListContributions"
@update-contribution-form="handleUpdateContributionForm"
@delete-contribution="handleDeleteContribution"
@update-status="updateStatus"