From 1793de40c178ed4b16f3036bc2f7cb064b9cc33f Mon Sep 17 00:00:00 2001 From: syui Date: Thu, 19 Jun 2025 13:17:32 +0900 Subject: [PATCH] fix rm callback page --- oauth/src/App.jsx | 1 - oauth/src/components/CommentForm.jsx | 36 ++++++++++++-------------- oauth/src/components/OAuthCallback.jsx | 13 +++------- oauth/src/services/oauth.js | 7 ----- 4 files changed, 20 insertions(+), 37 deletions(-) diff --git a/oauth/src/App.jsx b/oauth/src/App.jsx index 5e49c65..9ab8d20 100644 --- a/oauth/src/App.jsx +++ b/oauth/src/App.jsx @@ -133,7 +133,6 @@ export default function App() { { refreshAdminData?.() refreshUserData?.() diff --git a/oauth/src/components/CommentForm.jsx b/oauth/src/components/CommentForm.jsx index 83c2743..1f7c615 100644 --- a/oauth/src/components/CommentForm.jsx +++ b/oauth/src/components/CommentForm.jsx @@ -2,34 +2,21 @@ import React, { useState } from 'react' import { atproto, collections } from '../api/atproto.js' import { env } from '../config/env.js' -export default function CommentForm({ user, agent, onCommentPosted, pageContext }) { +export default function CommentForm({ user, agent, onCommentPosted }) { const [text, setText] = useState('') + const [url, setUrl] = useState('') const [loading, setLoading] = useState(false) const [error, setError] = useState(null) - - // Get current URL automatically, but exclude OAuth callback URLs - const getCurrentUrl = () => { - const currentPath = window.location.href - - // If on OAuth callback page, get the stored return URL or use root - if (currentPath.includes('/oauth/callback')) { - return sessionStorage.getItem('oauth_return_url') || window.location.origin - } - - // Remove hash fragments for clean URLs - return currentPath.split('#')[0] - } - - const currentUrl = getCurrentUrl() const handleSubmit = async (e) => { e.preventDefault() - if (!text.trim()) return + if (!text.trim() || !url.trim()) return setLoading(true) setError(null) try { + const currentUrl = url.trim() const timestamp = new Date().toISOString() // Create ai.syui.log record structure (new unified format) @@ -68,6 +55,7 @@ export default function CommentForm({ user, agent, onCommentPosted, pageContext // Clear form setText('') + setUrl('') // Notify parent component if (onCommentPosted) { @@ -98,8 +86,18 @@ export default function CommentForm({ user, agent, onCommentPosted, pageContext

コメントを投稿

-
- ページ: {currentUrl} +
+ + setUrl(e.target.value)} + placeholder="https://syui.ai/posts/example" + required + disabled={loading} + className="form-input" + />
diff --git a/oauth/src/components/OAuthCallback.jsx b/oauth/src/components/OAuthCallback.jsx index 29f07e4..f61b444 100644 --- a/oauth/src/components/OAuthCallback.jsx +++ b/oauth/src/components/OAuthCallback.jsx @@ -20,18 +20,11 @@ export default function OAuthCallback({ onAuthSuccess }) { } if (code) { - setStatus('認証成功!元のページに戻ります...') + setStatus('認証成功!メインページに戻ります...') - // 認証前のページを復元するか、ルートページに戻る - const returnUrl = sessionStorage.getItem('oauth_return_url') || '/' - sessionStorage.removeItem('oauth_return_url') - - // Clean up URL fragments and normalize - const cleanReturnUrl = returnUrl.split('#')[0] - - // 少し待ってから元のページにリダイレクト + // 少し待ってからメインページにリダイレクト setTimeout(() => { - window.location.replace(cleanReturnUrl) + window.location.href = '/' }, 1500) } else { setStatus('認証情報が見つかりません') diff --git a/oauth/src/services/oauth.js b/oauth/src/services/oauth.js index dadd6d6..2cff4ac 100644 --- a/oauth/src/services/oauth.js +++ b/oauth/src/services/oauth.js @@ -97,13 +97,6 @@ export class OAuthService { async login(handle) { await this.initialize() - // Save current URL for return after OAuth - const currentUrl = window.location.href - // Only save if not already on oauth callback page - if (!currentUrl.includes('/oauth/callback')) { - sessionStorage.setItem('oauth_return_url', currentUrl) - } - const client = isSyuIsHandle(handle) ? this.clients.syu : this.clients.bsky const authUrl = await client.authorize(handle, { scope: 'atproto transition:generic'