Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: drop await / errors from feed-back form handler #3572

Merged
merged 1 commit into from Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions packages/nc-gui/plugins/initializeFeedbackForm.ts
@@ -1,4 +1,3 @@
import type { Dayjs } from 'dayjs'
import dayjs from 'dayjs'
import { defineNuxtPlugin } from '#app'

Expand All @@ -8,32 +7,33 @@ const handleFeedbackForm = async () => {

const { $api } = useNuxtApp()

const fetchFeedbackForm = async (now: Dayjs) => {
try {
const { data: feedbackForm } = await $api.instance.get('/api/v1/feedback_form')
const isFetchedFormDuplicate = currentFeedbackForm.url === feedbackForm.url

currentFeedbackForm = {
url: feedbackForm.url,
lastFormPollDate: now.toISOString(),
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)
$api.instance
.get('/api/v1/feedback_form')
.then((response) => {
try {
const { data: feedbackForm } = response
if (!feedbackForm.error) {
const isFetchedFormDuplicate = currentFeedbackForm.url === feedbackForm.url

currentFeedbackForm = {
url: feedbackForm.url,
lastFormPollDate: now.toISOString(),
createdAt: feedbackForm.created_at,
isHidden: isFetchedFormDuplicate ? currentFeedbackForm.isHidden : false,
}
}
} catch (e) {}
})
.catch(() => {})
}
}

export default defineNuxtPlugin(async () => {
await handleFeedbackForm()
export default defineNuxtPlugin(() => {
handleFeedbackForm()
})
2 changes: 1 addition & 1 deletion packages/nocodb/src/lib/meta/api/utilApis.ts
Expand Up @@ -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 });
});
}

Expand Down