Skip to content

Commit 36c7b0d

Browse files
committed
fix: hasBody filter, body preview ellipsis, and sort/perPage reactivity
- Wire hasBody through QueryFilters so the checkbox actually filters results client-side (issues with body > 20 chars) - Fix body preview: check stripped body length for ellipsis, not the original markdown body - Fix sort/perPage dropdown changes not triggering a new search (the effect only matched text or non-text filter changes, missing the case where only executeSearch reference changed)
1 parent cfcf7d4 commit 36c7b0d

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/features/issues/components/issue-card.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ export function IssueCard({ issue }: IssueCardProps) {
3232
now: t("timeAgo.now"),
3333
};
3434

35-
const bodyPreview = issue.body
36-
? issue.body
37-
.replace(/[#*`>\-[\]()!]/g, "")
38-
.trim()
39-
.substring(0, 120) + (issue.body.length > 120 ? "..." : "")
35+
const strippedBody = issue.body
36+
? issue.body.replace(/[#*`>\-[\]()!]/g, "").trim()
4037
: "";
38+
const bodyPreview = strippedBody.length > 120
39+
? strippedBody.substring(0, 120) + "..."
40+
: strippedBody;
4141

4242
const avatarUrl = repo.owner
4343
? `https://github.com/${repo.owner}.png?size=40`

src/features/search/components/filters-panel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function toQueryFilters(filters: {
4747
noAssignee: boolean;
4848
noComments: boolean;
4949
noPr: boolean;
50+
hasBody: boolean;
5051
}): QueryFilters {
5152
return {
5253
label: filters.label,
@@ -59,6 +60,7 @@ function toQueryFilters(filters: {
5960
noAssignee: filters.noAssignee,
6061
noComments: filters.noComments,
6162
noPr: filters.noPr,
63+
hasBody: filters.hasBody,
6264
};
6365
}
6466

src/features/search/hooks/use-github-search.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ export function useGitHubSearch({
196196
dispatch({ type: "SET_RATE_LIMIT", rateLimit });
197197
}
198198

199-
dispatch({ type: "FETCH_SUCCESS", issues, totalCount, append });
199+
const filteredIssues = filters.hasBody
200+
? issues.filter((issue) => issue.body && issue.body.trim().length > 20)
201+
: issues;
202+
203+
dispatch({ type: "FETCH_SUCCESS", issues: filteredIssues, totalCount, append });
200204
});
201205
},
202206
[filters, sort, perPage],
@@ -221,7 +225,8 @@ export function useGitHubSearch({
221225
prev.dateDays !== filters.dateDays ||
222226
prev.noAssignee !== filters.noAssignee ||
223227
prev.noComments !== filters.noComments ||
224-
prev.noPr !== filters.noPr;
228+
prev.noPr !== filters.noPr ||
229+
prev.hasBody !== filters.hasBody;
225230

226231
if (debounceRef.current) {
227232
clearTimeout(debounceRef.current);
@@ -242,8 +247,8 @@ export function useGitHubSearch({
242247
return;
243248
}
244249

245-
// Initial mount (prev === filters on first render via ref initialization)
246-
if (prev === filters) {
250+
// Initial mount or sort/perPage changed (executeSearch changed but no filter field changed)
251+
if (!textChanged && !nonTextChanged) {
247252
executeSearch(1, false);
248253
}
249254

src/features/search/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type QueryFilters = {
2626
readonly noAssignee: boolean;
2727
readonly noComments: boolean;
2828
readonly noPr: boolean;
29+
readonly hasBody: boolean;
2930
};
3031

3132
export type TimeAgoTranslations = {

0 commit comments

Comments
 (0)