Spaces:
Sleeping
Sleeping
Commit ·
27d7043
1
Parent(s): ab1f587
I see this error with the app, reported by NextJS, please fix it. The er
Browse files
src/app/journey/[journeyId]/summary/page.tsx
CHANGED
|
@@ -90,7 +90,7 @@ export default function SummaryPage() {
|
|
| 90 |
} else {
|
| 91 |
setPageError("Failed to load and process the journey image. The summary cannot be generated.");
|
| 92 |
setImageDataUri(null);
|
| 93 |
-
setIsLoadingJourneyData(false);
|
| 94 |
}
|
| 95 |
}
|
| 96 |
})
|
|
@@ -98,14 +98,13 @@ export default function SummaryPage() {
|
|
| 98 |
if (isMounted) {
|
| 99 |
setPageError("An error occurred while converting the image. The summary cannot be generated.");
|
| 100 |
setImageDataUri(null);
|
| 101 |
-
setIsLoadingJourneyData(false);
|
| 102 |
}
|
| 103 |
})
|
| 104 |
.finally(() => {
|
| 105 |
-
// Only set isLoadingJourneyData to false if it hasn't been set by an error condition already
|
| 106 |
if (isMounted && isLoadingJourneyData && !imageDataUri && !pageError) {
|
| 107 |
setIsLoadingJourneyData(false);
|
| 108 |
-
} else if (isMounted && imageDataUri) {
|
| 109 |
setIsLoadingJourneyData(false);
|
| 110 |
}
|
| 111 |
});
|
|
@@ -120,7 +119,7 @@ export default function SummaryPage() {
|
|
| 120 |
if (!isMounted) return;
|
| 121 |
setIsLoadingSummary(true);
|
| 122 |
try {
|
| 123 |
-
const result = await summarizeImage({ imageDataUri: imageDataUri });
|
| 124 |
if (isMounted) {
|
| 125 |
if (result && result.summary) {
|
| 126 |
setSummary(result.summary);
|
|
@@ -137,9 +136,8 @@ export default function SummaryPage() {
|
|
| 137 |
console.error('Error generating summary:', fetchError);
|
| 138 |
const errorMessage = fetchError instanceof Error ? fetchError.message : "An unknown error occurred during summary generation.";
|
| 139 |
if (isMounted) {
|
| 140 |
-
// Set summary to the error message so it's displayed directly in the summary area
|
| 141 |
setSummary(`Failed to generate summary: ${errorMessage}`);
|
| 142 |
-
toast({
|
| 143 |
title: "Summary Generation Error",
|
| 144 |
description: `Could not generate summary. ${errorMessage}`,
|
| 145 |
variant: "destructive",
|
|
@@ -155,7 +153,7 @@ export default function SummaryPage() {
|
|
| 155 |
}, [isLoadingJourneyData, imageDataUri, pageError, summary, isLoadingSummary, toast]);
|
| 156 |
|
| 157 |
|
| 158 |
-
if (!isLoadingJourneyData && pageError && !journey) {
|
| 159 |
return (
|
| 160 |
<div className="flex min-h-screen flex-col">
|
| 161 |
<AppHeader
|
|
@@ -176,7 +174,7 @@ export default function SummaryPage() {
|
|
| 176 |
);
|
| 177 |
}
|
| 178 |
|
| 179 |
-
if (isLoadingJourneyData && !pageError) {
|
| 180 |
return (
|
| 181 |
<div className="flex min-h-screen flex-col">
|
| 182 |
<AppHeader
|
|
@@ -247,7 +245,6 @@ export default function SummaryPage() {
|
|
| 247 |
{summary}
|
| 248 |
</div>
|
| 249 |
)}
|
| 250 |
-
{/* Display summary error directly in the content area */}
|
| 251 |
{!isLoadingSummary && summary && summary.startsWith("Failed to generate summary:") && (
|
| 252 |
<Alert variant="destructive">
|
| 253 |
<AlertTriangle className="h-4 w-4" />
|
|
@@ -255,7 +252,6 @@ export default function SummaryPage() {
|
|
| 255 |
<AlertDescription>{summary.replace("Failed to generate summary: ", "")}</AlertDescription>
|
| 256 |
</Alert>
|
| 257 |
)}
|
| 258 |
-
{/* Display page-level error (e.g., image load failed) if summary wasn't even attempted */}
|
| 259 |
{!isLoadingSummary && !summary && pageError && (
|
| 260 |
<Alert variant="destructive">
|
| 261 |
<AlertTriangle className="h-4 w-4" />
|
|
@@ -263,7 +259,6 @@ export default function SummaryPage() {
|
|
| 263 |
<AlertDescription>{pageError}</AlertDescription>
|
| 264 |
</Alert>
|
| 265 |
)}
|
| 266 |
-
{/* Fallback for when summary is null, no error, but image URI might be missing post-loading */}
|
| 267 |
{!isLoadingSummary && !summary && !pageError && !imageDataUri && !isLoadingJourneyData && (
|
| 268 |
<Alert variant="default">
|
| 269 |
<AlertTriangle className="h-4 w-4" />
|
|
@@ -283,4 +278,3 @@ export default function SummaryPage() {
|
|
| 283 |
</div>
|
| 284 |
);
|
| 285 |
}
|
| 286 |
-
|
|
|
|
| 90 |
} else {
|
| 91 |
setPageError("Failed to load and process the journey image. The summary cannot be generated.");
|
| 92 |
setImageDataUri(null);
|
| 93 |
+
setIsLoadingJourneyData(false);
|
| 94 |
}
|
| 95 |
}
|
| 96 |
})
|
|
|
|
| 98 |
if (isMounted) {
|
| 99 |
setPageError("An error occurred while converting the image. The summary cannot be generated.");
|
| 100 |
setImageDataUri(null);
|
| 101 |
+
setIsLoadingJourneyData(false);
|
| 102 |
}
|
| 103 |
})
|
| 104 |
.finally(() => {
|
|
|
|
| 105 |
if (isMounted && isLoadingJourneyData && !imageDataUri && !pageError) {
|
| 106 |
setIsLoadingJourneyData(false);
|
| 107 |
+
} else if (isMounted && imageDataUri) {
|
| 108 |
setIsLoadingJourneyData(false);
|
| 109 |
}
|
| 110 |
});
|
|
|
|
| 119 |
if (!isMounted) return;
|
| 120 |
setIsLoadingSummary(true);
|
| 121 |
try {
|
| 122 |
+
const result = await summarizeImage({ imageDataUri: imageDataUri });
|
| 123 |
if (isMounted) {
|
| 124 |
if (result && result.summary) {
|
| 125 |
setSummary(result.summary);
|
|
|
|
| 136 |
console.error('Error generating summary:', fetchError);
|
| 137 |
const errorMessage = fetchError instanceof Error ? fetchError.message : "An unknown error occurred during summary generation.";
|
| 138 |
if (isMounted) {
|
|
|
|
| 139 |
setSummary(`Failed to generate summary: ${errorMessage}`);
|
| 140 |
+
toast({
|
| 141 |
title: "Summary Generation Error",
|
| 142 |
description: `Could not generate summary. ${errorMessage}`,
|
| 143 |
variant: "destructive",
|
|
|
|
| 153 |
}, [isLoadingJourneyData, imageDataUri, pageError, summary, isLoadingSummary, toast]);
|
| 154 |
|
| 155 |
|
| 156 |
+
if (!isLoadingJourneyData && pageError && !journey) {
|
| 157 |
return (
|
| 158 |
<div className="flex min-h-screen flex-col">
|
| 159 |
<AppHeader
|
|
|
|
| 174 |
);
|
| 175 |
}
|
| 176 |
|
| 177 |
+
if (isLoadingJourneyData && !pageError) {
|
| 178 |
return (
|
| 179 |
<div className="flex min-h-screen flex-col">
|
| 180 |
<AppHeader
|
|
|
|
| 245 |
{summary}
|
| 246 |
</div>
|
| 247 |
)}
|
|
|
|
| 248 |
{!isLoadingSummary && summary && summary.startsWith("Failed to generate summary:") && (
|
| 249 |
<Alert variant="destructive">
|
| 250 |
<AlertTriangle className="h-4 w-4" />
|
|
|
|
| 252 |
<AlertDescription>{summary.replace("Failed to generate summary: ", "")}</AlertDescription>
|
| 253 |
</Alert>
|
| 254 |
)}
|
|
|
|
| 255 |
{!isLoadingSummary && !summary && pageError && (
|
| 256 |
<Alert variant="destructive">
|
| 257 |
<AlertTriangle className="h-4 w-4" />
|
|
|
|
| 259 |
<AlertDescription>{pageError}</AlertDescription>
|
| 260 |
</Alert>
|
| 261 |
)}
|
|
|
|
| 262 |
{!isLoadingSummary && !summary && !pageError && !imageDataUri && !isLoadingJourneyData && (
|
| 263 |
<Alert variant="default">
|
| 264 |
<AlertTriangle className="h-4 w-4" />
|
|
|
|
| 278 |
</div>
|
| 279 |
);
|
| 280 |
}
|
|
|