diff --git a/build.ts b/build.ts
index b676fc6..46dd0d8 100644
--- a/build.ts
+++ b/build.ts
@@ -1,7 +1,4 @@
-
-
-
async function build() {
const minify = {
whitespace: true,
@@ -16,9 +13,6 @@ async function build() {
})
console.log(sa);
-
- const { stdout } = Bun.spawnSync({ cmd: ["bun", "build", "./app.ts", "--outfile=bundle.js", "--target=bun", "--minify"] });
- console.log(stdout.toString());
}
build();
diff --git a/frontend/list/list.tsx b/frontend/list/list.tsx
index 3efec15..8989746 100644
--- a/frontend/list/list.tsx
+++ b/frontend/list/list.tsx
@@ -3,9 +3,6 @@ import { splitByTitle, splitByYear } from "./functions";
import * as elements from "../elementcreate";
-
-
-
var sortType = 0;
var listType = 0;
@@ -36,6 +33,16 @@ function getLink(): string {
return "/api/media/movies";
}
+async function reload() {
+ try {
+ const response = await fetch(getLink());
+ const movies = await response.json();
+ renderMedias(movies);
+ } catch (err) {
+ console.log(err);
+ }
+}
+
function submitMedia(event: SubmitEvent) {
event.preventDefault();
@@ -62,21 +69,7 @@ function submitMedia(event: SubmitEvent) {
return;
}
- const movie: Movie = await response.json();
- var letter = movie.title[0].toUpperCase();
- if (!isNaN(parseInt(letter))) letter = "#";
-
- const mediaElement = ;
-
- const container = document.getElementById(letter);
- if (!container) {
- root?.appendChild();
- root?.appendChild({mediaElement});
- return
- };
- container.appendChild(mediaElement);
-
- movieElements.push(mediaElement);
+ await reload();
})
.catch(err => {
console.log(err);
@@ -122,9 +115,6 @@ function loadState() {
}
}
-/**
- * @param {number} type
- */
function changeType(type: number) {
listType = type;
loadPage();
@@ -143,9 +133,6 @@ function changeType(type: number) {
history.replaceState({}, '', window.location.pathname + '?' + searchParams.toString());
}
-/**
- * @param {number} type
- */
function changeSort(type: number) {
sortType = type;
loadPage();
@@ -216,13 +203,7 @@ async function loadPage() {
listButtons.forEach(button => button?.classList.remove("active"));
listButtons[listType]?.classList.add("active");
- try {
- const response = await fetch(getLink());
- const movies = await response.json();
- renderMedias(movies);
- } catch (err) {
- console.log(err);
- }
+ await reload();
}
@@ -270,6 +251,7 @@ function renderMedias(unsorted_movies: Array) {
if (!root) return;
root.innerHTML = "";
+ movieElements = [];
const splitMovies = splitBySort(unsorted_movies);