Skip to content

Commit bb6ea5f

Browse files
rainerstudiosclaude
andcommitted
Fix: Accurate login status detection in popup
Problem: - Showed 'Syncing to SteamLedger' even when logged out - Logic only checked old transaction history, not current login state Solution: - Track lastSyncSuccess timestamp when transactions sync - Only show 'logged in' state if: • Successful sync within last 5 minutes AND • No pending transactions - Otherwise show 'Create Account' section This prevents false positives when: - User logs out after syncing - User never logged in but has no transactions - Sync failed due to auth errors More conservative = better conversion prompts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 16fcdaf commit bb6ea5f

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

background.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,10 @@ async function syncSingleTransaction(tx, transactions) {
12901290
// Success - mark as synced
12911291
tx.status = 'synced';
12921292
tx.syncedAt = Date.now();
1293+
1294+
// Track last successful sync for login status detection
1295+
await chrome.storage.local.set({ lastSyncSuccess: Date.now() });
1296+
12931297
console.log(`[Background] Successfully synced: ${tx.itemName}`);
12941298
return;
12951299

popup.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,28 +345,28 @@ function initialize() {
345345
async function loadAccountStatus() {
346346
try {
347347
// Get pending transactions from storage
348-
const result = await chrome.storage.local.get(['pendingTransactions']);
348+
const result = await chrome.storage.local.get(['pendingTransactions', 'lastSyncSuccess']);
349349
const transactions = result.pendingTransactions || [];
350+
const lastSyncSuccess = result.lastSyncSuccess || 0;
350351

351352
const pendingCount = transactions.filter(tx =>
352353
tx.status === 'pending' || tx.status === 'failed'
353354
).length;
354355

355-
const syncedCount = transactions.filter(tx =>
356-
tx.status === 'synced'
357-
).length;
358-
359356
const notLoggedInDiv = document.getElementById('accountNotLoggedIn');
360357
const loggedInDiv = document.getElementById('accountLoggedIn');
361358
const pendingCountSpan = document.getElementById('pendingCount');
362359

363-
// Show appropriate section based on sync status
364-
if (syncedCount > 0 || pendingCount === 0) {
365-
// User is likely logged in (has synced transactions) or no transactions yet
360+
// Check if user successfully synced recently (within last 5 minutes)
361+
const recentlySync = (Date.now() - lastSyncSuccess) < 5 * 60 * 1000;
362+
363+
// Conservative logic: Only show "logged in" if recently synced successfully
364+
if (recentlySync && pendingCount === 0) {
365+
// User is logged in and all transactions are synced
366366
notLoggedInDiv.style.display = 'none';
367367
loggedInDiv.style.display = 'block';
368368
} else {
369-
// User has pending transactions (not logged in)
369+
// Show "Create Account" if any pending OR no recent sync
370370
notLoggedInDiv.style.display = 'block';
371371
loggedInDiv.style.display = 'none';
372372
pendingCountSpan.textContent = pendingCount;

0 commit comments

Comments
 (0)