Fix reopen-last behavior with new settings hash

This commit is contained in:
Jack Kingsman
2026-03-16 18:17:21 -07:00
parent e19a8d3395
commit 9c06ed62a4
2 changed files with 32 additions and 1 deletions

View File

@@ -211,7 +211,7 @@ export function useConversationRouter({
if (hashSyncEnabledRef.current && !suspendHashSync) {
updateUrlHash(activeConversation);
}
if (getReopenLastConversationEnabled() && activeConversation.type !== 'search') {
if (activeConversation.type !== 'search') {
saveLastViewedConversation(activeConversation);
}
}

View File

@@ -256,6 +256,37 @@ describe('App startup hash resolution', () => {
expect(window.location.hash).toBe('');
});
it('tracks the current conversation in local storage even before reopen is enabled', async () => {
const chatChannel = {
key: '11111111111111111111111111111111',
name: 'Ops',
is_hashtag: false,
on_radio: false,
last_read_at: null,
};
window.location.hash = '';
mocks.api.getChannels.mockResolvedValue([publicChannel, chatChannel]);
localStorage.setItem(
LAST_VIEWED_CONVERSATION_KEY,
JSON.stringify({
type: 'channel',
id: chatChannel.key,
name: chatChannel.name,
})
);
render(<App />);
await waitFor(() => {
for (const node of screen.getAllByTestId('active-conversation')) {
expect(node).toHaveTextContent(`channel:${publicChannel.key}:Public`);
}
});
expect(localStorage.getItem(LAST_VIEWED_CONVERSATION_KEY)).toContain(publicChannel.key);
});
it('restores last viewed contact from legacy name token when hash is empty and reopen is enabled', async () => {
const aliceContact = {
public_key: 'b'.repeat(64),