Skip to content

Commit

Permalink
Merge pull request #230 from Suwayomi/main
Browse files Browse the repository at this point in the history
fix drawer opening
  • Loading branch information
Robonau authored Sep 23, 2024
2 parents 0bc40b5 + 69d88be commit 175394c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,15 @@
import IconButton from '$lib/components/IconButton.svelte';
import { getDrawerStore, AppShell } from '@skeletonlabs/skeleton';
import type { LayoutData } from './$types';
import { writable } from 'svelte/store';
import { get, writable, type Writable } from 'svelte/store';
import { makeToggleDrawer } from './chapterStores';
export let data: LayoutData;
const drawerStore = getDrawerStore();
const dataStore = writable(data);
$: dataStore.set(data);
function draw() {
if ($drawerStore.open) drawerStore.close();
else {
drawerStore.open({
id: 'ChapterMenu',
width: 'w-[280px] md:w-[480px]',
meta: dataStore
});
}
}
const draw = makeToggleDrawer(drawerStore, dataStore);
</script>

<AppShell>
Expand Down
32 changes: 13 additions & 19 deletions src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
import { getDrawerStore } from '@skeletonlabs/skeleton';
import { onMount } from 'svelte';
import type { PageData } from './$types';
import { ViewNav, chapterTitle, mangaTitle } from './chapterStores';
import {
ViewNav,
chapterTitle,
makeToggleDrawer,
mangaTitle
} from './chapterStores';
import { filterChapters } from '../../util';
import { paths, type PathLayout, type Paths, type TPath } from './paths';
import {
Expand All @@ -35,6 +40,7 @@
} from '$lib/gql/Mutations';
import { ChapterTypeFragment } from '$lib/gql/Fragments';
import { queryParam, ssp } from 'sveltekit-search-params';
import { writable } from 'svelte/store';
export let data: PageData;
let mangaMeta = MangaMeta(data.MangaID);
Expand Down Expand Up @@ -208,24 +214,18 @@
}
}
const dataStore = writable(data);
$: dataStore.set(data);
const Toggledraw = makeToggleDrawer(drawerStore, dataStore);
async function handelKeypress(keyEvent: KeyboardEvent) {
if (!pageElement) {
pageElement = document.querySelector('#page') as HTMLDivElement;
}
if (keyEvent.code === 'Escape') {
keyEvent.preventDefault();
keyEvent.stopPropagation();
if ($drawerStore.open) {
drawerStore.close();
return;
}
drawerStore.open({
id: 'ChapterMenu',
width: 'w-[280px] md:w-[480px]',
meta: {
id: data.MangaID
}
});
Toggledraw();
return;
}
if (keyEvent.code === 'Space') {
Expand Down Expand Up @@ -331,13 +331,7 @@
} else if (pointInPoly([e.x, e.y], polyToPOLLY(path.back))) {
scrollBy(-0.8);
} else if (path.menu && pointInPoly([e.x, e.y], polyToPOLLY(path.menu))) {
drawerStore.open({
id: 'ChapterMenu',
width: 'w-[280px] md:w-[480px]',
meta: {
id: data.MangaID
}
});
Toggledraw();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,28 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// import { localStorageStore } from "@skeletonlabs/skeleton";
import { writable } from 'svelte/store';
import type { getDrawerStore } from '@skeletonlabs/skeleton';
import { get, writable, type Writable } from 'svelte/store';

export const mangaTitle = writable('');
export const chapterTitle = writable('');
export const ViewNav = writable<boolean>(false);

export function makeToggleDrawer(
drawerStore: ReturnType<typeof getDrawerStore>,
dataStore: Writable<{
MangaID: number;
ChapterID: number;
}>
) {
return () => {
if (get(drawerStore).open) drawerStore.close();
else {
drawerStore.open({
id: 'ChapterMenu',
width: 'w-[280px] md:w-[480px]',
meta: dataStore
});
}
};
}
2 changes: 1 addition & 1 deletion versionToServerVersionMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
{
"tag": "v1.1.0",
"uiVersion": "r1143",
"uiVersion": "r1146",
"serverVersion": "r1502",
"comment": "the server version is between 1.0.0 and 1.1.0 release",
"comment2": "because its the preview version that implemented the breaking changes"
Expand Down

0 comments on commit 175394c

Please sign in to comment.