refactor(control): implement ESLint -> remove unnecessary imports, improve general code quality

This commit is contained in:
E44
2026-06-09 22:00:36 +02:00
parent 64b8fcffe2
commit 919bba7c2e
14 changed files with 41 additions and 51 deletions
@@ -1,6 +1,7 @@
<script lang="ts">
import { get_shifted_color } from '$lib/ts/stores/ui_behavior';
import type { MenuOption } from '$lib/ts/types';
import type { Snippet } from 'svelte';
import { fade } from 'svelte/transition';
let {
@@ -26,7 +27,7 @@
menu_options?: MenuOption[];
menu_class?: string;
div_class?: string;
children?: any;
children: Snippet;
} = $props();
let menu_shown = $state(false);
@@ -158,14 +159,14 @@
e.stopPropagation();
}}
>
{#each menu_options as option}
{#each menu_options as option, i (i)}
<button
disabled={option.disabled ?? false}
class="bg-white/15 {option.disabled
? 'text-stone-500 cursor-not-allowed'
: 'hover:bg-white/35 active:bg-white/60 cursor-pointer ' +
option.class} rounded-lg p-2 transition-colors duration-200 select-none flex flex-row gap-2 items-center"
onclick={async (e) => {
onclick={async () => {
if (option.on_select) await option.on_select();
close_menu();
}}
@@ -3,11 +3,8 @@
import {
dnd_flip_duration_ms,
get_selectable_color_classes,
is_display_drag,
is_group_drag
is_display_drag
} from '$lib/ts/stores/ui_behavior';
import { cubicOut } from 'svelte/easing';
import { flip } from 'svelte/animate';
import DisplayObject from './DisplayObject.svelte';
import {
all_displays_of_group_selected,
@@ -18,10 +15,9 @@
} from '$lib/ts/stores/displays';
import DNDGrip from '$lib/components/DNDGrip.svelte';
import { fade } from 'svelte/transition';
import type { Display, DisplayIdGroup, MenuOption } from '$lib/ts/types';
import type { DisplayIdGroup, MenuOption } from '$lib/ts/types';
import { selected_display_ids } from '$lib/ts/stores/select';
import { liveQuery, type Observable } from 'dexie';
import { onMount } from 'svelte';
import { get_uuid } from '$lib/ts/utils';
let {
@@ -8,7 +8,7 @@
import DNDGrip from '$lib/components/DNDGrip.svelte';
import { Menu, Pin, PinOff, VideoOff } from 'lucide-svelte';
import OnlineState from './OnlineState.svelte';
import type { Display, DisplayIdObject, MenuOption } from '$lib/ts/types';
import type { DisplayIdObject, MenuOption } from '$lib/ts/types';
import { is_selected, select, selected_display_ids } from '$lib/ts/stores/select';
import { get_display_by_id, screenshot_loop } from '$lib/ts/stores/displays';
import { change_file_path, current_file_path } from '$lib/ts/stores/files';
@@ -1,11 +1,13 @@
<script lang="ts">
import type { Snippet } from "svelte";
let {
children,
bg = 'bg-stone-750',
fg = 'text-stone-200',
className = ''
}: {
children: any;
children: Snippet;
bg?: string;
fg?: string;
className?: string;
@@ -1,5 +1,5 @@
<script lang="ts">
import { ArrowRight, Ban, FileIcon, Folder, Play, Triangle, TriangleAlert } from 'lucide-svelte';
import { ArrowRight, Ban, FileIcon, Folder, Play, TriangleAlert } from 'lucide-svelte';
import {
current_height,
get_selectable_color_classes,
@@ -10,7 +10,6 @@
supported_file_type_icon,
type Inode,
get_file_primary_key,
type FileOnDisplay,
type FileTransferTask,
is_folder
} from '$lib/ts/types';
@@ -18,7 +17,6 @@
import {
is_selected,
select,
selected_display_ids,
selected_file_ids
} from '$lib/ts/stores/select';
import {
@@ -32,13 +30,11 @@
import { get_file_size_display_string, get_file_type } from '$lib/ts/utils';
import { open_file } from '$lib/ts/api_handler';
import {
get_display_by_id,
run_on_all_selected_displays,
selected_online_display_ids
} from '$lib/ts/stores/displays';
import { get_thumbnail_url } from '$lib/ts/stores/thumbnails';
import { liveQuery, type Observable } from 'dexie';
import { db } from '$lib/ts/database';
import { add_sync_recursively, file_transfer_tasks } from '$lib/ts/file_transfer_handler';
let { file, not_interactable = false }: { file: Inode; not_interactable?: boolean } = $props();
@@ -65,7 +61,7 @@
});
let file_transfer_task: FileTransferTask | null = $derived(
$file_transfer_tasks.hasOwnProperty(file_primary_key)
Object.hasOwn($file_transfer_tasks, file_primary_key)
? $file_transfer_tasks[file_primary_key]
: null
);
@@ -145,7 +141,7 @@
function get_grayed_out_text_color_strings(is_selected: boolean): string {
if (not_interactable) return 'text-stone-400';
if (!!file_transfer_task) return 'text-white/20';
if (file_transfer_task) return 'text-white/20';
const color = is_selected ? 'text-stone-600' : 'text-stone-400';
const factor = is_selected ? -1 : 1;
return `${color} group-hover:${get_shifted_color(color, factor * 100)} group-active:${get_shifted_color(color, factor * 150)}`;
@@ -153,14 +149,14 @@
function get_grayed_out_border_color_strings(is_selected: boolean): string {
if (not_interactable) return 'border-stone-550';
if (!!file_transfer_task) return 'border-white/10';
if (file_transfer_task) return 'border-white/10';
const color = is_selected ? 'border-stone-450' : 'border-stone-550';
const factor = is_selected ? 1 : 1;
return `${color} group-hover:${get_shifted_color(color, factor * 100)} group-active:${get_shifted_color(color, factor * 150)}`;
}
function onclick(e: Event) {
if (not_interactable || !!file_transfer_task) return;
if (not_interactable || file_transfer_task) return;
select(selected_file_ids, file_primary_key, 'toggle');
e.stopPropagation();
}
@@ -184,7 +180,7 @@
if (loading_finished) {
out += 'bg-stone-500 text-white/30';
} else if (!!file_transfer_task) {
} else if (file_transfer_task) {
out += 'bg-stone-700 text-white/30';
} else {
out += get_selectable_color_classes(
@@ -200,7 +196,7 @@
if (not_interactable) {
out += ' rounded-lg';
} else if (!!file_transfer_task) {
} else if (file_transfer_task) {
out += ' rounded-r-lg';
} else {
out += ' rounded-r-lg cursor-pointer';
@@ -1,6 +1,6 @@
<script lang="ts">
import type { NumberSetting } from '$lib/ts/types';
import { ChevronDown, ChevronUp, Minus, Plus } from 'lucide-svelte';
import { ChevronDown, ChevronUp } from 'lucide-svelte';
import Button from './Button.svelte';
let {
+2 -2
View File
@@ -127,8 +127,8 @@ export type MenuOption = {
export type PopupContent = {
open: boolean;
snippet: Snippet<[any]> | Snippet<[]> | Snippet | null | any;
snippet_arg?: any;
snippet: Snippet<[string]> | Snippet<[]> | null;
snippet_arg?: string;
title?: string;
title_class?: string;
title_icon?: typeof X | null;