Skip to content

Commit 41f24b2

Browse files
committed
Merge branch 'main' of https://github.com/huggingface/chat-ui into front/setting_page_theme
Fixes huggingface#746: Settings dark mode - merge
2 parents be637cd + 2128ce0 commit 41f24b2

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/lib/components/Pagination.svelte

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
$: pageIndex = parseInt($page.url.searchParams.get("p") ?? "0");
1313
$: pageIndexes = getPageIndexes(pageIndex, numTotalPages);
1414
15-
function getHref(pageIdx: number) {
16-
const newUrl = new URL($page.url);
15+
function getHref(url: URL | string, pageIdx: number) {
16+
const newUrl = new URL(url);
1717
newUrl.searchParams.set("p", pageIdx.toString());
1818
return newUrl.toString();
1919
}
@@ -66,7 +66,7 @@
6666
>
6767
<li>
6868
<PaginationArrow
69-
href={getHref(pageIndex - 1)}
69+
href={getHref($page.url, pageIndex - 1)}
7070
direction="previous"
7171
isDisabled={pageIndex - 1 < 0}
7272
/>
@@ -81,15 +81,15 @@
8181
: ''}
8282
"
8383
class:pointer-events-none={pageIdx === ELLIPSIS_IDX || pageIndex === pageIdx}
84-
href={getHref(pageIdx)}
84+
href={getHref($page.url, pageIdx)}
8585
>
8686
{pageIdx === ELLIPSIS_IDX ? "..." : pageIdx + 1}
8787
</a>
8888
</li>
8989
{/each}
9090
<li>
9191
<PaginationArrow
92-
href={getHref(pageIndex + 1)}
92+
href={getHref($page.url, pageIndex + 1)}
9393
direction="next"
9494
isDisabled={pageIndex + 1 >= numTotalPages}
9595
/>

src/routes/assistants/+page.server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const load = async ({ url }) => {
3232

3333
return {
3434
assistants: JSON.parse(JSON.stringify(assistants)) as Array<Assistant>,
35+
selectedModel: modelId ?? "",
3536
numTotalItems,
3637
numItemsPerPage: NUM_PER_PAGE,
3738
};

src/routes/assistants/+page.svelte

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
1515
export let data: PageData;
1616
17-
let selectedModel = $page.url.searchParams.get("modelId") ?? "";
18-
1917
const onModelChange = (e: Event) => {
2018
const newUrl = new URL($page.url);
21-
if ((e.target as HTMLSelectElement).value === "") {
22-
newUrl.searchParams.delete("modelId");
23-
} else {
19+
newUrl.search = ""; // clear searchParams (such as "p" for pagination)
20+
if ((e.target as HTMLSelectElement).value) {
2421
newUrl.searchParams.set("modelId", (e.target as HTMLSelectElement).value);
2522
}
2623
goto(newUrl);
@@ -66,7 +63,7 @@
6663
<div class="mt-6 flex justify-between gap-2 max-sm:flex-col sm:items-center">
6764
<select
6865
class="mt-1 h-[34px] rounded-lg border border-gray-300 bg-gray-50 px-2 text-sm text-gray-900 focus:border-blue-700 focus:ring-blue-700 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400"
69-
bind:value={selectedModel}
66+
bind:value={data.selectedModel}
7067
on:change={onModelChange}
7168
>
7269
<option value="">All models</option>

0 commit comments

Comments
 (0)