restore app.tsx
This commit is contained in:
@@ -431,24 +431,17 @@ 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;
|
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(user.handle)}`);
|
||||||
if (agent) {
|
if (profileResponse.ok) {
|
||||||
const profileResponse = await agent.getProfile({ actor: user.handle });
|
const profileData = await profileResponse.json();
|
||||||
profileData = profileResponse.data;
|
if (profileData.did) {
|
||||||
} else {
|
// Resolved DID
|
||||||
// フォールバック:public API
|
return {
|
||||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(user.handle)}`);
|
...user,
|
||||||
if (profileResponse.ok) {
|
did: profileData.did
|
||||||
profileData = await profileResponse.json();
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (profileData.did) {
|
|
||||||
// Resolved DID
|
|
||||||
return {
|
|
||||||
...user,
|
|
||||||
did: profileData.did
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Failed to resolve DID
|
// Failed to resolve DID
|
||||||
}
|
}
|
||||||
@@ -587,29 +580,23 @@ 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) {
|
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(record.value.author.handle)}`);
|
||||||
// 認証されたAPIでプロフィール取得
|
|
||||||
const profileResponse = await agent.getProfile({ actor: record.value.author.handle });
|
if (profileResponse.ok) {
|
||||||
profileData = profileResponse.data;
|
const profileData = await profileResponse.json();
|
||||||
} else {
|
return {
|
||||||
// フォールバック:public API
|
...record,
|
||||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(record.value.author.handle)}`);
|
value: {
|
||||||
if (profileResponse.ok) {
|
...record.value,
|
||||||
profileData = await profileResponse.json();
|
author: {
|
||||||
}
|
...record.value.author,
|
||||||
}
|
avatar: profileData.avatar,
|
||||||
return {
|
displayName: profileData.displayName || record.value.author.handle,
|
||||||
...record,
|
}
|
||||||
value: {
|
|
||||||
...record.value,
|
|
||||||
author: {
|
|
||||||
...record.value.author,
|
|
||||||
avatar: profileData.avatar,
|
|
||||||
displayName: profileData.displayName || record.value.author.handle,
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
} 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) {
|
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`);
|
||||||
// 認証されたAPIでプロフィールを取得してDIDを解決
|
if (profileResponse.ok) {
|
||||||
const profileResponse = await agent.getProfile({ actor: handle });
|
const profileData = await profileResponse.json();
|
||||||
profileData = profileResponse.data;
|
if (profileData.did) {
|
||||||
} else {
|
resolvedDid = profileData.did;
|
||||||
// フォールバック:public API
|
|
||||||
const profileResponse = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(handle)}`);
|
|
||||||
if (profileResponse.ok) {
|
|
||||||
profileData = await profileResponse.json();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (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>
|
||||||
|
|
||||||
@@ -1564,4 +1550,4 @@ function App() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
Reference in New Issue
Block a user