From 73f724746b947e61fe2e086cff43a4325fb2ce91 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Fri, 1 Oct 2021 21:40:59 +0500 Subject: [PATCH] updated addReport method to support report type --- .../container/postDropdownContainer.tsx | 2 +- src/providers/ecency/ecency.ts | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/postDropdown/container/postDropdownContainer.tsx b/src/components/postDropdown/container/postDropdownContainer.tsx index 9d6c96e42..688476459 100644 --- a/src/components/postDropdown/container/postDropdownContainer.tsx +++ b/src/components/postDropdown/container/postDropdownContainer.tsx @@ -124,7 +124,7 @@ class PostDropdownContainer extends PureComponent { const { dispatch, intl } = this.props; const _onConfirm = () => { - addReport(url) + addReport('content', url) .then(() => { dispatch( toastNotification( diff --git a/src/providers/ecency/ecency.ts b/src/providers/ecency/ecency.ts index c44b0ca33..ec9bf236c 100644 --- a/src/providers/ecency/ecency.ts +++ b/src/providers/ecency/ecency.ts @@ -160,12 +160,20 @@ export const deleteBookmark = async (bookmarkId:string) => { } -export const addReport = (url) => - api +export const addReport = async (type:'content'|'user', data:string) => { + try { + const response = await api .post('/report', { - url, + type, + data }) - .then((resp) => resp.data); + return response.data + } catch(err){ + console.warn("Failed to report to ecency") + bugsnagInstance.notify(err); + throw err; + } +} /**