Skip to content

Commit cfa3cc8

Browse files
author
jabrock
committed
code cleanup and random number updates to remove requirement on HTTPS
1 parent 6d9d62d commit cfa3cc8

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

app/src/components/app.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ import { createContext } from "preact";
66
type Props = {
77
appName: string;
88
};
9-
const convoUUID = window.crypto.randomUUID();
10-
export const ConvoCtx = createContext(convoUUID);
9+
const tempArray = new Uint32Array(10);
10+
const convoUUID = window.crypto.getRandomValues(tempArray);
11+
12+
export const ConvoCtx = createContext("");
1113

1214
export const App = registerCustomElement("app-root", (props: Props) => {
1315
props.appName = "Generative AI JET UI";
1416

1517
return (
1618
<div id="appContainer" class="oj-web-applayout-page">
17-
<ConvoCtx.Provider value={convoUUID}>
18-
{console.log("UUID: ", convoUUID)}
19+
<ConvoCtx.Provider value={convoUUID[0].toString()}>
20+
{console.log("UUID: ", convoUUID[0].toString())}
1921
<Header appName={props.appName} />
2022
<Content />
2123
</ConvoCtx.Provider>

app/src/components/content/stomp-interface.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const InitStomp = (
99
chatData: any,
1010
serviceType: any
1111
) => {
12-
//const [test, setTest] = useState();
1312
const protocol = window.location.protocol === "http:" ? "ws://" : "wss://";
1413
const hostname =
1514
window.location.hostname === "localhost"
@@ -47,7 +46,6 @@ export const InitStomp = (
4746

4847
const onMessage = (msg: any) => {
4948
let aiAnswer = JSON.parse(msg.body).content;
50-
//console.log("answer: ", aiAnswer);
5149
if (msg.data !== "connected") {
5250
let tempArray = [...chatData.current];
5351
// remove the animation item before adding answer

app/src/components/content/summary.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "preact";
2-
import { useState, useRef, useEffect } from "preact/hooks";
2+
import { useState, useRef, useEffect, useContext } from "preact/hooks";
33
import "md-wrapper/loader";
44
import "ojs/ojtoolbar";
55
import "oj-c/file-picker";
@@ -13,6 +13,7 @@ import { CFilePickerElement } from "oj-c/file-picker";
1313
import { CInputTextElement } from "oj-c/input-text";
1414
import { CButtonElement } from "oj-c/button";
1515
import MutableArrayDataProvider = require("ojs/ojmutablearraydataprovider");
16+
import { ConvoCtx } from "../app";
1617

1718
declare global {
1819
namespace preact.JSX {
@@ -47,6 +48,7 @@ export const Summary = ({
4748
summary,
4849
backendType,
4950
}: Props) => {
51+
const conversationId = useContext(ConvoCtx);
5052
const [invalidMessage, setInvalidMessage] = useState<string | null>(null);
5153
const [summaryPrompt, setSummaryPrompt] = useState<string>("");
5254
const [summaryResults, setSummaryResults] = useState<string | null>(summary);
@@ -89,6 +91,7 @@ export const Summary = ({
8991
mode: "cors",
9092
referrerPolicy: "strict-origin-when-cross-origin",
9193
body: formData,
94+
headers: { conversationID: conversationId, modelId: "" },
9295
});
9396
console.log("Response: ", res);
9497
const responseData = await res.json();
@@ -330,7 +333,11 @@ export const Summary = ({
330333
</>
331334
)}
332335
{invalidFiles.current.length !== 1 && fileNames && summary && (
333-
<div id="summaryContent" class="oj-panel oj-sm-width-full">
336+
<div
337+
id="summaryContent"
338+
class="oj-panel oj-sm-width-full oj-color-invert oj-sm-padding-4x oj-sm-margin-6x-top"
339+
style="background-color: var(--oj-sp-header-welcome-banner-background-color);"
340+
>
334341
<md-wrapper
335342
id="TestingOne"
336343
class="oj-sm-width-full"

0 commit comments

Comments
 (0)