Skip to content

Commit f439c6a

Browse files
Revert "core&ui: fix pagination sort parameter (#1094)"
This reverts commit f69d3cb.
1 parent 41a2f22 commit f439c6a

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

packages/hydrooj/src/handler/problem.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,15 @@ export class ProblemMainHandler extends Handler {
170170
pdocs.map((i) => i.docId),
171171
));
172172
}
173-
let qs = sortStrategy !== 'default' ? `sort=${sortStrategy}` : '';
174-
if (q) qs += `${qs ? '&' : ''}q=${encodeURIComponent(q)}`;
175173
if (pjax) {
176174
this.response.body = {
177175
title: this.renderTitle(this.translate('problem_main')),
178176
fragments: (await Promise.all([
179177
this.renderHTML('partials/problem_list.html', {
180-
page, ppcount, pcount, pdocs, psdict, qs, q, sort: sortStrategy,
178+
page, ppcount, pcount, pdocs, psdict, qs: q, sort: sortStrategy,
181179
}),
182180
this.renderHTML('partials/problem_stat.html', { pcount, pcountRelation: this.queryContext.pcountRelation }),
183-
this.renderHTML('partials/problem_lucky.html', { q }),
181+
this.renderHTML('partials/problem_lucky.html', { qs: q }),
184182
])).map((i) => ({ html: i })),
185183
};
186184
} else {
@@ -191,8 +189,7 @@ export class ProblemMainHandler extends Handler {
191189
pcountRelation: this.queryContext.pcountRelation,
192190
pdocs,
193191
psdict,
194-
qs,
195-
q,
192+
qs: q,
196193
sort: sortStrategy,
197194
};
198195
}

packages/ui-default/templates/partials/problem_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% if not pdocs.length %}
77
{{ nothing.render('Sorry, there are no problems in the problem set.') }}
88
{% else %}
9-
{{ paginator.render(page, ppcount, position='top', add_qs=qs) }}
9+
{{ paginator.render(page, ppcount, position='top', add_qs=('q=' + qs if qs else '')) }}
1010
<table class="data-table hide-problem-tag">
1111
<colgroup>
1212
<col class="col--checkbox display-mode-hide">
@@ -63,6 +63,6 @@
6363
{%- endfor -%}
6464
</tbody>
6565
</table>
66-
{{ paginator.render(page, ppcount, add_qs=qs) }}
66+
{{ paginator.render(page, ppcount, add_qs=('q=' + qs if qs else '')) }}
6767
{% endif %}
6868
</div>

packages/ui-default/templates/partials/problem_lucky.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div data-fragment-id="problem_lucky">
22
<p>
3-
<a href="{{ url('problem_random', query={q:q}) if q else url('problem_random') }}" class="expanded button" target="_blank">
3+
<a href="{{ url('problem_random', query={q:qs}) if qs else url('problem_random') }}" class="expanded button" target="_blank">
44
<span class="icon icon-feeling-lucky"></span> {{ _('Lucky') }}
55
</a>
66
</p>

packages/ui-default/templates/problem_main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="section__body no-padding">
99
<form method="get" id="searchForm" action="{{ url('problem_main') }}">
1010
<div class="search">
11-
<input name="q" type="text" value="{{ q }}" placeholder="{{ _('Search') }}">
11+
<input name="q" type="text" value="{{ qs }}" placeholder="{{ _('Search') }}">
1212
{% include "partials/problem_stat.html" %}
1313
<select name="sort" class="search-sort">
1414
{%- for sortType in ["default", "recent"] -%}

0 commit comments

Comments
 (0)