Skip to content

Commit

Permalink
enhance: 非ログイン時には別サーバーに遷移できるように (misskey-dev#13089)
Browse files Browse the repository at this point in the history
* enhance: 非ログイン時にはMisskey Hub経由で別サーバーに遷移できるように

* fix

* サーバーサイド照会を削除

* クライアント側の照会動作

* hubを経由せずにリモートで続行できるように

* fix と pleaseLogin誘導箇所の追加

* fix

* fix

* Update CHANGELOG.md

---------

Co-authored-by: syuilo <[email protected]>
  • Loading branch information
kakkokari-gtyih and syuilo authored Jul 14, 2024
1 parent 6dd6fcf commit 3c032dd
Show file tree
Hide file tree
Showing 19 changed files with 330 additions and 113 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Client
- Enhance: 内蔵APIドキュメントのデザイン・パフォーマンスを改善
- Enhance: 非ログイン時に他サーバーに遷移するアクションを追加
- Enhance: 非ログイン時のハイライトTLのデザインを改善
- Enhance: フロントエンドのアクセシビリティ改善
(Based on https://github.com/taiyme/misskey/pull/226)
Expand Down
26 changes: 25 additions & 1 deletion locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,22 @@ export interface Locale extends ILocale {
* リモートで表示
*/
"showOnRemote": string;
/**
* リモートで続行
*/
"continueOnRemote": string;
/**
* Misskey Hubからサーバーを選択
*/
"chooseServerOnMisskeyHub": string;
/**
* サーバーのドメインを直接指定
*/
"specifyServerHost": string;
/**
* ドメインを入力してください
*/
"inputHostName": string;
/**
* 全般
*/
Expand Down Expand Up @@ -1921,9 +1937,13 @@ export interface Locale extends ILocale {
*/
"onlyOneFileCanBeAttached": string;
/**
* 続行する前に、サインアップまたはサインインが必要です
* 続行する前に、登録またはログインが必要です
*/
"signinRequired": string;
/**
* 続行するには、お使いのサーバーに移動するか、このサーバーに登録・ログインする必要があります
*/
"signinOrContinueOnRemote": string;
/**
* 招待
*/
Expand Down Expand Up @@ -4984,6 +5004,10 @@ export interface Locale extends ILocale {
* お問い合わせ
*/
"inquiry": string;
/**
* もう一度お試しください。
*/
"tryAgain": string;
"_delivery": {
/**
* 配信状態
Expand Down
8 changes: 7 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ addAccount: "アカウントを追加"
reloadAccountsList: "アカウントリストの情報を更新"
loginFailed: "ログインに失敗しました"
showOnRemote: "リモートで表示"
continueOnRemote: "リモートで続行"
chooseServerOnMisskeyHub: "Misskey Hubからサーバーを選択"
specifyServerHost: "サーバーのドメインを直接指定"
inputHostName: "ドメインを入力してください"
general: "全般"
wallpaper: "壁紙"
setWallpaper: "壁紙を設定"
Expand Down Expand Up @@ -476,7 +480,8 @@ attachAsFileQuestion: "クリップボードのテキストが長いです。テ
noMessagesYet: "まだチャットはありません"
newMessageExists: "新しいメッセージがあります"
onlyOneFileCanBeAttached: "メッセージに添付できるファイルはひとつです"
signinRequired: "続行する前に、サインアップまたはサインインが必要です"
signinRequired: "続行する前に、登録またはログインが必要です"
signinOrContinueOnRemote: "続行するには、お使いのサーバーに移動するか、このサーバーに登録・ログインする必要があります"
invitations: "招待"
invitationCode: "招待コード"
checking: "確認しています"
Expand Down Expand Up @@ -1242,6 +1247,7 @@ keepOriginalFilenameDescription: "この設定をオフにすると、アップ
noDescription: "説明文はありません"
alwaysConfirmFollow: "フォローの際常に確認する"
inquiry: "お問い合わせ"
tryAgain: "もう一度お試しください。"

_delivery:
status: "配信状態"
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/src/components/MkFollowButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import { misskeyApi } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js';
import { claimAchievement } from '@/scripts/achievements.js';
import { pleaseLogin } from '@/scripts/please-login.js';
import { host } from '@/config.js';
import { $i } from '@/account.js';
import { defaultStore } from '@/store.js';
Expand All @@ -63,7 +65,7 @@ const hasPendingFollowRequestFromYou = ref(props.user.hasPendingFollowRequestFro
const wait = ref(false);
const connection = useStream().useChannel('main');
if (props.user.isFollowing == null) {
if (props.user.isFollowing == null && $i) {
misskeyApi('users/show', {
userId: props.user.id,
})
Expand All @@ -78,6 +80,8 @@ function onFollowChange(user: Misskey.entities.UserDetailed) {
}
async function onClick() {
pleaseLogin(undefined, { type: 'web', path: `/@${props.user.username}@${props.user.host ?? host}` });
wait.value = true;
try {
Expand Down
14 changes: 10 additions & 4 deletions packages/frontend/src/components/MkNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ import { MenuItem } from '@/types/menu.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { showMovedDialog } from '@/scripts/show-moved-dialog.js';
import { shouldCollapsed } from '@/scripts/collapsed.js';
import { host } from '@/config.js';
import { isEnabledUrlPreview } from '@/instance.js';
import { type Keymap } from '@/scripts/hotkey.js';
import { focusPrev, focusNext } from '@/scripts/focus.js';
Expand Down Expand Up @@ -278,6 +279,11 @@ const renoteCollapsed = ref(
),
);
const pleaseLoginContext = {
type: 'lookup',
path: `https://${host}/notes/${appearNote.value.id}`,
} as const;
/* Overload FunctionにLintが対応していないのでコメントアウト
function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string | string[]> | undefined | null, checkOnly: true): boolean;
function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string | string[]> | undefined | null, checkOnly: false): boolean | 'sensitiveMute';
Expand Down Expand Up @@ -411,7 +417,7 @@ if (!props.mock) {
}
function renote(viaKeyboard = false) {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
showMovedDialog();
const { menu } = getRenoteMenu({ note: note.value, renoteButton, mock: props.mock });
Expand All @@ -421,7 +427,7 @@ function renote(viaKeyboard = false) {
}
function reply(): void {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
if (props.mock) {
return;
}
Expand All @@ -434,7 +440,7 @@ function reply(): void {
}
function react(): void {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
showMovedDialog();
if (appearNote.value.reactionAcceptance === 'likeOnly') {
sound.playMisskeySfx('reaction');
Expand Down Expand Up @@ -565,7 +571,7 @@ function showRenoteMenu(): void {
}
if (isMyRenote) {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
os.popupMenu([
getCopyNoteLinkMenu(note.value, i18n.ts.copyLinkRenote),
{ type: 'divider' },
Expand Down
14 changes: 10 additions & 4 deletions packages/frontend/src/components/MkNoteDetailed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ import { reactionPicker } from '@/scripts/reaction-picker.js';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { host } from '@/config.js';
import { getNoteClipMenu, getNoteMenu, getRenoteMenu } from '@/scripts/get-note-menu.js';
import { useNoteCapture } from '@/scripts/use-note-capture.js';
import { deepClone } from '@/scripts/clone.js';
Expand Down Expand Up @@ -296,6 +297,11 @@ const conversation = ref<Misskey.entities.Note[]>([]);
const replies = ref<Misskey.entities.Note[]>([]);
const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || appearNote.value.userId === $i?.id);
const pleaseLoginContext = {
type: 'lookup',
path: `https://${host}/notes/${appearNote.value.id}`,
} as const;
const keymap = {
'r': () => reply(),
'e|a|plus': () => react(),
Expand Down Expand Up @@ -396,15 +402,15 @@ if (appearNote.value.reactionAcceptance === 'likeOnly') {
}
function renote() {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
showMovedDialog();
const { menu } = getRenoteMenu({ note: note.value, renoteButton });
os.popupMenu(menu, renoteButton.value);
}
function reply(): void {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
showMovedDialog();
os.post({
reply: appearNote.value,
Expand All @@ -415,7 +421,7 @@ function reply(): void {
}
function react(): void {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
showMovedDialog();
if (appearNote.value.reactionAcceptance === 'likeOnly') {
sound.playMisskeySfx('reaction');
Expand Down Expand Up @@ -499,7 +505,7 @@ async function clip(): Promise<void> {
function showRenoteMenu(): void {
if (!isMyRenote) return;
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
os.popupMenu([{
text: i18n.ts.unrenote,
icon: 'ti ti-trash',
Expand Down
8 changes: 7 additions & 1 deletion packages/frontend/src/components/MkPoll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { pleaseLogin } from '@/scripts/please-login.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { host } from '@/config.js';
import { useInterval } from '@/scripts/use-interval.js';
const props = defineProps<{
Expand All @@ -60,6 +61,11 @@ const timer = computed(() => i18n.tsx._poll[
const showResult = ref(props.readOnly || isVoted.value);
const pleaseLoginContext = {
type: 'lookup',
path: `https://${host}/notes/${props.note.id}`,
} as const;
// 期限付きアンケート
if (props.poll.expiresAt) {
const tick = () => {
Expand All @@ -76,7 +82,7 @@ if (props.poll.expiresAt) {
}
const vote = async (id) => {
pleaseLogin();
pleaseLogin(undefined, pleaseLoginContext);
if (props.readOnly || closed.value || isVoted.value) return;
Expand Down
Loading

0 comments on commit 3c032dd

Please sign in to comment.