From c1ecd0ea5f3f3b4f531ddd6b2028d04decf65d7a Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 8 Mar 2021 13:46:20 +0900 Subject: [PATCH] Update middleware to prevent calling method many times --- frontend/middleware/check-admin.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/middleware/check-admin.js b/frontend/middleware/check-admin.js index c4168a2e..92cd6f7d 100644 --- a/frontend/middleware/check-admin.js +++ b/frontend/middleware/check-admin.js @@ -1,4 +1,6 @@ -export default async function({ app, store, route, redirect }) { +import _ from 'lodash' + +export default _.debounce(async function({ app, store, route, redirect }) { try { await store.dispatch('projects/setCurrentProject', route.params.id) } catch(e) { @@ -10,4 +12,4 @@ export default async function({ app, store, route, redirect }) { if (!role.is_project_admin && path !== projectRoot) { return redirect(projectRoot) } -} +}, 1000)