Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: User ID #25

Merged
merged 1 commit into from
Sep 10, 2024
Merged

Fix: User ID #25

merged 1 commit into from
Sep 10, 2024

Conversation

IeuanWalker
Copy link
Contributor

@IeuanWalker IeuanWalker commented Sep 9, 2024

Looks to be a possible bug with the MAUI preferences, before this PR we'd call the following code, to either get the saved user id or create/ save a new one -

Preferences.Get(userIdKey, GenerateNewAnonymousUserId());

But from testing, GenerateNewAnonymousUserId would always be called, even if one was already saved, which sets a new user ID -

public string GenerateNewAnonymousUserId()
{
    var userId = Guid.NewGuid().ToString();
    Preferences.Set(userIdKey, userId);

    return userId;
}

You can see what I mean in this screenshot -
(it first sets the user id to a custom value, it then gets the user ID, but it returns a new guide not the custom value)
image

To fix this I created a new method GetUserId() that gets the saved id, and then if its null, it will generate and save a new one.

Here is the updated version of the above screenshot -
image

@dhindrik dhindrik merged commit a7015f3 into dhindrik:main Sep 10, 2024
1 check passed
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.

2 participants