diff --git a/packages/client/src/components/note-detailed.vue b/packages/client/src/components/note-detailed.vue index 3549ef953..83d8b02e2 100644 --- a/packages/client/src/components/note-detailed.vue +++ b/packages/client/src/components/note-detailed.vue @@ -126,7 +126,7 @@ import XRenoteButton from './renote-button.vue'; import MkUrlPreview from '@/components/url-preview.vue'; import MkInstanceTicker from '@/components/instance-ticker.vue'; import MkVisibility from '@/components/visibility.vue'; -import { pleaseLogin } from '@/scripts/please-login'; +import { pleaseLoginOrRemote, urlForNote } from '@/scripts/please-login'; import { checkWordMute } from '@/scripts/check-word-mute'; import { userPage } from '@/filters/user'; import { notePage } from '@/filters/note'; @@ -195,7 +195,8 @@ useNoteCapture({ }); function reply(viaKeyboard = false): void { - pleaseLogin(); + pleaseLoginOrRemote(urlForNote(appearNote)); + os.post({ reply: appearNote, animation: !viaKeyboard, @@ -205,7 +206,8 @@ function reply(viaKeyboard = false): void { } function react(): void { - pleaseLogin(); + pleaseLoginOrRemote(urlForNote(appearNote)); + blur(); reactionPicker.show(reactButton.value, reaction => { os.api('notes/reactions/create', { diff --git a/packages/client/src/components/note.vue b/packages/client/src/components/note.vue index b0938b3c0..8324f083a 100644 --- a/packages/client/src/components/note.vue +++ b/packages/client/src/components/note.vue @@ -115,7 +115,7 @@ import XRenoteButton from './renote-button.vue'; import MkUrlPreview from '@/components/url-preview.vue'; import MkInstanceTicker from '@/components/instance-ticker.vue'; import MkVisibility from '@/components/visibility.vue'; -import { pleaseLogin } from '@/scripts/please-login'; +import { pleaseLoginOrRemote, urlForNote } from '@/scripts/please-login'; import { focusPrev, focusNext } from '@/scripts/focus'; import { checkWordMute } from '@/scripts/check-word-mute'; import { userPage } from '@/filters/user'; @@ -188,7 +188,8 @@ useNoteCapture({ }); function reply(viaKeyboard = false): void { - pleaseLogin(); + pleaseLoginOrRemote(urlForNote(appearNote)); + os.post({ reply: appearNote, animation: !viaKeyboard, @@ -198,7 +199,8 @@ function reply(viaKeyboard = false): void { } function react(): void { - pleaseLogin(); + pleaseLoginOrRemote(urlForNote(appearNote)); + blur(); reactionPicker.show(reactButton.value, reaction => { os.api('notes/reactions/create', { diff --git a/packages/client/src/components/poll.vue b/packages/client/src/components/poll.vue index 92f0961c9..db1363d28 100644 --- a/packages/client/src/components/poll.vue +++ b/packages/client/src/components/poll.vue @@ -25,7 +25,7 @@ import { computed, ref } from 'vue'; import * as foundkey from 'foundkey-js'; import { sum } from '@/scripts/array'; -import { pleaseLogin } from '@/scripts/please-login'; +import { pleaseLoginOrRemote, urlForNote } from '@/scripts/please-login'; import * as os from '@/os'; import { i18n } from '@/i18n'; import { useInterval } from '@/scripts/use-interval'; @@ -68,7 +68,7 @@ if (props.note.poll.expiresAt) { } const vote = async (id) => { - pleaseLogin(); + pleaseLoginOrRemote(urlForNote(props.note)); if (props.readOnly || closed.value || isVoted.value) return; diff --git a/packages/client/src/components/renote-button.vue b/packages/client/src/components/renote-button.vue index 9e4dbb3e6..4f84b783a 100644 --- a/packages/client/src/components/renote-button.vue +++ b/packages/client/src/components/renote-button.vue @@ -17,7 +17,7 @@ import { computed, ref } from 'vue'; import { Note } from 'foundkey-js/built/entities'; import XDetails from '@/components/users-tooltip.vue'; -import { pleaseLogin } from '@/scripts/please-login'; +import { pleaseLoginOrRemote, urlForNote } from '@/scripts/please-login'; import * as os from '@/os'; import { $i } from '@/account'; import { useTooltip } from '@/scripts/use-tooltip'; @@ -51,7 +51,8 @@ useTooltip(buttonRef, async (showing) => { }); function renote(viaKeyboard = false): void { - pleaseLogin(); + pleaseLoginOrRemote(urlForNote(props.note)); + os.popupMenu([{ text: i18n.ts.renote, icon: 'fas fa-retweet', diff --git a/packages/client/src/scripts/please-login.ts b/packages/client/src/scripts/please-login.ts index 660876070..89c0376ca 100644 --- a/packages/client/src/scripts/please-login.ts +++ b/packages/client/src/scripts/please-login.ts @@ -2,6 +2,8 @@ import { defineAsyncComponent } from 'vue'; import { $i } from '@/account'; import { i18n } from '@/i18n'; import { popup } from '@/os'; +import { url } from '@/config'; +import { entities } from 'foundkey-js'; export function pleaseLoginOrPage(path?: string) { if ($i) return; @@ -19,3 +21,19 @@ export function pleaseLoginOrPage(path?: string) { if (!path) throw new Error('signin required'); } + +export function pleaseLoginOrRemote(url: string) { + if ($i) return; + + popup(defineAsyncComponent(() => import('@/components/remote-interact.vue')), { + remoteUrl, + }, {}, 'closed'); + + throw new Error('signin required'); +} + +export function urlForNote(note: entities.Note): string { + return note.url + ?? note.uri + ?? `${url}/notes/${note.id}`; +}