NextJS 14 experimental upgrade

This commit is contained in:
Koper
2023-12-26 20:49:40 +07:00
parent ee3b4cb9f7
commit 9f42c4d8a7
12 changed files with 1243 additions and 146 deletions

View File

@@ -24,6 +24,11 @@ It also uses https://github.com/fief-dev for authentication, and Vercel for depl
- [Back-End](#back-end) - [Back-End](#back-end)
- [Installation](#installation-1) - [Installation](#installation-1)
- [Start the API/Backend](#start-the-apibackend) - [Start the API/Backend](#start-the-apibackend)
- [Redis (Mac)](#redis-mac)
- [Redis (Windows)](#redis-windows)
- [Update the database schema (run on first install, and after each pull containing a migration)](#update-the-database-schema-run-on-first-install-and-after-each-pull-containing-a-migration)
- [Main Server](#main-server)
- [Crontab (optional)](#crontab-optional)
- [Using docker](#using-docker) - [Using docker](#using-docker)
- [Using local GPT4All](#using-local-gpt4all) - [Using local GPT4All](#using-local-gpt4all)
- [Using local files](#using-local-files) - [Using local files](#using-local-files)
@@ -152,7 +157,7 @@ redis-server
## Update the database schema (run on first install, and after each pull containing a migration) ## Update the database schema (run on first install, and after each pull containing a migration)
```bash ```bash
poetry run python alembic head poetry run alembic heads
``` ```
## Main Server ## Main Server

View File

@@ -3,7 +3,6 @@ import { useError } from "../../(errors)/errorContext";
import { GetTranscript, CreateTranscript } from "../../api"; import { GetTranscript, CreateTranscript } from "../../api";
import useApi from "../../lib/useApi"; import useApi from "../../lib/useApi";
type UseTranscript = { type UseTranscript = {
transcript: GetTranscript | null; transcript: GetTranscript | null;
loading: boolean; loading: boolean;
@@ -23,26 +22,16 @@ const useCreateTranscript = (): UseTranscript => {
setLoading(true); setLoading(true);
console.debug( console.log(
"POST - /v1/transcripts/ - Requesting new transcription creation", "POST - /v1/transcripts/ - Requesting new transcription creation",
transcriptCreationDetails, transcriptCreationDetails,
api api,
); );
const aaa = async () => { console.log("START");
console.log("Calling API...");
await new Promise((res) => setTimeout(res, 500)); api
.v1TranscriptsCreate(transcriptCreationDetails)
console.log("500 ms elapsed - calling api");
const test = await api.v1TranscriptsCreate(transcriptCreationDetails);
console.log(test);
};
aaa();
api.v1TranscriptsCreate(transcriptCreationDetails)
.then((transcript) => { .then((transcript) => {
console.debug("New transcript created:", transcript); console.debug("New transcript created:", transcript);
setTranscript(transcript); setTranscript(transcript);
@@ -55,6 +44,9 @@ const useCreateTranscript = (): UseTranscript => {
); );
setErrorState(err); setErrorState(err);
setLoading(false); setLoading(false);
})
.finally(() => {
console.log("At least this should display?");
}); });
}; };

View File

@@ -4,7 +4,7 @@ import Markdown from "react-markdown";
import "../../styles/markdown.css"; import "../../styles/markdown.css";
import { featureEnabled } from "../domainContext"; import { featureEnabled } from "../domainContext";
import { UpdateTranscript } from "../../api"; import { UpdateTranscript } from "../../api";
import useApi from "../../lib/useApi"; import useApi from "../../lib/useApi";
type FinalSummaryProps = { type FinalSummaryProps = {
summary: string; summary: string;

View File

@@ -89,29 +89,30 @@ const ShareLink = (props: ShareLinkProps) => {
<p>This transcript is public. Everyone can access it.</p> <p>This transcript is public. Everyone can access it.</p>
)} )}
{isOwner && apiReady ( {isOwner &&
<div className="relative"> apiReady(
<SelectSearch <div className="relative">
className="select-search--top select-search" <SelectSearch
options={[ className="select-search--top select-search"
{ name: "Private", value: "private" }, options={[
{ name: "Secure", value: "semi-private" }, { name: "Private", value: "private" },
{ name: "Public", value: "public" }, { name: "Secure", value: "semi-private" },
]} { name: "Public", value: "public" },
value={shareMode?.toString()} ]}
onChange={updateShareMode} value={shareMode?.toString()}
closeOnSelect={true} onChange={updateShareMode}
/> closeOnSelect={true}
{shareLoading && ( />
<div className="h-4 w-4 absolute top-1/3 right-3 z-10"> {shareLoading && (
<FontAwesomeIcon <div className="h-4 w-4 absolute top-1/3 right-3 z-10">
icon={faSpinner} <FontAwesomeIcon
className="animate-spin-slow text-gray-600 flex-grow rounded-lg md:rounded-xl h-4 w-4" icon={faSpinner}
/> className="animate-spin-slow text-gray-600 flex-grow rounded-lg md:rounded-xl h-4 w-4"
</div> />
)} </div>
</div> )}
)} </div>,
)}
</div> </div>
)} )}
{!requireLogin && ( {!requireLogin && (

View File

@@ -21,7 +21,8 @@ const useTopics = (id: string): TranscriptTopics => {
if (!id || !api) return; if (!id || !api) return;
setLoading(true); setLoading(true);
api.v1TranscriptGetTopics(id) api
.v1TranscriptGetTopics(id)
.then((result) => { .then((result) => {
setTopics(result); setTopics(result);
setLoading(false); setLoading(false);

View File

@@ -36,7 +36,8 @@ const useTranscript = (
setLoading(true); setLoading(true);
api.v1TranscriptGet(id) api
.v1TranscriptGet(id)
.then((result) => { .then((result) => {
setResponse(result); setResponse(result);
setLoading(false); setLoading(false);

View File

@@ -19,10 +19,9 @@ const useTranscriptList = (page: number): TranscriptList => {
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
if (!api) if (!api) return;
api
return; .v1TranscriptsList(page)
api.v1TranscriptsList(page)
.then((response) => { .then((response) => {
setResponse(response); setResponse(response);
setLoading(false); setLoading(false);

View File

@@ -35,10 +35,10 @@ const useWebRTC = (
p.on("signal", (data: any) => { p.on("signal", (data: any) => {
if (!api) return; if (!api) return;
if ("sdp" in data) { if ("sdp" in data) {
const rtcOffer : RtcOffer = { const rtcOffer: RtcOffer = {
sdp: data.sdp, sdp: data.sdp,
type: data.type, type: data.type,
}; };
api api
.v1TranscriptRecordWebrtc(transcriptId, rtcOffer) .v1TranscriptRecordWebrtc(transcriptId, rtcOffer)

View File

@@ -19,14 +19,13 @@ export default function useApi(): DefaultService | null {
return; return;
} }
if (!accessTokenInfo) if (!accessTokenInfo) return;
return;
const openApi = new OpenApi({ const openApi = new OpenApi({
BASE: api_url, BASE: api_url,
TOKEN: accessTokenInfo?.access_token TOKEN: accessTokenInfo?.access_token,
}); });
setApi(openApi); setApi(openApi);
}, [!accessTokenInfo, hasAuthCookie]); }, [!accessTokenInfo, hasAuthCookie]);

View File

@@ -20,10 +20,12 @@
"@vercel/edge-config": "^0.4.1", "@vercel/edge-config": "^0.4.1",
"autoprefixer": "10.4.14", "autoprefixer": "10.4.14",
"axios": "^1.6.2", "axios": "^1.6.2",
"eslint-config-next": "^14.0.4",
"fontawesome": "^5.6.3", "fontawesome": "^5.6.3",
"jest-worker": "^29.6.2", "jest-worker": "^29.6.2",
"next": "^13.4.9", "next": "^14.0.4",
"postcss": "8.4.25", "postcss": "8.4.25",
"prop-types": "^15.8.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-dropdown": "^1.11.0", "react-dropdown": "^1.11.0",

View File

@@ -19,7 +19,8 @@
} }
], ],
"strictNullChecks": true, "strictNullChecks": true,
"downlevelIteration": true "downlevelIteration": true,
"target": "ES2020"
}, },
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"] "exclude": ["node_modules"]

File diff suppressed because it is too large Load Diff