Fix pull silently skipping on fresh browser install; show last pull time
Three issues in the Gist pull flow on a browser with no prior data:
1. _getAllData() returned Date.now() as lastModified when ss_lastModified
was unset (fresh install). The timestamp check in pullFromGist then
saw the Gist data as older than local, silently returned imported:false
("Already up to date") without importing anything or prompting for
auth. Fixed by using || 0 so a browser with no data always accepts
remote data as newer.
2. _applyData now persists ss_last_pull_time and ss_last_pull_source so
the last successful pull survives page reloads.
3. The Gist section on the options page now shows "Last pulled: <time>"
alongside the Gist ID on load, so both browsers display their sync
status rather than showing nothing on first open.
https://claude.ai/code/session_01QJnEnLfbXKR5FSCQ3Qfs53
This commit is contained in:
+5
-2
@@ -901,7 +901,7 @@ const SilentSendSync = {
|
||||
const result = await api.storage.local.get('ss_lastModified');
|
||||
return {
|
||||
version: '1',
|
||||
lastModified: result.ss_lastModified || Date.now(),
|
||||
lastModified: result.ss_lastModified || 0,
|
||||
identity: identity || {},
|
||||
mappings: mappings || [],
|
||||
settings: settings || {},
|
||||
@@ -924,9 +924,12 @@ const SilentSendSync = {
|
||||
}
|
||||
|
||||
// Metadata stays plaintext
|
||||
const now = Date.now();
|
||||
await api.storage.local.set({
|
||||
ss_lastModified: data.lastModified,
|
||||
ss_sync_notification: { source, time: Date.now() },
|
||||
ss_sync_notification: { source, time: now },
|
||||
ss_last_pull_time: now,
|
||||
ss_last_pull_source: source,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -161,9 +161,13 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
// --- GitHub Gist sync ---
|
||||
// Restore saved token (session only — never persisted to storage)
|
||||
{
|
||||
const stored = await api.storage.local.get('ss_gist_id');
|
||||
const stored = await api.storage.local.get(['ss_gist_id', 'ss_last_pull_time', 'ss_last_pull_source']);
|
||||
if (stored.ss_gist_id) {
|
||||
setGistSyncStatus(`Gist ID: ${stored.ss_gist_id.slice(0, 12)}…`, 'ok');
|
||||
let status = `Gist ID: ${stored.ss_gist_id.slice(0, 12)}…`;
|
||||
if (stored.ss_last_pull_time && stored.ss_last_pull_source === 'gist') {
|
||||
status += ` · Last pulled: ${new Date(stored.ss_last_pull_time).toLocaleString()}`;
|
||||
}
|
||||
setGistSyncStatus(status, 'ok');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user