Skip to content

Commit 129c47d

Browse files
committed
fix: auto-fetch profile from network when no cached data exists
When a wallet with an existing identity is imported, identity discovery stores the identity in the local DB but the DashPay profile is not cached. Previously, the Profile Screen would show 'No Profile Loaded' and require the user to manually click 'Refresh' to fetch from the network. Now, when load_profile_from_database() finds no cached profile data, it automatically queues a network fetch via pending_action. The queueing is guarded with pending_action.is_none() and marks profile_load_attempted before the pending action executes so refresh() does not repeatedly enqueue the same work. Fixes #759
1 parent 7e03205 commit 129c47d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/ui/dashpay/profile_screen.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,19 @@ impl ProfileScreen {
319319
}
320320
}
321321
Ok(None) => {
322-
tracing::debug!("No profile found in database for identity {}", identity_id);
322+
tracing::debug!(
323+
"No profile found in database for identity {}, will auto-fetch from network",
324+
identity_id
325+
);
326+
// No cached profile exists — queue an automatic network fetch
327+
// so the user doesn't have to manually click "Refresh".
328+
if self.pending_action.is_none() {
329+
// Mark that we've already attempted to load a profile to
330+
// avoid repeatedly queuing the same work if this method
331+
// is called again before the pending action executes.
332+
self.profile_load_attempted = true;
333+
self.pending_action = Some(Box::new(self.trigger_load_profile()));
334+
}
323335
}
324336
Err(e) => {
325337
tracing::error!("Error loading profile from database: {}", e);

0 commit comments

Comments
 (0)