Many improvemtns and fixes related to decoupling of svelte and rust on android.
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { onMount, onDestroy, setContext } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import { page } from "$app/stores";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { auth, isAuthenticated, isLoading as isAuthLoading, currentUser } from "$lib/stores/auth";
|
||||
import { library } from "$lib/stores/library";
|
||||
import { currentMedia, isPlaying, playbackPosition, playbackDuration } from "$lib/stores/player";
|
||||
import { currentMedia, isPlaying, playbackPosition, playbackDuration, shouldShowAudioMiniPlayer } from "$lib/stores/player";
|
||||
import { useScrollGuard } from "$lib/composables/useScrollGuard";
|
||||
import Search from "$lib/components/Search.svelte";
|
||||
import MiniPlayer from "$lib/components/player/MiniPlayer.svelte";
|
||||
import AudioPlayer from "$lib/components/player/AudioPlayer.svelte";
|
||||
import SleepTimerModal from "$lib/components/player/SleepTimerModal.svelte";
|
||||
|
||||
// Scroll guard prevents accidental taps on library cards during/after scrolling (Android)
|
||||
const scrollGuard = useScrollGuard(300);
|
||||
setContext("scrollGuard", scrollGuard);
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
let searchQuery = $state("");
|
||||
@@ -48,6 +53,7 @@
|
||||
return () => {
|
||||
clearTimeout(timeoutId);
|
||||
if (pollInterval) clearInterval(pollInterval);
|
||||
scrollGuard.cleanup();
|
||||
};
|
||||
});
|
||||
|
||||
@@ -241,8 +247,12 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main content (with padding for nav bar and mini player) -->
|
||||
<main class="flex-1 overflow-y-auto p-4 pb-16 {$currentMedia && $currentMedia.type !== 'Movie' && $currentMedia.type !== 'Episode' ? (isAndroid ? 'pb-40' : 'pb-40 md:pb-24') : ''}">
|
||||
<!-- Main content (with padding for bottom nav bar and mini player) -->
|
||||
<main
|
||||
class="flex-1 overflow-y-auto p-4"
|
||||
style="padding-bottom: {$shouldShowAudioMiniPlayer ? (isAndroid ? '11rem' : '7rem') : '5rem'}; overscroll-behavior: contain"
|
||||
onscroll={scrollGuard.onScroll}
|
||||
>
|
||||
{@render children()}
|
||||
</main>
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { onMount, getContext } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import type { Library, MediaItem } from "$lib/api/types";
|
||||
import { library, libraries, libraryItems, isLibraryLoading, currentLibrary, selectedGenres } from "$lib/stores/library";
|
||||
import { isServerReachable } from "$lib/stores/connectivity";
|
||||
import type { useScrollGuard } from "$lib/composables/useScrollGuard";
|
||||
import LibraryGrid from "$lib/components/library/LibraryGrid.svelte";
|
||||
import MediaCard from "$lib/components/library/MediaCard.svelte";
|
||||
import GenreFilter from "$lib/components/library/GenreFilter.svelte";
|
||||
|
||||
// Scroll guard from layout - prevents accidental taps during scrolling (Android)
|
||||
const scrollGuard = getContext<ReturnType<typeof useScrollGuard>>("scrollGuard");
|
||||
|
||||
let searchResults = $derived($library.searchResults);
|
||||
let searchQuery = $derived($library.searchQuery);
|
||||
|
||||
@@ -48,6 +52,9 @@
|
||||
});
|
||||
|
||||
async function handleLibraryClick(lib: Library) {
|
||||
// Prevent accidental taps during scrolling (Android)
|
||||
if (scrollGuard.isScrollActive()) return;
|
||||
|
||||
// Route to dedicated music library page
|
||||
if (lib.collectionType === "music") {
|
||||
library.setCurrentLibrary(lib);
|
||||
@@ -70,6 +77,9 @@
|
||||
}
|
||||
|
||||
function handleItemClick(item: MediaItem | Library) {
|
||||
// Prevent accidental taps during scrolling (Android)
|
||||
if (scrollGuard.isScrollActive()) return;
|
||||
|
||||
if ("type" in item) {
|
||||
// It's a MediaItem
|
||||
const mediaItem = item as MediaItem;
|
||||
@@ -102,6 +112,8 @@
|
||||
}
|
||||
|
||||
function goBackToLibraries() {
|
||||
// Prevent accidental taps during scrolling (Android)
|
||||
if (scrollGuard.isScrollActive()) return;
|
||||
library.setCurrentLibrary(null);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user