Browse Source

Merge pull request #3572 from nocodb/fix/feedback-form

fix: drop await / errors from feed-back form handler
pull/3504/head
mertmit 2 years ago committed by GitHub
parent
commit
1f611d19f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      packages/nc-gui/plugins/initializeFeedbackForm.ts
  2. 2
      packages/nocodb/src/lib/meta/api/utilApis.ts

32
packages/nc-gui/plugins/initializeFeedbackForm.ts

@ -1,4 +1,3 @@
import type { Dayjs } from 'dayjs'
import dayjs from 'dayjs'
import { defineNuxtPlugin } from '#app'
@ -8,9 +7,18 @@ const handleFeedbackForm = async () => {
const { $api } = useNuxtApp()
const fetchFeedbackForm = async (now: Dayjs) => {
const isFirstTimePolling = !currentFeedbackForm.lastFormPollDate
const now = dayjs()
const lastFormPolledDate = dayjs(currentFeedbackForm.lastFormPollDate)
if (isFirstTimePolling || dayjs.duration(now.diff(lastFormPolledDate)).days() > 0) {
$api.instance
.get('/api/v1/feedback_form')
.then((response) => {
try {
const { data: feedbackForm } = await $api.instance.get('/api/v1/feedback_form')
const { data: feedbackForm } = response
if (!feedbackForm.error) {
const isFetchedFormDuplicate = currentFeedbackForm.url === feedbackForm.url
currentFeedbackForm = {
@ -19,21 +27,13 @@ const handleFeedbackForm = async () => {
createdAt: feedbackForm.created_at,
isHidden: isFetchedFormDuplicate ? currentFeedbackForm.isHidden : false,
}
} catch (e) {
console.error(e)
}
}
const isFirstTimePolling = !currentFeedbackForm.lastFormPollDate
const now = dayjs()
const lastFormPolledDate = dayjs(currentFeedbackForm.lastFormPollDate)
if (isFirstTimePolling || dayjs.duration(now.diff(lastFormPolledDate)).days() > 0) {
await fetchFeedbackForm(now)
} catch (e) {}
})
.catch(() => {})
}
}
export default defineNuxtPlugin(async () => {
await handleFeedbackForm()
export default defineNuxtPlugin(() => {
handleFeedbackForm()
})

2
packages/nocodb/src/lib/meta/api/utilApis.ts

@ -89,7 +89,7 @@ export async function feedbackFormGet(_req: Request, res: Response) {
res.json(response.data);
})
.catch((e) => {
res.status(500).json({ error: e.message });
res.json({ error: e.message });
});
}

Loading…
Cancel
Save