Skip to content

Commit

Permalink
fix(frontend): search user with trailing space (misskey-dev#11184)
Browse files Browse the repository at this point in the history
* fix(frontend): search user with trailing space

* fix(backend): search user with trailing space

* Update search.ts

---------

Co-authored-by: syuilo <[email protected]>
  • Loading branch information
2 people authored and slofp committed Jul 21, 2023
1 parent 6bf0e56 commit d629db7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/backend/src/server/api/endpoints/users/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
super(meta, paramDef, async (ps, me) => {
const activeThreshold = new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)); // 30日

ps.query = ps.query.trim();
const isUsername = ps.query.startsWith('@');

let users: User[] = [];
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/api/endpoints/users/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
let user;

const isModerator = await this.roleService.isModerator(me);
ps.username = ps.username?.trim();

if (ps.userIds) {
if (ps.userIds.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/search.user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function search() {
endpoint: 'users/search',
limit: 10,
params: {
query: searchQuery,
query: query,
origin: searchOrigin,
},
};
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/scripts/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { Router } from '@/nirax';
export async function lookup(router?: Router) {
const _router = router ?? mainRouter;

const { canceled, result: query } = await os.inputText({
const { canceled, result: temp } = await os.inputText({
title: i18n.ts.lookup,
});
const query = temp ? temp.trim() : '';
if (canceled) return;

if (query.startsWith('@') && !query.includes(' ')) {
Expand Down

0 comments on commit d629db7

Please sign in to comment.