Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(frontend): ノートとユーザーの検索時に照会を行うかを選択できるように #89

Merged
merged 12 commits into from
Jun 20, 2024
2 changes: 2 additions & 0 deletions CHANGELOG_engawa.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

### Client
- fix: 投稿にされたリアクションが正常に表示されない問題
- enhance: ノートとユーザーの検索時に照会を行うかが選択できるようになりました
- @foo@example.com 形式でユーザ検索した場合に照会ができるようになりました

### Server

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

_searchOrApShow:
question: "Do you want to get it from Fediverse?"
penginn-net marked this conversation as resolved.
Show resolved Hide resolved
caption: "Please select No when searching"
22 changes: 16 additions & 6 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11201,12 +11201,22 @@ export interface Locale extends ILocale {
*/
"endDate": string;
};
"_description": {
/**
* その他
*/
"other": string;
}
"_description": {
/**
* その他の設定
*/
"other": string;
};
};
"_searchOrApShow": {
/**
* 照会を行いますか?
*/
"question": string;
/**
* 検索する場合はいいえを選択してください
*/
"caption": string;
};
}
declare const locales: {
Expand Down
4 changes: 4 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2987,3 +2987,7 @@ _advancedSearch:
endDate: "まで"
_description:
other: "その他の設定"

_searchOrApShow:
question: "照会を行いますか?"
caption: "検索する場合はいいえを選択してください"
30 changes: 20 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,31 @@ 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,
caption: i18n.ts._searchOrApShow.caption,
okText: i18n.ts.yes,
penginn-net marked this conversation as resolved.
Show resolved Hide resolved
cancelText: i18n.ts.no,
});

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
47 changes: 34 additions & 13 deletions packages/frontend/src/pages/search.user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,51 @@ const key = ref(0);
const searchQuery = ref('');
const searchOrigin = ref('combined');
const userPagination = ref();
const isApUserName = RegExp('@.+@.+');
penginn-net marked this conversation as resolved.
Show resolved Hide resolved

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,
caption: i18n.ts._searchOrApShow.caption,
okText: i18n.ts.yes,
penginn-net marked this conversation as resolved.
Show resolved Hide resolved
cancelText: i18n.ts.no,
});

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;
}

penginn-net marked this conversation as resolved.
Show resolved Hide resolved
userPagination.value = {
endpoint: 'users/search',
limit: 10,
Expand Down
Loading