Skip to content

Conversation

@kamieniarz
Copy link
Contributor

These fields in profile (configured in config: database.settings.extraUserFields) refresh on re-login only. I made them update on each profile window open
image

Disclaimer: PR created with AI. I have no idea what I'm doing

@Mygod
Copy link
Collaborator

Mygod commented Sep 30, 2025

This patch seems really questionable. An API fetch shouldn't be cached by the browser and you added multiple mechanisms to prevent caching.

Are you using your map behind a CDN? Would the outdated data be an issue if you try connect to your map without going through the CDN?

@kamieniarz
Copy link
Contributor Author

That's just a straight solution from AI 🤷‍♂️ Garbage in garbage out 😅 I used your commeng and updated fetches.js

@Mygod
Copy link
Collaborator

Mygod commented Sep 30, 2025

Umm I am suggesting that something else (non-reactmap) might be the issue here. Have you tried what I suggested?

@kamieniarz
Copy link
Contributor Author

Why it would be non-reactmap? I simply used AI on repo with prompt pretty much like "extraUserFields refresh on re-login only - make it refresh on each profile window open". There was no other context than that

@Mygod
Copy link
Collaborator

Mygod commented Sep 30, 2025

The fact that this fixed it for you seems to say that this might be a different issue.

@kamieniarz
Copy link
Contributor Author

I'm not sure that's an issue in the first place. I guess it's just how that feature was developed and the way it currently works was intended

@Mygod Mygod mentioned this pull request Oct 1, 2025
@Mygod
Copy link
Collaborator

Mygod commented Oct 1, 2025

Please check if #1145 fixes the issue for you.

P.S. You can call it a programmer's intuition but it appears to me that your patch works around the problem rather than addressing the root cause. Here's what my codex found:

  • Blocking – src/features/profile/ExtraFields.jsx:57: the mutation still submits the pre-change value captured from the hook, so the database never sees the freshly typed target.value. That’s why the user only ever sees the “old” data again after a reload/login. The change set does nothing to address this root cause—please switch the payload to value: target.value (and ideally wait for the mutation result before mutating local state) so the server
    actually stores the update.
  • Minor – src/features/profile/index.jsx:37: once the mutation is fixed the extra getSettings fetch on every profile open becomes redundant churn. It only rewrites auth.data, leaves the rest of the settings stale (e.g. new fields won’t appear), and adds latency; consider removing it instead of shipping unnecessary network work.
  • Neutral – server/src/routes/rootRouter.js:214: adding the Cache-Control header is harmless and may help with an overly aggressive CDN, but it isn’t what was breaking the feature—the stale payload bug above is. Keep the header if you want stricter cache semantics, but don’t expect it to compensate for the client bug.

@Mygod
Copy link
Collaborator

Mygod commented Oct 1, 2025

Does your patch work if you revert the changes in server/src/routes/rootRouter.js?

@kamieniarz
Copy link
Contributor Author

No

@Mygod Mygod requested a review from Copilot October 1, 2025 20:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Updates the user profile to refresh extraUserFields data whenever the profile window is opened, instead of only on re-login. This provides more current information to users without requiring them to log out and back in.

  • Adds automatic data refresh when profile dialog opens
  • Updates server endpoint to include user data in response
  • Maintains existing error handling and cleanup patterns

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/features/profile/index.jsx Adds useEffect to fetch and update user data when profile opens
server/src/routes/rootRouter.js Updates settings endpoint to include user data in response

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Mygod Mygod requested a review from Copilot October 1, 2025 21:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Mygod
Copy link
Collaborator

Mygod commented Oct 1, 2025

@kamieniarz I did some additional improvements on your PR. Please check if it still works for you?

@kamieniarz
Copy link
Contributor Author

Everything works 💪

@Mygod Mygod merged commit 2216787 into WatWowMap:develop Oct 1, 2025
2 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 1, 2025
# [1.40.0-develop.6](v1.40.0-develop.5...v1.40.0-develop.6) (2025-10-01)

### Features

* faster extraUserFields ([#1144](#1144)) ([2216787](2216787))
@github-actions
Copy link

github-actions bot commented Oct 1, 2025

🎉 This PR is included in version 1.40.0-develop.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants