Skip to content

Conversation

@flodolo
Copy link
Collaborator

@flodolo flodolo commented Feb 5, 2026

Fixes #3900

Not sure if there's a better way to do it.

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.50%. Comparing base (dffde97) to head (9ee9c07).
⚠️ Report is 2 commits behind head on main.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@flodolo flodolo requested a review from mathjazz February 5, 2026 17:58
@flodolo
Copy link
Collaborator Author

flodolo commented Feb 7, 2026

I tried to use the data already available in the frontend instead of adding info to the Django template.

Just in case, I kept the changes in a separate commit, so it's easy to revert 9f6564b

Worth noting that I'm very much hand waving when writing JavaScript, and even more so when writing tests (asked ChatGPT to write one based on test cases).

P.S. this seems to add an additional call to /user-data, and I couldn't figure out a way to avoid that (e.g. by using getUserData, which got me lost in Redux concepts).


async function isAuthenticated(): Promise<boolean> {
if (!userDataPromise) {
userDataPromise = fetchUserData();
Copy link
Member

Choose a reason for hiding this comment

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

Re-fetching user data for logging like this is not the right solution; the info is available at least via useAppSelector((state) => state[USER].isAuthenticated). Accesssing that might require renaming some functions to be hooks, or to pass the data along in arguments.

@flodolo
Copy link
Collaborator Author

flodolo commented Feb 7, 2026

I think I'm in React/Redux hell. I tried moving the authentication state as a parameter of the existing function, but that required adding it to all props, update calls, tests, etc.

This is how far I manage to go. It works, I'm not sure how correct it is in terms of model (e.g. separation).

});
}
}, []);
}, [user.isAuthenticated, unread, log]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same here: is this unnecessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Again, trying to wrap my head about React, and failing 😵‍💫

I think this was OK before, because the log was sent once at startup (could we potentially log the wrong number of unread notifications though?). But now it depends on authentication status.

The "multiple notifications" was caused by the log changing each render, so the solution is stabilize that across re-renders?

@flodolo
Copy link
Collaborator Author

flodolo commented Feb 8, 2026

I seem to have introduced a bug for "unread notifications", where this action is sent multiple times.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forbidden: /log-ux-action/ errors in logs

4 participants