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

View File

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

View File

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