Describe the bug
When deployed latest (4a077b562e705d0ed318e36c0c6366f210731ca9) fronted on new empty instance, and created a new user, the user is not visible on the management list at all after joining. After they change settings, they are there, but without email, display name, and with incorrect list of roles.
To Reproduce
Setup independent instance of Rowy
Invite user by email
Used signs in
User is not visible on members lists after signing in
User stop having it's profile picture visible after changing settings
Expected behavior
User is visible on members list with correct information after they sign in.
useSettingsDocs is being called, and on the first call, value of currentUser is always undefined, this causes in the call below to useFirestoreDocWithAtom to never initialize the fields in the database.
Later after user changes any settings, it's impossible for this code to execute again because createIfNonExistent won't be called, because something exists there already.
This is how the possible fix looks like: https://github.com/rowyio/rowy/commit/8d8686af5283e574853375ac013ca47cdb15ed51 The part I'm not sure there is the scary looking warning about "infinite re-render", but it doesn't work without that change (more race conditions and that's also why user roles list is not getting properly updates in the management list even though it's added there already) and with it there doesn't seem to be anything triggering this infinite re-render and comment doesn't explain because of what this infinite loop was happening.
Describe the bug When deployed latest (4a077b562e705d0ed318e36c0c6366f210731ca9) fronted on new empty instance, and created a new user, the user is not visible on the management list at all after joining. After they change settings, they are there, but without email, display name, and with incorrect list of roles.
To Reproduce
Expected behavior User is visible on members list with correct information after they sign in.
Additional context
I'm not familiar with the app or React really, but I think I've traced down the issue in the code, and it looks like the order of operation when initializing the React app is incorrect and this code: https://github.com/rowyio/rowy/blob/4a077b562e705d0ed318e36c0c6366f210731ca9/src/sources/ProjectSourceFirebase/useSettingsDocs.ts#L46-L51 is never executed, the
user
field in__rowy__/userManagement/users/${userid}/
is never being set, so the user is incorrectly or not at all visible on the members list etc.useSettingsDocs
is being called, and on the first call, value ofcurrentUser
is alwaysundefined
, this causes in the call below touseFirestoreDocWithAtom
to never initialize the fields in the database.Later after user changes any settings, it's impossible for this code to execute again because
createIfNonExistent
won't be called, because something exists there already.Possible solution
I'm not sure, but it looks to me that changing this invocation: https://github.com/rowyio/rowy/blob/4a077b562e705d0ed318e36c0c6366f210731ca9/src/sources/ProjectSourceFirebase/useAuthUser.ts#L47 to also fill in user details would be a better place to initialize this part of the document. This way, any updates to the user like profile picture or display name should also be properly picked up by the application.
This is how the possible fix looks like: https://github.com/rowyio/rowy/commit/8d8686af5283e574853375ac013ca47cdb15ed51 The part I'm not sure there is the scary looking warning about "infinite re-render", but it doesn't work without that change (more race conditions and that's also why user roles list is not getting properly updates in the management list even though it's added there already) and with it there doesn't seem to be anything triggering this infinite re-render and comment doesn't explain because of what this infinite loop was happening.