restore app.tsx
This commit is contained in:
@@ -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() {
|
||||
/>
|
||||
</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-info">
|
||||
<div className="user-profile">
|
||||
@@ -1238,9 +1187,38 @@ function App() {
|
||||
</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 */}
|
||||
{activeTab === 'comments' && (
|
||||
<div className="comments-list">
|
||||
@@ -1555,6 +1533,14 @@ function App() {
|
||||
{error && <p className="error">{error}</p>}
|
||||
</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>
|
||||
</main>
|
||||
|
||||
@@ -1564,4 +1550,4 @@ function App() {
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App;
|
Reference in New Issue
Block a user