diff --git a/app/components/editor/hooks/useIndex.tsx b/app/components/editor/hooks/useIndex.tsx index 7252d80..ce7f95d 100644 --- a/app/components/editor/hooks/useIndex.tsx +++ b/app/components/editor/hooks/useIndex.tsx @@ -41,6 +41,9 @@ export default function useIndex() { setEcho(
Loading Shared Content...
); fetch(`https://dpaste.com/${hash}.txt`) .then((resp) => { + if (!resp.ok) { + throw new Error(`HTTP error! status: ${resp.status}`); + } return resp.text(); }) .then((content) => { @@ -49,11 +52,7 @@ export default function useIndex() { setModelTextPersistent(sharedContent.model); setCustomConfigPersistent(sharedContent.customConfig); setRequestPersistent(sharedContent.request); - setRequestPersistent(sharedContent.request); - if (sharedContent.enforceContext) { - setEnforceContextDataPersistent(new Map(Object.entries(sharedContent.enforceContext))); - } - setRequestResult(''); + setModelKind(sharedContent.modelKind); window.location.hash = ''; // prevent duplicate load setEcho(
Shared Content Loaded.
); }) diff --git a/app/components/editor/hooks/useShareInfo.tsx b/app/components/editor/hooks/useShareInfo.tsx index 02c02a9..15697c8 100644 --- a/app/components/editor/hooks/useShareInfo.tsx +++ b/app/components/editor/hooks/useShareInfo.tsx @@ -19,11 +19,12 @@ interface ShareProps extends ShareFormat { } export interface ShareFormat { + modelKind: string; model: string; policy: string; customConfig: string; request: string; - enforceContext: object; + requestResult: object; } async function dpaste(content: string) { @@ -43,11 +44,12 @@ export default function useShareInfo() { setSharing(true); props.onResponse(
Sharing...
); const shareContent: ShareFormat = { + modelKind: props.modelKind, model: props.model, policy: props.policy, customConfig: props.customConfig, request: props.request, - enforceContext: props.enforceContext, + requestResult: props.requestResult, }; dpaste(JSON.stringify(shareContent)).then((url: string) => { setSharing(false); diff --git a/app/components/editor/index.tsx b/app/components/editor/index.tsx index 60bc8d9..6289a78 100755 --- a/app/components/editor/index.tsx +++ b/app/components/editor/index.tsx @@ -422,11 +422,12 @@ export const EditorScreen = () => { onResponse: (v) => { return handleShare(v); }, + modelKind, model: modelText, policy, customConfig, request, - enforceContext: Object.entries(enforceContextData), + requestResult: Array.from(enforceContextData.entries()), }); }} > diff --git a/next.config.mjs b/next.config.mjs index 9a147bf..de63c65 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,6 +1,7 @@ import GenerateCasbinVersionPlugin from './generateCasbinVersionPlugin.js'; /** @type {import('next').NextConfig} */ const nextConfig = { + // reactStrictMode: false, /** * Enable static exports for the App Router. *