Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the jank right arrow stuff on quick menu #206

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 34 additions & 43 deletions src/routes/QuickSearchModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
$: $category, $categories, value, doCategory();
$: $sources, value, doSource();

function doCategory() {
async function doCategory() {
if (value.startsWith('#')) {
const parsed = value.slice(1).split(/[/:]/);
const categorySearch: string | undefined = parsed[0];
Expand All @@ -132,16 +132,41 @@
| undefined = undefined;
let includeChapters: ResultOf<typeof ChapterTypeFragment>[] | undefined =
undefined;
if (mangaSearch && includeCategory?.[0]) {
if (mangaSearch !== undefined && includeCategory?.[0]) {
catId = includeCategory[0].id;
includeMangas = $category?.data?.category?.mangas.nodes.filter((e) =>
e.title.toLowerCase().includes(mangaSearch.toLowerCase())
);
if (chapterNameSearch && includeMangas?.[0]) {
includeMangas = await new Promise((resolve) => {
window.requestAnimationFrame(() => {
let unSub = () => {};
unSub = category.subscribe((ee) => {
if (ee?.data?.category?.mangas?.nodes) {
unSub();
resolve(
ee.data.category.mangas.nodes.filter((e) =>
e.title.toLowerCase().includes(mangaSearch.toLowerCase())
)
);
}
});
});
});

if (chapterNameSearch !== undefined && includeMangas?.[0]) {
mangaId = includeMangas[0].id;
includeChapters = $manga?.data?.manga?.chapters.nodes?.filter((e) =>
e.name.toLowerCase().includes(chapterNameSearch.toLowerCase())
);
includeChapters = await new Promise((resolve) => {
let unSub = () => {};
unSub = manga.subscribe((ee) => {
if (ee?.data?.manga?.chapters?.nodes) {
unSub();
resolve(
ee.data.manga.chapters.nodes.filter((e) =>
e.name
.toLowerCase()
.includes(chapterNameSearch.toLowerCase())
)
);
}
});
});
}
}

Expand Down Expand Up @@ -256,40 +281,6 @@
previous.focus();
return;
}
if (event.key === 'ArrowRight') {
let selectEnd = inputEl?.selectionEnd;
if (selectEnd === value.length) {
let SelectedItem: item;
if (inputElement) {
SelectedItem = items[0];
} else {
const tabElements = [...document.querySelectorAll('.tabindex')] as (
| HTMLInputElement
| HTMLAnchorElement
)[];
const index = tabElements.findIndex(
(e) => e === document.activeElement
);
SelectedItem = items[index];
}
if ('str' in SelectedItem) {
if (!value.includes(SelectedItem.str)) {
value += SelectedItem.str;
}
} else if ('firstLineBoldText' in SelectedItem) {
if (!value.includes(SelectedItem.firstLineBoldText)) {
value += SelectedItem.firstLineBoldText;
}
} else if (!value.includes(SelectedItem.firstLine)) {
value += SelectedItem.firstLine;
}
(
document.querySelector('.tabindex') as
| HTMLInputElement
| HTMLAnchorElement
).focus();
}
}
}

$: if (catId !== undefined)
Expand Down
2 changes: 1 addition & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config = {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: '404.html',
fallback: 'index.html',
precompress: false
})
}
Expand Down
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": "r1042",
"uiVersion": "r1067",
"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