From a5dfe07559d3b441f5b75d90c5ba79ada6f692f8 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Wed, 18 Sep 2024 16:59:35 +0200 Subject: [PATCH] fix: aiEnabled in external api --- frontend/src/js/ui/views/extern-print/generator.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/js/ui/views/extern-print/generator.ts b/frontend/src/js/ui/views/extern-print/generator.ts index db22329..265ad98 100644 --- a/frontend/src/js/ui/views/extern-print/generator.ts +++ b/frontend/src/js/ui/views/extern-print/generator.ts @@ -1,6 +1,6 @@ import m from 'mithril'; -import Generator, { sanitizeConfig } from 'js/types/generator'; +import Generator, { sanitizeConfig, seed } from 'js/types/generator'; import * as API from 'js/core/api'; import { settings } from 'js/core/store'; import { render } from 'js/core/templating'; @@ -32,11 +32,18 @@ export default (): m.Component => { API.exec(API.GET_GENERATOR, state.id) .then((gen) => { + const rawConfig = JSON.parse(atob(attrs.config)); + const config = sanitizeConfig(gen, rawConfig); + const aiEnabled = !!rawConfig['aiEnabled']; + const aiToken = rawConfig['aiToken'] ?? config['seed'] ?? seed(); + render(gen.printTemplate, { sources: gen.dataSources, images: gen.images, - config: sanitizeConfig(gen, JSON.parse(atob(attrs.config))), + config: config, settings: settings.value, + aiEnabled: aiEnabled, + aiToken: aiEnabled ? aiToken : undefined, }) .then((res) => { state.gen = res;