From eafd2646f6f3232912f1008ce37956b303486c2c Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 16 Jan 2024 14:36:40 +1100 Subject: [PATCH] Handle existing saved filters --- .../src/models/list-filter/criteria/gender.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ui/v2.5/src/models/list-filter/criteria/gender.ts b/ui/v2.5/src/models/list-filter/criteria/gender.ts index b0291f11abe..3d7d50b1fb9 100644 --- a/ui/v2.5/src/models/list-filter/criteria/gender.ts +++ b/ui/v2.5/src/models/list-filter/criteria/gender.ts @@ -4,7 +4,11 @@ import { GenderEnum, } from "src/core/generated-graphql"; import { genderStrings, stringToGender } from "src/utils/gender"; -import { CriterionOption, MultiStringCriterion } from "./criterion"; +import { + CriterionOption, + IEncodedCriterion, + MultiStringCriterion, +} from "./criterion"; export const GenderCriterionOption = new CriterionOption({ messageID: "gender", @@ -33,4 +37,18 @@ export class GenderCriterion extends MultiStringCriterion { modifier: this.modifier, }; } + + public setFromEncodedCriterion( + encodedCriterion: IEncodedCriterion + ) { + // backwards compatibility - if the value is a string, convert it to an array + if (typeof encodedCriterion.value === "string") { + encodedCriterion = { + ...encodedCriterion, + value: [encodedCriterion.value], + }; + } + + super.setFromEncodedCriterion(encodedCriterion); + } }