Skip to content

Commit ce74462

Browse files
fix: navbar visibility when contact profile is open
1 parent fef8f59 commit ce74462

1 file changed

Lines changed: 65 additions & 2 deletions

File tree

src/main.js

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6292,13 +6292,28 @@ openChat = function(contact) {
62926292
function setupEncryptedNotesButton() {
62936293
const notesBtn = document.getElementById('chat-bookmarks-btn');
62946294
if (notesBtn) {
6295-
notesBtn.onclick = openEncryptedNotes;
6295+
// Remove any existing click handlers to prevent duplicates
6296+
notesBtn.onclick = null;
6297+
notesBtn.addEventListener('click', handleEncryptedNotesClick);
62966298

62976299
// Simple visibility management
62986300
updateEncryptedNotesButton();
62996301
}
63006302
}
63016303

6304+
function handleEncryptedNotesClick() {
6305+
// Store current state before opening notes
6306+
if (strOpenChat !== strPubkey) { // Only store if we're not already in notes
6307+
window.previousStateBeforeNotes = {
6308+
type: window.isViewingProfileInChat ? 'profile' : 'chat',
6309+
profile: window.isViewingProfileInChat ? getProfile(strOpenChat) : null,
6310+
chatId: strOpenChat
6311+
};
6312+
}
6313+
6314+
openEncryptedNotes();
6315+
}
6316+
63026317
// Simple function to show/hide notes button
63036318
function updateEncryptedNotesButton() {
63046319
const notesBtn = document.getElementById('chat-bookmarks-btn');
@@ -6325,7 +6340,38 @@ function updateEncryptedNotesButton() {
63256340
}
63266341

63276342
function openEncryptedNotes() {
6328-
openChat(strPubkey);
6343+
// If we're already in notes and there's a previous state, go back
6344+
if (strOpenChat === strPubkey && window.previousStateBeforeNotes) {
6345+
returnToPreviousState();
6346+
return;
6347+
}
6348+
6349+
// Otherwise open notes
6350+
openChat(strPubkey);
6351+
}
6352+
6353+
function returnToPreviousState() {
6354+
if (!window.previousStateBeforeNotes) {
6355+
// If no previous state, show hello screen
6356+
showHelloScreen();
6357+
return;
6358+
}
6359+
6360+
const previous = window.previousStateBeforeNotes;
6361+
6362+
if (previous.type === 'profile' && previous.profile) {
6363+
// Return to profile view
6364+
showProfileInChatArea(previous.profile);
6365+
} else if (previous.type === 'chat' && previous.chatId) {
6366+
// Return to chat
6367+
openChat(previous.chatId);
6368+
} else {
6369+
// Fallback to hello screen
6370+
showHelloScreen();
6371+
}
6372+
6373+
// Clear the previous state
6374+
window.previousStateBeforeNotes = null;
63296375
}
63306376

63316377
// Function to show profile in chat area
@@ -6335,6 +6381,9 @@ function showProfileInChatArea(profile) {
63356381
// Render the profile first
63366382
renderProfileTab(profile);
63376383

6384+
// IMPORTANT: Keep navbar visible in widescreen
6385+
domNavbar.style.display = '';
6386+
63386387
// Hide ALL chat interface elements completely
63396388
const chatInterface = document.querySelector('.chat-interface');
63406389
if (chatInterface) {
@@ -6452,6 +6501,13 @@ function showProfileInChatArea(profile) {
64526501

64536502
// Store that we're viewing profile in chat context
64546503
window.isViewingProfileInChat = true;
6504+
6505+
// Store the previous state so we can return to it
6506+
window.previousStateBeforeNotes = {
6507+
type: 'profile',
6508+
profile: profile,
6509+
chatId: strOpenChat
6510+
};
64556511
}
64566512

64576513
// Function to close profile and return to chat
@@ -6541,6 +6597,9 @@ function closeProfileInChatArea() {
65416597
mainContainer.appendChild(domProfile);
65426598
}
65436599

6600+
// IMPORTANT: Ensure navbar remains visible
6601+
domNavbar.style.display = '';
6602+
65446603
setTimeout(() => {
65456604
if (domChatMessages) domChatMessages.style.display = 'flex';
65466605
if (domChatMessageBox) domChatMessageBox.style.display = 'flex';
@@ -6559,7 +6618,11 @@ function setupProfileBackButton() {
65596618
if (window.isViewingProfileInChat) {
65606619
// If viewing profile in chat, return to chat
65616620
closeProfileInChatArea();
6621+
} else if (strOpenChat === strPubkey && window.previousStateBeforeNotes) {
6622+
// If in notes with previous state, return to that state
6623+
returnToPreviousState();
65626624
} else if (strOpenChat === strPubkey) {
6625+
// If in notes without previous state, go to hello screen
65636626
closeChat();
65646627
} else {
65656628
openChatlist();

0 commit comments

Comments
 (0)