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

Handle the nullable ThemeModel.demoUrl #10356

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.wordpress.android.fluxc.model.ThemeModel
data class Theme(
val id: String,
val name: String,
val demoUrl: String
val demoUrl: String?
)

fun ThemeModel.toAppModel(): Theme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,26 @@ class ThemePickerViewModel @Inject constructor(
onSuccess = { result ->
_viewState.update {
Success(
carouselItems = result.map { theme ->
CarouselItem.Theme(
themeId = theme.id,
name = theme.name,
screenshotUrl = AppUrls.getScreenshotUrl(theme.demoUrl),
demoUri = theme.demoUrl
)
}.plus(
CarouselItem.Message(
title = resourceProvider.getString(
string.theme_picker_carousel_info_item_title
),
description = resourceProvider.getString(
string.theme_picker_carousel_info_item_description
carouselItems = result
.filter { theme -> theme.demoUrl != null }
.map { theme ->
CarouselItem.Theme(
themeId = theme.id,
name = theme.name,
screenshotUrl = AppUrls.getScreenshotUrl(theme.demoUrl!!),
demoUri = theme.demoUrl
)
}
.plus(
CarouselItem.Message(
title = resourceProvider.getString(
string.theme_picker_carousel_info_item_title
),
description = resourceProvider.getString(
string.theme_picker_carousel_info_item_description
)
)
)
)
)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ThemePreviewViewModel @Inject constructor(

private suspend fun Theme.prepareThemeDemoPages(): Flow<List<ThemeDemoPage>> = flow {
val homePage = ThemeDemoPage(
uri = demoUrl,
uri = requireNotNull(demoUrl),
title = resourceProvider.getString(R.string.theme_preview_bottom_sheet_home_section),
isLoaded = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.wordpress.android.fluxc.store.ThemeStore.SiteThemePayload
import org.wordpress.android.fluxc.store.ThemeStore.ThemeErrorType
import javax.inject.Inject

@Suppress("DEPRECATION")
class ThemeRepository @Inject constructor(
private val themeStore: ThemeStore,
private val dispatcher: Dispatcher,
Expand Down Expand Up @@ -108,6 +109,8 @@ class ThemeRepository @Inject constructor(
private suspend fun installThemeIfNeeded(themeId: String): Result<Unit> {
val installationResult: OnThemeInstalled = dispatcher.dispatchAndAwait(
ThemeActionBuilder.newInstallThemeAction(
// The Default constructor ThemeModel() is deprecated.
// We should add a new method to ThemeStore install a theme by themeId
SiteThemePayload(selectedSite.get(), ThemeModel().apply { this.themeId = themeId })
)
)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ tasks.register("installGitHooks", Copy) {
}

ext {
fluxCVersion = 'trunk-2f304118ff4776274b83f6e34c66180cdc16eb40'
fluxCVersion = 'trunk-3f65981193242842166b7428f409fd2d290076ac'
glideVersion = '4.13.2'
coilVersion = '2.1.0'
constraintLayoutVersion = '1.2.0'
Expand Down
Loading