Skip to content

Commit

Permalink
fix: item list reactive update
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2E committed Mar 15, 2024
1 parent 71d41a0 commit eeab25c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"moment": "^2.30.1",
"svelte-sonner": "^0.3.19",
"tailwind-merge": "^2.2.1",
"tailwind-variants": "^0.2.0"
"tailwind-variants": "^0.2.1"
}
}
2 changes: 1 addition & 1 deletion frontend/src/lib/components/FeedsSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { Button } from './ui/button';
export let data: Feed[];
export let selected: number;
export let selected: number | undefined;
export let className = '';
let open = false;
Expand Down
16 changes: 10 additions & 6 deletions frontend/src/lib/components/ItemList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
let oldFilter = Object.assign({}, filter);
let selectedFeed = filter?.feed_id ?? -1;
let selectedFeed = filter?.feed_id;
$: updateSelectedFeed(selectedFeed);
function updateSelectedFeed(id: number) {
if (id == filter.feed_id) return;
function updateSelectedFeed(id: number | undefined) {
if (id === filter.feed_id) return;
filter.feed_id = id !== -1 ? id : undefined;
filter.page = 1;
console.log(filter);
Expand All @@ -51,7 +51,7 @@
}
if (!updated) return;
oldFilter = Object.assign({}, filter);
if (oldFilter.keyword !== filter.keyword) filter.page = 1;
const p = new URLSearchParams($page.url.searchParams);
for (key in f) {
Expand All @@ -60,6 +60,9 @@
p.set(key, String(f[key]));
}
}
oldFilter = Object.assign({}, filter);
console.log(p.toString());
goto('?' + p.toString());
}
Expand All @@ -81,7 +84,7 @@
const context = this;
const later = () => {
func.apply(context, event);
func.apply(context, [event]);
};
clearTimeout(timeout);
Expand Down Expand Up @@ -119,6 +122,7 @@
type="text"
placeholder="Search in title and content..."
class="w-full md:w-[400px]"
value={filter.keyword}
on:input={handleSearchInput}
/>
</div>
Expand Down Expand Up @@ -156,7 +160,7 @@
class="flex justify-between items-center gap-2 py-6"
variant="ghost"
>
<h2 class="w-full truncate text-lg font-medium">
<h2 class="truncate text-lg font-medium">
{item.title}
</h2>
<div class="flex justify-between items-center w-1/3 md:w-1/4">
Expand Down

0 comments on commit eeab25c

Please sign in to comment.