Add user settings page

This commit is contained in:
2026-09-20 11:42:05 +01:00
parent fd0af3172d
commit 7910a578e6
8 changed files with 141 additions and 15 deletions
@@ -2,8 +2,12 @@ import _ from "lodash";
import type { BUN_SQLITE_WGUI_MEDIA } from "@/db/types/db";
import grabMediaFromParadigm from "@/src/functions/backend/db/media/grab-media-from-paraidigm";
import type { MediaParadigmType, TableType, User } from "@/src/types";
import grabDirNames from "@/src/utils/grab-dir-names";
import BunSQLite from "@moduletrace/bun-sqlite";
import { rmSync } from "fs";
import path from "path";
const { DATA_DIR } = grabDirNames();
type Params = {
id?: string | number;
@@ -84,11 +88,13 @@ export default async function deleteMedia(params: Params) {
}
if (target_media.media_write_path) {
rmSync(target_media.media_write_path);
rmSync(path.join(DATA_DIR, target_media.media_write_path));
}
if (target_media.media_thumbnail_write_path) {
rmSync(target_media.media_thumbnail_write_path);
rmSync(
path.join(DATA_DIR, target_media.media_thumbnail_write_path),
);
}
await BunSQLite.delete<BUN_SQLITE_WGUI_MEDIA, TableType>({
@@ -202,7 +202,7 @@ export default async function uploadAndRecordMedia({
}
}
if (existsSync(media_write_path)) {
if (existsSync(media_write_path_full)) {
media_written_to_disk = true;
}
@@ -252,7 +252,16 @@ export default async function uploadAndRecordMedia({
targetId: existing_media_id,
});
media_record = update_media_record.singleRes || undefined;
if (!update_media_record.success) {
throw new Error(`Couldn't update media record!`);
}
media_record = (
await BunSQLite.select<BUN_SQLITE_WGUI_MEDIA, TableType>({
table: "media",
targetId: existing_media_id,
})
).singleRes || undefined;
} else {
const new_media_record = await BunSQLite.insert<
BUN_SQLITE_WGUI_MEDIA,
@@ -263,7 +272,18 @@ export default async function uploadAndRecordMedia({
update_on_duplicate,
});
media_record = new_media_record.singleRes || undefined;
const insert_id = new_media_record.postInsertReturn?.insertId;
if (!new_media_record.success || !insert_id) {
throw new Error(`Couldn't record media!`);
}
media_record = (
await BunSQLite.select<BUN_SQLITE_WGUI_MEDIA, TableType>({
table: "media",
targetId: insert_id,
})
).singleRes || undefined;
}
if (!media_record) {