Skip to content

Commit

Permalink
enhance(frontend): ノートとユーザーの検索時に照会を行うかを選択できるように (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net authored Jun 20, 2024
1 parent d6a13b2 commit 39b596f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG_yojo.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
### General
- メディアプロキシurlと拡大画像urlを分割

### Client
- enhance: ノートとユーザーの検索時に照会を行うかが選択できるようになりました
- @foo@example.com 形式でユーザ検索した場合に照会ができるようになりました

### Server
- remoteProxyエンドポイント設定を追加

Expand Down
5 changes: 5 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2854,3 +2854,8 @@ _advancedSearch:
endDate: "Until"
_description:
other: "Other settings"

_searchOrApShow:
question: "Want to search?"
search: "Search"
lookup: "Lookup"
14 changes: 14 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11208,6 +11208,20 @@ export interface Locale extends ILocale {
"other": string;
};
};
"_searchOrApShow": {
/**
* 照会を行いますか?
*/
"question": string;
/**
* 検索
*/
"search": string;
/**
* 照会
*/
"lookup": string;
};
}
declare const locales: {
[lang: string]: Locale;
Expand Down
5 changes: 5 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2987,3 +2987,8 @@ _advancedSearch:
endDate: "まで"
_description:
other: "その他の設定"

_searchOrApShow:
question: "照会を行いますか?"
search: "検索"
lookup: "照会"
29 changes: 19 additions & 10 deletions packages/frontend/src/pages/search.note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,30 @@ async function search() {
if (query == null || query === '') return;

if (query.startsWith('https://')) {
const promise = misskeyApi('ap/show', {
uri: query,
const { canceled } = await os.confirm({
type: 'question',
text: i18n.ts._searchOrApShow.question,
okText: i18n.ts._searchOrApShow.lookup,
cancelText: i18n.ts._searchOrApShow.search,
});

os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
if (!canceled) {
const promise = misskeyApi('ap/show', {
uri: query,
});

const res = await promise;
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);

if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`);
}
const res = await promise;

if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`);
}

return;
return;
}
}

if (isAdvancedSearchAvailable === true && advancedSearch.value === true) {
Expand Down
44 changes: 32 additions & 12 deletions packages/frontend/src/pages/search.user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,48 @@ const key = ref(0);
const searchQuery = ref('');
const searchOrigin = ref('combined');
const userPagination = ref();
const isApUserName = RegExp('^@[a-zA-Z0-9_.]+@[a-zA-Z0-9-_.]+[a-zA-Z]$');

async function search() {
const query = searchQuery.value.toString().trim();

if (query == null || query === '') return;

if (query.startsWith('https://')) {
const promise = misskeyApi('ap/show', {
uri: query,
if (query.startsWith('https://') || isApUserName.test(query)) {
const { canceled } = await os.confirm({
type: 'question',
text: i18n.ts._searchOrApShow.question,
okText: i18n.ts._searchOrApShow.lookup,
cancelText: i18n.ts._searchOrApShow.search,
});

os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
if (!canceled) {
if (isApUserName.test(query)) {
const querys = query.split('@');
const promise = misskeyApi('users/show', {
username: querys[1],
host: querys[2],
});
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
const res = await promise;
if (typeof res.error === 'undefined') {
router.push(`/@${res.username}@${res.host}`);
}
} else {
const promise = misskeyApi('ap/show', {
uri: query,
});
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
const res = await promise;

const res = await promise;

if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`);
if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`);
}
}
return;
}

return;
}

userPagination.value = {
Expand Down

0 comments on commit 39b596f

Please sign in to comment.