Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Icon } from '@iconify/react';
import { type ReactNode, useState } from 'react';
import { type ReactNode, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { Button, IconButton, InputField, Link, TimeDisplay } from '~/Components';
import { eventQuery } from '~/Components/EventQuery/utils';
import { ImageCard } from '~/Components/ImageCard';
Expand All @@ -22,7 +23,8 @@ type EventsListProps = {
export function EventsList({ events }: EventsListProps) {
const { t, i18n } = useTranslation();
const [tableView, setTableView] = useState(false);
const [query, setQuery] = useState('');
const [searchParam, setSearchParam] = useSearchParams();
const [query, setQuery] = useState(searchParam.get('q') ?? '');
const isDesktop = useDesktop();

const eventColumns = [
Expand Down Expand Up @@ -99,6 +101,18 @@ export function EventsList({ events }: EventsListProps) {
});
}

useEffect(() => {
setSearchParam((prev) => {
const next = new URLSearchParams(prev);
if (query) {
next.set('q', query);
} else {
next.delete('q');
}
return next;
});
}, [query, setSearchParam]);

Comment thread
0xSpecter marked this conversation as resolved.
function getButton(title: string, icon: string, func: () => void, chosen: boolean) {
return (
<Button rounded={true} onClick={func} theme={chosen ? 'blue' : 'secondary'}>
Expand Down
Loading