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

🐛 Bug Report: Double-Nested Data in User Preferences account.updatePrefs #221

Open
2 tasks done
olerhan opened this issue Oct 12, 2024 · 1 comment
Open
2 tasks done
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@olerhan
Copy link

olerhan commented Oct 12, 2024

👟 Reproduction steps

Running the following code in a Flutter project:

prefs = {"data": {"name" : "Erhan"}};
User prefsUpdatedUser = await account.updatePrefs(
  prefs: prefs,
);

Running the code to update user preferences.

👍 Expected behavior

The user preferences should be:
prefsUpdatedUser.prefs => {"data": {"name" : "Erhan"}}

👎 Actual Behavior

Instead, the actual preferences returned are:
prefsUpdatedUser.prefs => {"data": {"data": {"name" : "Erhan"}}}

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

MacOS

🧱 Your Environment

I'm working on a Flutter project using Visual Studio Code with appwrite: ^13.0.0.
The issue can be easily resolved by sending the correct format of prefs. However, it creates confusion when working according to the references provided, which is why I believe this is a bug and wanted to report it:
https://appwrite.io/docs/references/cloud/models/user
https://appwrite.io/docs/references/1.6.x/models/preferences

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@olerhan olerhan added the bug Something isn't working label Oct 12, 2024
@olerhan olerhan changed the title 🐛 Bug Report: 🐛 Bug Report: Double-Nested Data in User Preferences account.updatePrefs Oct 12, 2024
@stnguyen90
Copy link
Contributor

stnguyen90 commented Nov 1, 2024

Instead, the actual preferences returned are:
prefsUpdatedUser.prefs => {"data": {"data": {"name" : "Erhan"}}}

How exactly are you printing that data?

This looks expected to me because account.updatePrefs() returns a User and User has a prefs property that is a Preferences object and Preferences has a Map<string, dynamic> data property.

Part of the reason why there's this data property is because Dart is statically typed so we have to nest the dynamic data in the data property.

@stnguyen90 stnguyen90 transferred this issue from appwrite/appwrite Nov 1, 2024
@stnguyen90 stnguyen90 self-assigned this Nov 1, 2024
@stnguyen90 stnguyen90 added the question Further information is requested label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants