More fixes around filter

This commit is contained in:
Kuba Orlik 2021-11-07 19:28:07 +01:00
parent 9b40f88db3
commit e40eebb521
3 changed files with 16 additions and 1 deletions

View File

@ -17,6 +17,7 @@ const Sidebar = () => {
const [origin, setOrigin] = useState<string | null>(null);
const [minValueLength, setMinValueLength] = useState<number | null>(7);
const [cookiesOnly, setCookiesOnly] = useState<boolean>(false);
const [cookiesOrOriginOnly, setCookiesOrOriginOnly] = useState<boolean>(true);
const [counter, setCounter] = useEmitter(getMemory());
useEffect(() => {
@ -51,6 +52,8 @@ const Sidebar = () => {
setMinValueLength={setMinValueLength}
cookiesOnly={cookiesOnly}
setCookiesOnly={setCookiesOnly}
cookiesOrOriginOnly={cookiesOrOriginOnly}
setCookiesOrOriginOnly={setCookiesOrOriginOnly}
/>
<StolenData
origin={origin}
@ -58,6 +61,7 @@ const Sidebar = () => {
refresh={() => setCounter((c) => c + 1)}
minValueLength={minValueLength}
cookiesOnly={cookiesOnly}
cookiesOrOriginOnly={cookiesOrOriginOnly}
/>
</>
);

View File

@ -75,12 +75,14 @@ export default function StolenDataCluster({
shorthost,
minValueLength,
cookiesOnly,
cookiesOrOriginOnly,
}: {
origin: string;
shorthost: string;
refreshToken: number;
minValueLength: number;
cookiesOnly: boolean;
cookiesOrOriginOnly: boolean;
}) {
const cluster = getMemory().getClustersForOrigin(origin)[shorthost];
const icons: Record<Sources, string> = {
@ -110,7 +112,7 @@ export default function StolenDataCluster({
<table>
<tbody>
{cluster
.getStolenData({ minValueLength, cookiesOnly })
.getStolenData({ minValueLength, cookiesOnly, cookiesOrOriginOnly })
.map((entry) => (
<tr
key={origin + cluster.id + entry.getUniqueKey()}

View File

@ -11,12 +11,14 @@ export function StolenData({
refreshToken,
refresh,
cookiesOnly,
cookiesOrOriginOnly,
}: {
origin: string;
refreshToken: number;
refresh: () => void;
minValueLength: number;
cookiesOnly: boolean;
cookiesOrOriginOnly: boolean;
}) {
if (!origin) {
return <div></div>;
@ -64,6 +66,12 @@ export function StolenData({
</h1>
{clusters
.filter((cluster) => !cookiesOnly || cluster.hasCookies())
.filter(
(cluster) =>
!cookiesOrOriginOnly ||
cluster.hasCookies() ||
cluster.exposesOrigin()
)
.map((cluster) => {
return (
<StolenDataCluster
@ -73,6 +81,7 @@ export function StolenData({
refreshToken={refreshToken}
minValueLength={minValueLength}
cookiesOnly={cookiesOnly}
cookiesOrOriginOnly={cookiesOrOriginOnly}
/>
);
})}