Skip to content

Commit d0190a9

Browse files
committed
Typing fixes
1 parent aa186ec commit d0190a9

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

app/src/views/AllSurgeAlerts/index.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,28 @@ export function Component() {
114114

115115
const [positionFilter, setPositionFilter] = useUrlSearchState<string | undefined>(
116116
'position',
117-
(searchValue: string | undefined) => {
118-
const potentialValue = isDefined(searchValue)
119-
? String(searchValue)
120-
: undefined;
121-
if (isDefined(potentialValue)) {
117+
(value) => {
118+
const v = value == null ? undefined : String(value);
119+
const normalized = v && v.trim() ? v.trim() : undefined;
120+
if (isDefined(normalized)) {
122121
setPage(0);
123122
}
124-
return potentialValue;
123+
return normalized;
125124
},
126-
(position: string | undefined) => position,
125+
(position) => position ?? undefined,
127126
);
128127

129128
const [keywordsFilter, setKeywordsFilter] = useUrlSearchState<string | undefined>(
130129
'keywords',
131-
(searchValue: string | undefined) => {
132-
const potentialValue = isDefined(searchValue)
133-
? String(searchValue)
134-
: undefined;
135-
if (isDefined(potentialValue)) {
130+
(value) => {
131+
const v = value == null ? undefined : String(value);
132+
const normalized = v && v.trim() ? v.trim() : undefined;
133+
if (isDefined(normalized)) {
136134
setPage(0);
137135
}
138-
return potentialValue;
136+
return normalized;
139137
},
140-
(keywords: string | undefined) => keywords,
138+
(keywords) => keywords ?? undefined,
141139
);
142140

143141
useRequest({
@@ -193,7 +191,6 @@ export function Component() {
193191
country: countryFilter,
194192
message__icontains: positionFilter,
195193
molnix_tag_name: keywordsFilter,
196-
197194
// FIXME: this should come from the useFilterState
198195
ordering: 'molnix_status,-opens',
199196
},

0 commit comments

Comments
 (0)