Skip to content

Commit

Permalink
fix: aiEnabled in external api
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Sep 18, 2024
1 parent 92c7537 commit a5dfe07
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/src/js/ui/views/extern-print/generator.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -32,11 +32,18 @@ export default (): m.Component<ExternPrintProps> => {

API.exec<Generator>(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;
Expand Down

0 comments on commit a5dfe07

Please sign in to comment.