restore app.tsx

This commit is contained in:
2025-06-16 02:21:03 +09:00
parent 40493d0958
commit 92845705f8

View File

@@ -431,17 +431,9 @@ function App() {
if (user.did && user.did.includes('-placeholder')) { if (user.did && user.did.includes('-placeholder')) {
// Resolving placeholder DID // Resolving placeholder DID
try { try {
let profileData;
if (agent) {
const profileResponse = await agent.getProfile({ actor: user.handle });
profileData = profileResponse.data;
} else {
// フォールバックpublic API
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(user.handle)}`); const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(user.handle)}`);
if (profileResponse.ok) { if (profileResponse.ok) {
profileData = await profileResponse.json(); const profileData = await profileResponse.json();
}
}
if (profileData.did) { if (profileData.did) {
// Resolved DID // Resolved DID
return { return {
@@ -449,6 +441,7 @@ function App() {
did: profileData.did did: profileData.did
}; };
} }
}
} catch (err) { } catch (err) {
// Failed to resolve DID // Failed to resolve DID
} }
@@ -587,18 +580,11 @@ function App() {
sortedComments.map(async (record) => { sortedComments.map(async (record) => {
if (!record.value.author?.avatar && record.value.author?.handle) { if (!record.value.author?.avatar && record.value.author?.handle) {
try { try {
let profileData; // Public API でプロフィール取得
if (agent) {
// 認証されたAPIでプロフィール取得
const profileResponse = await agent.getProfile({ actor: record.value.author.handle });
profileData = profileResponse.data;
} else {
// フォールバックpublic API
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(record.value.author.handle)}`); const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(record.value.author.handle)}`);
if (profileResponse.ok) { if (profileResponse.ok) {
profileData = await profileResponse.json(); const profileData = await profileResponse.json();
}
}
return { return {
...record, ...record,
value: { value: {
@@ -610,6 +596,7 @@ function App() {
} }
} }
}; };
}
} catch (err) { } catch (err) {
// Ignore enhancement errors // Ignore enhancement errors
} }
@@ -809,21 +796,14 @@ function App() {
let resolvedDid = `did:plc:${handle.replace(/\./g, '-')}-placeholder`; // フォールバック let resolvedDid = `did:plc:${handle.replace(/\./g, '-')}-placeholder`; // フォールバック
try { try {
let profileData; // Public APIでプロフィールを取得してDIDを解決
if (agent) {
// 認証されたAPIでプロフィールを取得してDIDを解決
const profileResponse = await agent.getProfile({ actor: handle });
profileData = profileResponse.data;
} else {
// フォールバックpublic API
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`); const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`);
if (profileResponse.ok) { if (profileResponse.ok) {
profileData = await profileResponse.json(); const profileData = await profileResponse.json();
}
}
if (profileData.did) { if (profileData.did) {
resolvedDid = profileData.did; resolvedDid = profileData.did;
} }
}
} catch (err) { } catch (err) {
} }
@@ -1099,38 +1079,7 @@ function App() {
/> />
</div> </div>
</div> </div>
) : null} ) : (
{/* Tab Navigation */}
<div className="tab-navigation">
<button
className={`tab-button ${activeTab === 'comments' ? 'active' : ''}`}
onClick={() => setActiveTab('comments')}
>
comment ({comments.filter(shouldShowComment).length})
</button>
<button
className={`tab-button ${activeTab === 'ai-chat' ? 'active' : ''}`}
onClick={() => setActiveTab('ai-chat')}
>
chat ({aiChatHistory.length})
</button>
<button
className={`tab-button ${activeTab === 'lang-en' ? 'active' : ''}`}
onClick={() => setActiveTab('lang-en')}
>
en ({langEnRecords.length})
</button>
<button
className={`tab-button ${activeTab === 'ai-comment' ? 'active' : ''}`}
onClick={() => setActiveTab('ai-comment')}
>
feedback ({aiCommentRecords.length})
</button>
</div>
{/* User Section - moved below tab navigation */}
{user && (
<div className="user-section"> <div className="user-section">
<div className="user-info"> <div className="user-info">
<div className="user-profile"> <div className="user-profile">
@@ -1238,9 +1187,38 @@ function App() {
</div> </div>
</div> </div>
)} )}
</div> </div>
)} )}
{/* Tab Navigation */}
<div className="tab-navigation">
<button
className={`tab-button ${activeTab === 'comments' ? 'active' : ''}`}
onClick={() => setActiveTab('comments')}
>
Comments ({comments.filter(shouldShowComment).length})
</button>
<button
className={`tab-button ${activeTab === 'ai-chat' ? 'active' : ''}`}
onClick={() => setActiveTab('ai-chat')}
>
AI Chat ({aiChatHistory.length})
</button>
<button
className={`tab-button ${activeTab === 'lang-en' ? 'active' : ''}`}
onClick={() => setActiveTab('lang-en')}
>
AI Lang:en ({langEnRecords.length})
</button>
<button
className={`tab-button ${activeTab === 'ai-comment' ? 'active' : ''}`}
onClick={() => setActiveTab('ai-comment')}
>
AI Comment ({aiCommentRecords.length})
</button>
</div>
{/* Comments List */} {/* Comments List */}
{activeTab === 'comments' && ( {activeTab === 'comments' && (
<div className="comments-list"> <div className="comments-list">
@@ -1555,6 +1533,14 @@ function App() {
{error && <p className="error">{error}</p>} {error && <p className="error">{error}</p>}
</div> </div>
)} )}
{/* Show authentication status on non-post pages */}
{user && !appConfig.rkey && (
<div className="auth-status">
<p> Authenticated as @{user.handle}</p>
<p><small>Visit a post page to comment</small></p>
</div>
)}
</section> </section>
</main> </main>