-
Notifications
You must be signed in to change notification settings - Fork 37
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
[Gutenberg] Adjust the fetching of custom colors #1620
Conversation
storedColors: List<EditorThemeElementBuilder>, | ||
storedGradients: List<EditorThemeElementBuilder> | ||
): EditorTheme { | ||
val colors = storedColors?.mapNotNull { it.toEditorThemeElement() } | ||
val gradients = storedGradients?.mapNotNull { it.toEditorThemeElement() } | ||
val colors = if (storedColors.count() > 0) storedColors.mapNotNull { it.toEditorThemeElement() } else null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should keep this optional and also keep the guard, as well as checking the count, since we don't yet know why WellSql is occasionally sending null or empty. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that would probably be the safer path. I’ll make that tweak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested, and everything is working as expected now. The only thing I'm wondering about is, do we have a risk of NPE dereferencing the values returned from WellSql? (i.e. I think storedColors
or storedGradients
can be null, since the inferred platform type is (MutableList<EditorThemeSqlUtils.EditorThemeElementBuilder!>..List<EditorThemeSqlUtils.EditorThemeElementBuilder!>?)
).
I looked a bit deeper into the WellSql source, but couldn't be sure. I didn't see any nullability annotations though. So what I mean is, maybe we need to keep storedColors
and storedGradients
optional?
Edit: Nevermind, I was looking at an older changeset 🤦♂️ .. not sure why it wasn't showing me the latest code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Chip! I tested via the steps described, works as expected. LGTM!
Fixes: wordpress-mobile/gutenberg-mobile#2432
WPAndroid PR: wordpress-mobile/WordPress-Android#12289
To Test:
Expect to see a log of colors and/or gradients
Expect to see a log of
[null]
for colors and gradients