mirror of
https://github.com/willchen96/mike.git
synced 2026-06-24 21:38:06 +02:00
Add courtlistener intergration, liquid glass redesign, UI improvements, version control, various fixes
This commit is contained in:
parent
d39f5806e5
commit
44e868eb42
106 changed files with 16350 additions and 7753 deletions
|
|
@ -9,6 +9,8 @@ interface DocRow {
|
|||
}
|
||||
|
||||
interface VersionPathRow extends DocRow {
|
||||
/** API/client alias for document_versions.filename of the active version. */
|
||||
filename?: string | null;
|
||||
/** Set from document_versions.storage_path of the active version. */
|
||||
storage_path?: string | null;
|
||||
/** Set from document_versions.pdf_storage_path of the active version. */
|
||||
|
|
@ -16,6 +18,10 @@ interface VersionPathRow extends DocRow {
|
|||
current_version_id?: string | null;
|
||||
/** Set from document_versions.version_number of the active version. */
|
||||
active_version_number?: number | null;
|
||||
/** Active-version file metadata. */
|
||||
file_type?: string | null;
|
||||
size_bytes?: number | null;
|
||||
page_count?: number | null;
|
||||
}
|
||||
|
||||
export interface ActiveVersion {
|
||||
|
|
@ -23,8 +29,11 @@ export interface ActiveVersion {
|
|||
storage_path: string;
|
||||
pdf_storage_path: string | null;
|
||||
version_number: number | null;
|
||||
display_name: string | null;
|
||||
filename: string | null;
|
||||
source: string | null;
|
||||
file_type: string | null;
|
||||
size_bytes: number | null;
|
||||
page_count: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +63,7 @@ export async function loadActiveVersion(
|
|||
const { data: v } = await db
|
||||
.from("document_versions")
|
||||
.select(
|
||||
"id, document_id, storage_path, pdf_storage_path, version_number, display_name, source",
|
||||
"id, document_id, storage_path, pdf_storage_path, version_number, filename, source, file_type, size_bytes, page_count",
|
||||
)
|
||||
.eq("id", targetVersionId)
|
||||
.single();
|
||||
|
|
@ -64,8 +73,11 @@ export async function loadActiveVersion(
|
|||
storage_path: v.storage_path as string,
|
||||
pdf_storage_path: (v.pdf_storage_path as string | null) ?? null,
|
||||
version_number: (v.version_number as number | null) ?? null,
|
||||
display_name: (v.display_name as string | null) ?? null,
|
||||
filename: (v.filename as string | null) ?? null,
|
||||
source: (v.source as string | null) ?? null,
|
||||
file_type: (v.file_type as string | null) ?? null,
|
||||
size_bytes: (v.size_bytes as number | null) ?? null,
|
||||
page_count: (v.page_count as number | null) ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -85,14 +97,20 @@ export async function attachActiveVersionPaths<T extends VersionPathRow>(
|
|||
.filter((id): id is string => typeof id === "string");
|
||||
if (versionIds.length === 0) {
|
||||
for (const d of docs) {
|
||||
d.filename = "Untitled document";
|
||||
d.storage_path = null;
|
||||
d.pdf_storage_path = null;
|
||||
d.file_type = null;
|
||||
d.size_bytes = null;
|
||||
d.page_count = null;
|
||||
}
|
||||
return docs;
|
||||
}
|
||||
const { data: rows } = await db
|
||||
.from("document_versions")
|
||||
.select("id, storage_path, pdf_storage_path, version_number")
|
||||
.select(
|
||||
"id, storage_path, pdf_storage_path, version_number, filename, file_type, size_bytes, page_count",
|
||||
)
|
||||
.in("id", versionIds);
|
||||
const byId = new Map<
|
||||
string,
|
||||
|
|
@ -100,6 +118,10 @@ export async function attachActiveVersionPaths<T extends VersionPathRow>(
|
|||
storage_path: string | null;
|
||||
pdf_storage_path: string | null;
|
||||
version_number: number | null;
|
||||
filename: string | null;
|
||||
file_type: string | null;
|
||||
size_bytes: number | null;
|
||||
page_count: number | null;
|
||||
}
|
||||
>();
|
||||
for (const r of (rows ?? []) as {
|
||||
|
|
@ -107,11 +129,19 @@ export async function attachActiveVersionPaths<T extends VersionPathRow>(
|
|||
storage_path: string | null;
|
||||
pdf_storage_path: string | null;
|
||||
version_number: number | null;
|
||||
filename: string | null;
|
||||
file_type: string | null;
|
||||
size_bytes: number | null;
|
||||
page_count: number | null;
|
||||
}[]) {
|
||||
byId.set(r.id, {
|
||||
storage_path: r.storage_path ?? null,
|
||||
pdf_storage_path: r.pdf_storage_path ?? null,
|
||||
version_number: r.version_number ?? null,
|
||||
filename: r.filename ?? null,
|
||||
file_type: r.file_type ?? null,
|
||||
size_bytes: r.size_bytes ?? null,
|
||||
page_count: r.page_count ?? null,
|
||||
});
|
||||
}
|
||||
for (const d of docs) {
|
||||
|
|
@ -119,6 +149,10 @@ export async function attachActiveVersionPaths<T extends VersionPathRow>(
|
|||
d.storage_path = v?.storage_path ?? null;
|
||||
d.pdf_storage_path = v?.pdf_storage_path ?? null;
|
||||
d.active_version_number = v?.version_number ?? null;
|
||||
d.filename = v?.filename?.trim() || "Untitled document";
|
||||
d.file_type = v?.file_type ?? null;
|
||||
d.size_bytes = v?.size_bytes ?? null;
|
||||
d.page_count = v?.page_count ?? null;
|
||||
}
|
||||
return docs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue