mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-05 16:37:09 +00:00
fix(control): removed date_created completly from Inode and fixed the displayed created date in InodeElement
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
import {
|
||||
change_file_path,
|
||||
current_file_path,
|
||||
get_date_mapping,
|
||||
get_missing_colliding_display_ids
|
||||
} from '$lib/ts/stores/files';
|
||||
import RefreshPlay from '../svgs/RefreshPlay.svelte';
|
||||
@@ -37,13 +38,29 @@
|
||||
});
|
||||
let thumbnail_url = liveQuery(() => get_thumbnail_url(file));
|
||||
|
||||
let date_mapping: Observable<Record<string, Date>> = liveQuery(() =>
|
||||
get_date_mapping(get_file_primary_key(file))
|
||||
);
|
||||
|
||||
const is_folder = file.type === 'inode/directory';
|
||||
|
||||
function get_created_string(date_object: Date | null, full_string = false) {
|
||||
if (!date_object) {
|
||||
return full_string ? 'Verschiedene Daten auf verschiedenen Bildschirmen' : 'versch.';
|
||||
}
|
||||
function get_created_info(date_mapping: Record<string, Date> | undefined, full_string = false) {
|
||||
if (!date_mapping) return 'undef.';
|
||||
|
||||
const keys = Object.keys(date_mapping);
|
||||
|
||||
if (keys.length === 1) return get_formated_created_string(date_mapping[keys[0]], full_string);
|
||||
|
||||
if (!full_string) return 'versch.';
|
||||
let out = "";
|
||||
for (const key of keys) {
|
||||
if (key !== keys[0]) out += "\n";
|
||||
out += `${key}: ${get_formated_created_string(date_mapping[keys[0]])}`
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function get_formated_created_string(date_object: Date, full_string = true) {
|
||||
if (full_string) {
|
||||
return (
|
||||
get_formated_date_string(date_object, true) + ' ' + get_formated_time_string(date_object)
|
||||
@@ -221,9 +238,9 @@
|
||||
{/if} -->
|
||||
<div
|
||||
class="w-14 content-center text-center select-none text-xs whitespace-nowrap"
|
||||
title={get_created_string(file.date_created, true)}
|
||||
title={get_created_info($date_mapping, true)}
|
||||
>
|
||||
{get_created_string(file.date_created)}
|
||||
{get_created_info($date_mapping)}
|
||||
</div>
|
||||
<div
|
||||
class="h-[70%] border {get_grayed_out_border_color_strings(
|
||||
|
||||
@@ -378,3 +378,19 @@ export async function create_folder_on_all_selected_displays(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function get_date_mapping(file_primary_key: string): Promise<Record<string, Date>> {
|
||||
const same_file_on_displays: FileOnDisplay[] = await db.files_on_display.where('file_primary_key').equals(file_primary_key).toArray();
|
||||
const displays_with_that_file: Display[] = await db.displays.where('id').anyOf(same_file_on_displays.map((e) => e.display_id)).toArray();
|
||||
|
||||
const out: Record<string, Date> = {};
|
||||
for (const current_file_on_display of same_file_on_displays) {
|
||||
const current_name = displays_with_that_file.find((e) => e.id === current_file_on_display.display_id)?.name;
|
||||
if (!current_name) continue;
|
||||
const current_date = current_file_on_display.date_created;
|
||||
out[current_name] = current_date;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -33,7 +33,6 @@ export type Inode = {
|
||||
name: string;
|
||||
size: number;
|
||||
type: string;
|
||||
date_created: Date;
|
||||
thumbnail: Blob | null;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user