From 7fe848d1b3638463483ffe20d6f5b17df23a5586 Mon Sep 17 00:00:00 2001
From: flisk <akkomadev.mvch71fq@flisk.xyz>
Date: Wed, 8 Mar 2023 14:36:40 +0100
Subject: [PATCH] only fetch privileged resources when appropriate

always doing these fetches regardless of whether they'll reasonably
succeed is silly and causes a bunch of spurious 403's, which end up as
noise in the server logs. instead, let's not do that.
---
 src/boot/after_store.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index d45584c0..53cf0236 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -399,6 +399,14 @@ const afterStoreSetup = async ({ store, i18n }) => {
   ])
 
   // Start fetching things that don't need to block the UI
+  const currentUser = store.state.users.currentUser
+  if (currentUser) {
+    store.dispatch('fetchMutes')
+    store.dispatch('startFetchingAnnouncements')
+    if (currentUser.role === 'admin' || currentUser.role === 'moderator') {
+      store.dispatch('startFetchingReports')
+    }
+  }
   getTOS({ store })
   getStickers({ store })