Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit b61e04f

Browse files
authored
Merge pull request #2904 from wordpress-mobile/fix/removeFontFamiliesFromStoredTheme
Removes font families from the stored block settings response
2 parents da7285c + cf398d5 commit b61e04f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

fluxc/src/main/java/org/wordpress/android/fluxc/model/EditorTheme.kt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ data class EditorTheme(
3939
blockEditorSettings.gradients,
4040
null,
4141
blockEditorSettings.styles?.toString(),
42-
blockEditorSettings.features?.toString(),
42+
blockEditorSettings.featuresFiltered?.toString(),
4343
blockEditorSettings.isBlockBasedTheme,
4444
blockEditorSettings.galleryWithImageBlocks,
4545
blockEditorSettings.quoteBlockV2,
@@ -83,7 +83,25 @@ data class BlockEditorSettings(
8383
@SerializedName("__experimentalFeatures") val features: JsonElement?,
8484
@JsonAdapter(EditorThemeElementListSerializer::class) val colors: List<EditorThemeElement>?,
8585
@JsonAdapter(EditorThemeElementListSerializer::class) val gradients: List<EditorThemeElement>?
86-
)
86+
) {
87+
val featuresFiltered: JsonElement?
88+
get() = features?.removeFontFamilies()
89+
90+
private fun JsonElement.removeFontFamilies(): JsonElement {
91+
if (isJsonObject && asJsonObject.has("typography")) {
92+
val featuresObject = asJsonObject
93+
val typography = featuresObject.get("typography")
94+
if (typography.isJsonObject) {
95+
val typographyObject = typography.asJsonObject
96+
if (typographyObject.has("fontFamilies")) {
97+
typographyObject.remove("fontFamilies")
98+
return featuresObject
99+
}
100+
}
101+
}
102+
return this
103+
}
104+
}
87105

88106
data class EditorThemeSupport(
89107
@JsonAdapter(EditorThemeElementListSerializer::class)

0 commit comments

Comments
 (0)