fix test ask-AI oauth profile
This commit is contained in:
@@ -197,7 +197,6 @@ a.view-markdown:any-link {
|
|||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main Content */
|
|
||||||
.main-content {
|
.main-content {
|
||||||
grid-area: main;
|
grid-area: main;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
@@ -1141,7 +1140,17 @@ article.article-content {
|
|||||||
.article-meta {
|
.article-meta {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article-actions {
|
.article-actions {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
article.article-content {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ask-ai-content {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,16 +12,66 @@ function toggleAskAI() {
|
|||||||
panel.style.display = isVisible ? 'none' : 'block';
|
panel.style.display = isVisible ? 'none' : 'block';
|
||||||
|
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
checkAuthenticationStatus();
|
console.log('Ask AI panel opened');
|
||||||
|
|
||||||
|
// For production fallback - if OAuth app fails to load, show profiles
|
||||||
|
const isProd = window.location.hostname !== 'localhost' && !window.location.hostname.includes('preview');
|
||||||
|
if (isProd) {
|
||||||
|
console.log('Production environment detected - using fallback profile display');
|
||||||
|
// Shorter timeout for production
|
||||||
|
setTimeout(() => {
|
||||||
|
const userSections = document.querySelectorAll('.user-section');
|
||||||
|
console.log('Production check - user sections:', userSections.length);
|
||||||
|
|
||||||
|
if (userSections.length === 0) {
|
||||||
|
console.log('No user sections found in production - showing profiles directly');
|
||||||
|
handleAuthenticationStatus(false);
|
||||||
|
} else {
|
||||||
|
console.log('User sections found in production - showing authenticated UI');
|
||||||
|
handleAuthenticationStatus(true);
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
} else {
|
||||||
|
checkAuthenticationStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkAuthenticationStatus() {
|
function checkAuthenticationStatus() {
|
||||||
const userSections = document.querySelectorAll('.user-section');
|
// Check multiple times for OAuth app to load
|
||||||
const isAuthenticated = userSections.length > 0;
|
let checkCount = 0;
|
||||||
|
const maxChecks = 10;
|
||||||
|
|
||||||
|
const checkForAuth = () => {
|
||||||
|
console.log(`Auth check attempt ${checkCount + 1}/${maxChecks}`);
|
||||||
|
const userSections = document.querySelectorAll('.user-section');
|
||||||
|
const authButtons = document.querySelectorAll('[data-auth-status]');
|
||||||
|
const oauthContainers = document.querySelectorAll('#oauth-container');
|
||||||
|
|
||||||
|
console.log('User sections found:', userSections.length);
|
||||||
|
console.log('Auth buttons found:', authButtons.length);
|
||||||
|
console.log('OAuth containers found:', oauthContainers.length);
|
||||||
|
|
||||||
|
const isAuthenticated = userSections.length > 0;
|
||||||
|
|
||||||
|
if (isAuthenticated || checkCount >= maxChecks - 1) {
|
||||||
|
console.log('Final auth status:', isAuthenticated);
|
||||||
|
handleAuthenticationStatus(isAuthenticated);
|
||||||
|
} else {
|
||||||
|
checkCount++;
|
||||||
|
setTimeout(checkForAuth, 200);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
checkForAuth();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleAuthenticationStatus(isAuthenticated) {
|
||||||
|
console.log('Handling auth status:', isAuthenticated);
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
// User is authenticated - show Ask AI UI
|
// User is authenticated - show Ask AI UI
|
||||||
|
console.log('User authenticated - showing AI chat interface');
|
||||||
document.getElementById('authCheck').style.display = 'none';
|
document.getElementById('authCheck').style.display = 'none';
|
||||||
document.getElementById('chatForm').style.display = 'block';
|
document.getElementById('chatForm').style.display = 'block';
|
||||||
document.getElementById('chatHistory').style.display = 'block';
|
document.getElementById('chatHistory').style.display = 'block';
|
||||||
@@ -38,6 +88,7 @@ function checkAuthenticationStatus() {
|
|||||||
}, 50);
|
}, 50);
|
||||||
} else {
|
} else {
|
||||||
// User not authenticated - show profiles instead of auth message
|
// User not authenticated - show profiles instead of auth message
|
||||||
|
console.log('User not authenticated - showing profiles');
|
||||||
document.getElementById('authCheck').style.display = 'none';
|
document.getElementById('authCheck').style.display = 'none';
|
||||||
document.getElementById('chatForm').style.display = 'none';
|
document.getElementById('chatForm').style.display = 'none';
|
||||||
document.getElementById('chatHistory').style.display = 'block';
|
document.getElementById('chatHistory').style.display = 'block';
|
||||||
@@ -377,6 +428,37 @@ function setupAskAIEventListeners() {
|
|||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
setupAskAIEventListeners();
|
setupAskAIEventListeners();
|
||||||
console.log('Ask AI initialized successfully');
|
console.log('Ask AI initialized successfully');
|
||||||
|
|
||||||
|
// Also listen for OAuth app load completion
|
||||||
|
const observer = new MutationObserver(function(mutations) {
|
||||||
|
mutations.forEach(function(mutation) {
|
||||||
|
if (mutation.type === 'childList') {
|
||||||
|
// Check if user-section was added/removed
|
||||||
|
const userSectionAdded = Array.from(mutation.addedNodes).some(node =>
|
||||||
|
node.nodeType === Node.ELEMENT_NODE &&
|
||||||
|
(node.classList?.contains('user-section') || node.querySelector?.('.user-section'))
|
||||||
|
);
|
||||||
|
const userSectionRemoved = Array.from(mutation.removedNodes).some(node =>
|
||||||
|
node.nodeType === Node.ELEMENT_NODE &&
|
||||||
|
(node.classList?.contains('user-section') || node.querySelector?.('.user-section'))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (userSectionAdded || userSectionRemoved) {
|
||||||
|
console.log('User section status changed');
|
||||||
|
// Update Ask AI panel if it's visible
|
||||||
|
const panel = document.getElementById('askAiPanel');
|
||||||
|
if (panel && panel.style.display !== 'none') {
|
||||||
|
checkAuthenticationStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Global functions for onclick handlers
|
// Global functions for onclick handlers
|
||||||
|
@@ -61,7 +61,7 @@
|
|||||||
<div class="ask-ai-panel" id="askAiPanel" style="display: none;">
|
<div class="ask-ai-panel" id="askAiPanel" style="display: none;">
|
||||||
<div class="ask-ai-content">
|
<div class="ask-ai-content">
|
||||||
<div id="authCheck" class="auth-check">
|
<div id="authCheck" class="auth-check">
|
||||||
<p>profile</p>
|
<p>atproto</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="chatForm" class="ask-ai-form" style="display: none;">
|
<div id="chatForm" class="ask-ai-form" style="display: none;">
|
||||||
|
@@ -1070,6 +1070,13 @@ body {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
article.article-content {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ask-ai-content {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avatar Styles */
|
/* Avatar Styles */
|
||||||
|
@@ -69,8 +69,6 @@ export default function ChatRecordList({ chatPairs, apiConfig, user = null, agen
|
|||||||
)}
|
)}
|
||||||
<div className="user-info">
|
<div className="user-info">
|
||||||
<div className="display-name">{chatPair.question.value.author?.displayName || chatPair.question.value.author?.handle}</div>
|
<div className="display-name">{chatPair.question.value.author?.displayName || chatPair.question.value.author?.handle}</div>
|
||||||
<div className="handle">@{chatPair.question.value.author?.handle}</div>
|
|
||||||
<div className="timestamp">{new Date(chatPair.question.value.createdAt).toLocaleString()}</div>
|
|
||||||
</div>
|
</div>
|
||||||
{canDelete(chatPair) && (
|
{canDelete(chatPair) && (
|
||||||
<div className="record-actions">
|
<div className="record-actions">
|
||||||
@@ -105,8 +103,6 @@ export default function ChatRecordList({ chatPairs, apiConfig, user = null, agen
|
|||||||
)}
|
)}
|
||||||
<div className="user-info">
|
<div className="user-info">
|
||||||
<div className="display-name">{chatPair.answer.value.author?.displayName || chatPair.answer.value.author?.handle}</div>
|
<div className="display-name">{chatPair.answer.value.author?.displayName || chatPair.answer.value.author?.handle}</div>
|
||||||
<div className="handle">@{chatPair.answer.value.author?.handle}</div>
|
|
||||||
<div className="timestamp">{new Date(chatPair.answer.value.createdAt).toLocaleString()}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="message-content">{chatPair.answer.value.text}</div>
|
<div className="message-content">{chatPair.answer.value.text}</div>
|
||||||
|
@@ -58,8 +58,6 @@ export default function ProfileRecordList({ profileRecords, apiConfig, user = nu
|
|||||||
<span className="admin-badge"> Admin</span>
|
<span className="admin-badge"> Admin</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="handle">@{profile.value.author?.handle}</div>
|
|
||||||
<div className="timestamp">{new Date(profile.value.createdAt).toLocaleString()}</div>
|
|
||||||
</div>
|
</div>
|
||||||
{canDelete(profile) && (
|
{canDelete(profile) && (
|
||||||
<div className="record-actions">
|
<div className="record-actions">
|
||||||
|
@@ -64,18 +64,18 @@ export default function RecordTabs({ langRecords, commentRecords, userComments,
|
|||||||
>
|
>
|
||||||
chat ({userChatRecords?.length || 0})
|
chat ({userChatRecords?.length || 0})
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
className={`tab-btn ${activeTab === 'users' ? 'active' : ''}`}
|
|
||||||
onClick={() => setActiveTab('users')}
|
|
||||||
>
|
|
||||||
comment ({filteredUserComments.length})
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
className={`tab-btn ${activeTab === 'comment' ? 'active' : ''}`}
|
className={`tab-btn ${activeTab === 'comment' ? 'active' : ''}`}
|
||||||
onClick={() => setActiveTab('comment')}
|
onClick={() => setActiveTab('comment')}
|
||||||
>
|
>
|
||||||
feedback ({filteredCommentRecords.length})
|
feedback ({filteredCommentRecords.length})
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
className={`tab-btn ${activeTab === 'users' ? 'active' : ''}`}
|
||||||
|
onClick={() => setActiveTab('users')}
|
||||||
|
>
|
||||||
|
comment ({filteredUserComments.length})
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`tab-btn ${activeTab === 'lang' ? 'active' : ''}`}
|
className={`tab-btn ${activeTab === 'lang' ? 'active' : ''}`}
|
||||||
onClick={() => setActiveTab('lang')}
|
onClick={() => setActiveTab('lang')}
|
||||||
|
Reference in New Issue
Block a user