fix(AccountView): resolve stale registration status cache after identity creation

- Add live registration verification to AccountView.initializeState()
- When settings show unregistered but user has activeDid, verify with server
- Use fetchEndorserRateLimits() matching HomeView's successful pattern
- Update database and UI state immediately upon server confirmation
- Eliminate need to navigate away/back to refresh registration status

Technical details:
- Condition: if (!this.isRegistered && this.activeDid)
- Server check: fetchEndorserRateLimits(this.apiServer, this.axios, this.activeDid)
- On success: $saveUserSettings({isRegistered: true}) + this.isRegistered = true
- Graceful handling for actually unregistered users (expected behavior)

Fixes issue where AccountView showed "Before you can publicly announce..."
message immediately after User Zero identity creation, despite server confirming
user was registered. Problem was Vue component state caching stale settings
while database contained updated registration status.

Resolves behavior reported in iOS testing: User had to navigate to HomeView
and back to AccountView for registration status to update properly.
This commit is contained in:
Matthew Raymer
2025-10-02 08:27:56 +00:00
parent 666bed0efd
commit 20322789a2

View File

@@ -1064,6 +1064,42 @@ export default class AccountViewView extends Vue {
this.hideRegisterPromptOnNewContact = this.hideRegisterPromptOnNewContact =
!!settings.hideRegisterPromptOnNewContact; !!settings.hideRegisterPromptOnNewContact;
this.isRegistered = !!settings?.isRegistered; this.isRegistered = !!settings?.isRegistered;
// If settings show unregistered but user has activeDid, verify registration status
if (!this.isRegistered && this.activeDid) {
logger.debug("[AccountViewView] Settings show unregistered, verifying with server:", {
activeDid: this.activeDid,
apiServer: this.apiServer,
});
try {
const { fetchEndorserRateLimits } = await import("@/libs/endorserServer");
const resp = await fetchEndorserRateLimits(
this.apiServer,
this.axios,
this.activeDid,
);
if (resp.status === 200) {
logger.debug("[AccountViewView] Server confirms user IS registered, updating settings:", {
activeDid: this.activeDid,
wasRegistered: false,
nowRegistered: true,
});
// Update settings and state
await this.$saveUserSettings(this.activeDid, {
isRegistered: true,
});
this.isRegistered = true;
}
} catch (error) {
logger.debug("[AccountViewView] Registration check failed (expected for unregistered users):", {
activeDid: this.activeDid,
error: error instanceof Error ? error.message : String(error),
});
}
}
this.isSearchAreasSet = !!settings.searchBoxes; this.isSearchAreasSet = !!settings.searchBoxes;
this.searchBox = settings.searchBoxes?.[0] || null; this.searchBox = settings.searchBoxes?.[0] || null;
this.notifyingNewActivity = !!settings.notifyingNewActivityTime; this.notifyingNewActivity = !!settings.notifyingNewActivityTime;