From a90ffabeec7dfe2ed00c58a789e55527686aa9e6 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Sat, 1 May 2021 17:15:09 +0200 Subject: [PATCH] Inherits top-level settings for embed function --- source/app/metrics/index.mjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/app/metrics/index.mjs b/source/app/metrics/index.mjs index 446e1e68..1d20df22 100644 --- a/source/app/metrics/index.mjs +++ b/source/app/metrics/index.mjs @@ -94,6 +94,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf, console.debug(error) } //Embed method + const _q = q const embed = async (name, q = {}) => { //Check arguments if ((!name) || (typeof q !== "object") || (q === null)) { @@ -101,10 +102,11 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf, throw new Error("An error occured during embed rendering, dying") return "

⚠️ Failed to execute embed function: invalid arguments

" } + q = {..._q, ...Object.fromEntries(Object.keys(Plugins).map(key => [key, false])), template:"classic", ...q} //Translate action syntax to web syntax let parts = [] - if (q.base === true); - ({parts} = conf.settings.plugins.base) + if (q.base === true) + q.base = _q.base if (typeof q.base === "string") parts = q.base.split(",").map(x => x.trim()) if (Array.isArray(q.base)) @@ -116,10 +118,8 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf, q.config_animations = false } q = Object.fromEntries([...Object.entries(q).map(([key, value]) => [key.replace(/^plugin_/, "").replace(/_/g, "."), value]), ["base", false]]) - //Enable required plugins - const plugins = Object.fromEntries(Object.entries(arguments[1].plugins).map(([key, value]) => [key, {...value, enabled:true}])) //Compute rendering - const {rendered} = await metrics({login, q}, {...arguments[1], plugins, convert:null}, arguments[2]) + const {rendered} = await metrics({login, q}, {...arguments[1], convert:null}, arguments[2]) return `` } //Rendering template source