private game toggle
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
let { loggedIn }: { loggedIn: boolean } = $props();
|
let { loggedIn }: { loggedIn: boolean } = $props();
|
||||||
|
|
||||||
|
const showPrivate = $derived($page.url.searchParams.get('private') === '1');
|
||||||
|
|
||||||
async function rescan() {
|
async function rescan() {
|
||||||
await fetch('/api/scan', { method: 'POST' });
|
await fetch('/api/scan', { method: 'POST' });
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -14,6 +19,25 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
{#if loggedIn}
|
{#if loggedIn}
|
||||||
|
<button
|
||||||
|
onclick={() => goto(showPrivate ? '/' : '/?private=1')}
|
||||||
|
aria-label={showPrivate ? 'Hide private games' : 'Show private games'}
|
||||||
|
title={showPrivate ? 'Hide private games' : 'Show private games'}
|
||||||
|
class:text-purple-400={showPrivate}
|
||||||
|
class="text-sm text-gray-400 hover:text-gray-200 transition-colors"
|
||||||
|
>
|
||||||
|
{#if showPrivate}
|
||||||
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
|
||||||
|
<circle cx="12" cy="12" r="3"/>
|
||||||
|
</svg>
|
||||||
|
{:else}
|
||||||
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/>
|
||||||
|
<line x1="1" y1="1" x2="23" y2="23"/>
|
||||||
|
</svg>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={rescan}
|
onclick={rescan}
|
||||||
class="text-sm text-gray-400 hover:text-gray-200 transition-colors"
|
class="text-sm text-gray-400 hover:text-gray-200 transition-colors"
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import type { PageServerLoad } from './$types';
|
import type { PageServerLoad } from './$types';
|
||||||
import { getDb } from '$lib/server/db';
|
import { getDb } from '$lib/server/db';
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ parent }) => {
|
export const load: PageServerLoad = async ({ parent, url }) => {
|
||||||
const { loggedIn } = await parent();
|
const { loggedIn } = await parent();
|
||||||
const db = getDb();
|
const db = getDb();
|
||||||
|
|
||||||
const games = loggedIn
|
const showPrivate = loggedIn && url.searchParams.get('private') === '1';
|
||||||
|
|
||||||
|
const games = showPrivate
|
||||||
? db
|
? db
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT id, slug, title, library, has_cover, has_wide, genre
|
`SELECT id, slug, title, library, has_cover, has_wide, genre
|
||||||
@@ -19,7 +21,7 @@ export const load: PageServerLoad = async ({ parent }) => {
|
|||||||
)
|
)
|
||||||
.all();
|
.all();
|
||||||
|
|
||||||
const series = loggedIn
|
const series = showPrivate
|
||||||
? db.prepare(`SELECT id, slug, title, library, has_cover FROM series ORDER BY title ASC`).all()
|
? db.prepare(`SELECT id, slug, title, library, has_cover FROM series ORDER BY title ASC`).all()
|
||||||
: db
|
: db
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|||||||
Reference in New Issue
Block a user