From 92845705f8af38484b64201d1b8d2738286b6454 Mon Sep 17 00:00:00 2001 From: syui Date: Mon, 16 Jun 2025 02:21:03 +0900 Subject: [PATCH] restore app.tsx --- oauth/src/App.tsx | 154 +++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 84 deletions(-) diff --git a/oauth/src/App.tsx b/oauth/src/App.tsx index d3794cf..928a565 100644 --- a/oauth/src/App.tsx +++ b/oauth/src/App.tsx @@ -431,24 +431,17 @@ function App() { if (user.did && user.did.includes('-placeholder')) { // Resolving placeholder DID 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)}`); - if (profileResponse.ok) { - profileData = await profileResponse.json(); + const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(user.handle)}`); + if (profileResponse.ok) { + const profileData = await profileResponse.json(); + if (profileData.did) { + // Resolved DID + return { + ...user, + did: profileData.did + }; } } - if (profileData.did) { - // Resolved DID - return { - ...user, - did: profileData.did - }; - } } catch (err) { // Failed to resolve DID } @@ -587,29 +580,23 @@ function App() { sortedComments.map(async (record) => { if (!record.value.author?.avatar && record.value.author?.handle) { try { - let profileData; - 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)}`); - if (profileResponse.ok) { - profileData = await profileResponse.json(); - } - } - return { - ...record, - value: { - ...record.value, - author: { - ...record.value.author, - avatar: profileData.avatar, - displayName: profileData.displayName || record.value.author.handle, + // Public API でプロフィール取得 + const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(record.value.author.handle)}`); + + if (profileResponse.ok) { + const profileData = await profileResponse.json(); + return { + ...record, + value: { + ...record.value, + author: { + ...record.value.author, + avatar: profileData.avatar, + displayName: profileData.displayName || record.value.author.handle, + } } - } - }; + }; + } } catch (err) { // Ignore enhancement errors } @@ -809,21 +796,14 @@ function App() { let resolvedDid = `did:plc:${handle.replace(/\./g, '-')}-placeholder`; // フォールバック try { - let profileData; - 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)}`); - if (profileResponse.ok) { - profileData = await profileResponse.json(); + // Public APIでプロフィールを取得してDIDを解決 + const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`); + if (profileResponse.ok) { + const profileData = await profileResponse.json(); + if (profileData.did) { + resolvedDid = profileData.did; } } - if (profileData.did) { - resolvedDid = profileData.did; - } } catch (err) { } @@ -1099,38 +1079,7 @@ function App() { /> - ) : null} - - {/* Tab Navigation */} -
- - - - -
- - {/* User Section - moved below tab navigation */} - {user && ( + ) : (
@@ -1238,9 +1187,38 @@ function App() {
)} +
)} + {/* Tab Navigation */} +
+ + + + +
+ {/* Comments List */} {activeTab === 'comments' && (
@@ -1555,6 +1533,14 @@ function App() { {error &&

{error}

}
)} + + {/* Show authentication status on non-post pages */} + {user && !appConfig.rkey && ( +
+

✅ Authenticated as @{user.handle}

+

Visit a post page to comment

+
+ )} @@ -1564,4 +1550,4 @@ function App() { ); } -export default App; +export default App; \ No newline at end of file