From 9d8465c9508c5f1ee4df531a39c3359d01bbb8cb Mon Sep 17 00:00:00 2001 From: wvffle Date: Thu, 21 Jul 2022 20:25:34 +0000 Subject: [PATCH] Fetch notification count only when logged in --- .gitpod/Dockerfile | 2 +- front/src/components/Sidebar.vue | 36 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.gitpod/Dockerfile b/.gitpod/Dockerfile index 0a4f54706..1603291a6 100644 --- a/.gitpod/Dockerfile +++ b/.gitpod/Dockerfile @@ -1,4 +1,4 @@ -FROM gitpod/workspace-full:2022-07-17-14-41-27 +FROM gitpod/workspace-full:2022-07-12-11-05-29 USER gitpod RUN sudo apt update -y \ diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue index 636cb1135..e20d9378b 100644 --- a/front/src/components/Sidebar.vue +++ b/front/src/components/Sidebar.vue @@ -95,26 +95,28 @@ const moderationNotifications = computed(() => ) onMounted(async () => { - const [edits, reports, requests] = await Promise.all([ - axios.get('mutations/', { params: { page_size: 1, q: 'is_approved:null' } }).catch(() => ({ data: { count: 0 } })), - axios.get('manage/moderation/reports/', { params: { page_size: 1, q: 'resolved:no' } }).catch(() => ({ data: { count: 0 } })), - axios.get('manage/moderation/requests/', { params: { page_size: 1, q: 'status:pending' } }).catch(() => ({ data: { count: 0 } })) - ]) + if (store.state.auth.authenticated) { + const [edits, reports, requests] = await Promise.all([ + axios.get('mutations/', { params: { page_size: 1, q: 'is_approved:null' } }).catch(() => ({ data: { count: 0 } })), + axios.get('manage/moderation/reports/', { params: { page_size: 1, q: 'resolved:no' } }).catch(() => ({ data: { count: 0 } })), + axios.get('manage/moderation/requests/', { params: { page_size: 1, q: 'status:pending' } }).catch(() => ({ data: { count: 0 } })) + ]) - store.commit('ui/incrementNotifications', { - type: 'pendingReviewEdits', - value: edits.data.count - }) + store.commit('ui/incrementNotifications', { + type: 'pendingReviewEdits', + value: edits.data.count + }) - store.commit('ui/incrementNotifications', { - type: 'pendingReviewRequests', - value: requests.data.count - }) + store.commit('ui/incrementNotifications', { + type: 'pendingReviewRequests', + value: requests.data.count + }) - store.commit('ui/incrementNotifications', { - type: 'pendingReviewReports', - value: reports.data.count - }) + store.commit('ui/incrementNotifications', { + type: 'pendingReviewReports', + value: reports.data.count + }) + } }) const isProduction = import.meta.env.PROD