linking works
This commit is contained in:
+26
-10
@@ -1,12 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useState, Suspense } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import TextEditor from "@/components/text-editor";
|
||||
import { HomelabApp } from "@/types"; // Adjust path if needed
|
||||
import { HomelabApp } from "@/types";
|
||||
|
||||
export default function WritePage() {
|
||||
function WritePageContent() {
|
||||
const searchParams = useSearchParams();
|
||||
const appQuery = searchParams.get("app");
|
||||
|
||||
@@ -21,12 +21,13 @@ export default function WritePage() {
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch apps to find the one matching the query parameter string
|
||||
const apps = (await invoke("get_app")) as HomelabApp[];
|
||||
|
||||
// Match checking both UUID structure and sanitized string names
|
||||
const matchedApp = apps.find(
|
||||
(app) =>
|
||||
app.id === appQuery ||
|
||||
app.name.toLowerCase() === appQuery.toLowerCase(),
|
||||
app.name.toLowerCase().trim() === appQuery.toLowerCase().trim(),
|
||||
);
|
||||
|
||||
if (matchedApp) {
|
||||
@@ -56,13 +57,28 @@ export default function WritePage() {
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<TextEditor
|
||||
content=""
|
||||
onSave={onSave}
|
||||
initialLinkedAppIds={initialAppIds}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Main Page export wrapped in a Suspense boundary
|
||||
export default function WritePage() {
|
||||
return (
|
||||
<div className="flex flex-col p-2">
|
||||
<TextEditor
|
||||
content=""
|
||||
onSave={onSave}
|
||||
initialLinkedAppIds={initialAppIds}
|
||||
/>
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="p-4 text-sm text-zinc-400">
|
||||
Loading router state...
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<WritePageContent />
|
||||
</Suspense>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user