Fix filter hooks (#3482)

This commit is contained in:
DingDongSoLong4
2023-02-28 01:12:14 +02:00
committed by GitHub
parent 1d13f46e23
commit f992b9a0de
3 changed files with 34 additions and 35 deletions

View File

@@ -15,10 +15,10 @@ export const usePerformerFilterHook = (
return c.criterionOption.type === "performers";
}) as PerformersCriterion;
if (performerCriterion) {
if (
performerCriterion &&
(performerCriterion.modifier === GQL.CriterionModifier.IncludesAll ||
performerCriterion.modifier === GQL.CriterionModifier.Includes)
performerCriterion.modifier === GQL.CriterionModifier.IncludesAll ||
performerCriterion.modifier === GQL.CriterionModifier.Includes
) {
// add the performer if not present
if (
@@ -28,12 +28,16 @@ export const usePerformerFilterHook = (
) {
performerCriterion.value.push(performerValue);
}
} else {
// overwrite
performerCriterion.value = [performerValue];
}
performerCriterion.modifier = GQL.CriterionModifier.IncludesAll;
} else {
// overwrite
performerCriterion = new PerformersCriterion();
performerCriterion.value = [performerValue];
performerCriterion.modifier = GQL.CriterionModifier.IncludesAll;
filter.criteria.push(performerCriterion);
}

View File

@@ -14,21 +14,11 @@ export const useStudioFilterHook = (studio: GQL.StudioDataFragment) => {
return c.criterionOption.type === "studios";
}) as StudiosCriterion;
if (
studioCriterion &&
(studioCriterion.modifier === GQL.CriterionModifier.IncludesAll ||
studioCriterion.modifier === GQL.CriterionModifier.Includes)
) {
if (studioCriterion) {
// we should be showing studio only. Remove other values
studioCriterion.value.items = studioCriterion.value.items.filter(
(v) => v.id === studio.id
);
if (studioCriterion.value.items.length === 0) {
studioCriterion.value.items.push(studioValue);
}
studioCriterion.value.items = [studioValue];
studioCriterion.modifier = GQL.CriterionModifier.Includes;
} else {
// overwrite
studioCriterion = new StudiosCriterion();
studioCriterion.value = {
items: [studioValue],
@@ -36,6 +26,7 @@ export const useStudioFilterHook = (studio: GQL.StudioDataFragment) => {
? -1
: 0,
};
studioCriterion.modifier = GQL.CriterionModifier.Includes;
filter.criteria.push(studioCriterion);
}

View File

@@ -19,10 +19,10 @@ export const useTagFilterHook = (tag: GQL.TagDataFragment) => {
return c.criterionOption.type === "tags";
}) as TagsCriterion;
if (tagCriterion) {
if (
tagCriterion &&
(tagCriterion.modifier === GQL.CriterionModifier.IncludesAll ||
tagCriterion.modifier === GQL.CriterionModifier.Includes)
tagCriterion.modifier === GQL.CriterionModifier.IncludesAll ||
tagCriterion.modifier === GQL.CriterionModifier.Includes
) {
// add the tag if not present
if (
@@ -32,10 +32,13 @@ export const useTagFilterHook = (tag: GQL.TagDataFragment) => {
) {
tagCriterion.value.items.push(tagValue);
}
} else {
// overwrite
tagCriterion.value.items = [tagValue];
}
tagCriterion.modifier = GQL.CriterionModifier.IncludesAll;
} else {
// overwrite
tagCriterion = new TagsCriterion(TagsCriterionOption);
tagCriterion.value = {
items: [tagValue],
@@ -43,6 +46,7 @@ export const useTagFilterHook = (tag: GQL.TagDataFragment) => {
? -1
: 0,
};
tagCriterion.modifier = GQL.CriterionModifier.IncludesAll;
filter.criteria.push(tagCriterion);
}