Skip to content

Commit

Permalink
Merge pull request #6 from Kur0den/Kur0den/issue2
Browse files Browse the repository at this point in the history
照会の挙動をなんかいい感じに
  • Loading branch information
Kur0den authored Aug 27, 2024
2 parents 8c0a1ff + 4264723 commit a0eead9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG_NYA-N.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 1.0.0
- Enhance: 照会の挙動を改善
- 頭に@が付いてない場合、ユーザーとして照会をかけるように変更
- 照会中にローディングのポップアップが表示されるように
- 照会失敗時に、修正前より詳細なエラーポップアップが表示されるように
4 changes: 4 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2971,3 +2971,7 @@ _imageCompressionMode:
noResizeCompress: "Compression without resize"
resizeCompressLossy: "Resize and lossy compression"
noResizeCompressLossy: "Lossy compression without resize"
_lookupUi:
fetchingAsApUser: "Fetching from the Fediverse"
lookupFailed: "Lookup failed"
lookupFailedDescription: "Please make sure you have entered the correct lookup destination"
14 changes: 14 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11516,6 +11516,20 @@ export interface Locale extends ILocale {
*/
"noResizeCompressLossy": string;
};
"_lookupUi": {
/**
* ユーザーを照会中
*/
"fetchingAsApUser": string;
/**
* 照会に失敗しました
*/
"lookupFailed": string;
/**
* 照会先を正しく入力しているか確認してください
*/
"lookupFailedDescription": 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 @@ -3068,3 +3068,8 @@ _imageCompressionMode:
noResizeCompress: "縮小せず再圧縮する"
resizeCompressLossy: "縮小して非可逆圧縮する"
noResizeCompressLossy: "縮小せず非可逆圧縮する"

_lookupUi:
fetchingAsApUser: "ユーザーを照会中"
lookupFailed: "照会に失敗しました"
lookupFailedDescription: "照会先を正しく入力しているか確認してください"
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

/*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class NoRecursiveDelete1711722198590 {
name = 'NoRecursiveDelete1711722198590'

Expand Down
25 changes: 19 additions & 6 deletions packages/frontend/src/scripts/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import * as Misskey from 'cherrypick-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
Expand All @@ -18,11 +19,6 @@ export async function lookup(router?: Router) {
const query = temp ? temp.trim() : '';
if (canceled || query.length <= 1) return;

if (query.startsWith('@') && !query.includes(' ')) {
_router.push(`/${query}`);
return;
}

if (query.startsWith('#')) {
_router.push(`/tags/${encodeURIComponent(query.substring(1))}`);
return;
Expand All @@ -33,7 +29,9 @@ export async function lookup(router?: Router) {
uri: query,
});

os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
os.promiseDialog(promise, null, (err: Misskey.api.APIError) => {
os.alert({ type: 'error', title: i18n.ts._lookupUi.lookupFailed, text: i18n.ts._lookupUi.lookupFailedDescription + '\n' + err.message + err.id });
}, i18n.ts.fetchingAsApObject);

const res = await promise;

Expand All @@ -45,4 +43,19 @@ export async function lookup(router?: Router) {

return;
}

if (!query.includes(' ')) {
const promise = misskeyApi('users/show', Misskey.acct.parse(query));
os.promiseDialog(promise, null, (err: Misskey.api.APIError) => {
os.alert({ type: 'error', title: i18n.ts._lookupUi.lookupFailed, text: i18n.ts._lookupUi.lookupFailedDescription + '\n' + err.message + '\n' + err.id });
}, i18n.ts._lookupUi.fetchingAsApUser);
await promise;

promise.then(user => {
_router.push(user.host ? `/@${user.username}@${user.host}` : `/@${user.username}`);
return;
});
}

return;
}

0 comments on commit a0eead9

Please sign in to comment.