Skip to content

Commit 0257ee2

Browse files
authored
Merge pull request #15086 from woocommerce/hack-modularize-selected-site
[HACK week] Modularization of SelectedSite
2 parents 89a38f5 + 06d96f4 commit 0257ee2

File tree

13 files changed

+64
-14
lines changed

13 files changed

+64
-14
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [*][Woo POS] Automatically scroll to newly created orders when returning to the Orders screen [https://github.com/woocommerce/woocommerce-android/pull/14990]
3636
- [Internal] Restore coupon drawable files mistakenly removed in previous release [https://github.com/woocommerce/woocommerce-android/pull/15005]
3737
- [*] Fixed a rare crash that occurred when displaying shipping rates for a selected package [https://github.com/woocommerce/woocommerce-android/pull/15032]
38+
- [*][Woo POS] Prepopulate orders cache after opening POS to improve performance [https://github.com/woocommerce/woocommerce-android/pull/15066]
3839
- [*] [WEAR] Resolved title clipping on round screens for Wear [https://github.com/woocommerce/woocommerce-android/pull/15108]
3940

4041
23.7

WooCommerce/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ dependencies {
266266

267267
implementation(project(":libs:fluxc"))
268268
implementation(project(":libs:fluxc-plugin"))
269+
269270
implementation(project(":libs:login"))
270271
implementation(project(":libs:pos"))
271272

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.woocommerce.android.di
2+
3+
import androidx.datastore.core.DataStore
4+
import com.woocommerce.android.ui.mystore.data.DashboardDataModel
5+
import dagger.hilt.EntryPoint
6+
import dagger.hilt.InstallIn
7+
import kotlinx.coroutines.CoroutineScope
8+
9+
@InstallIn(SiteComponent::class)
10+
@EntryPoint
11+
interface SiteComponentEntryPoint {
12+
fun dashboardDataStore(): DataStore<DashboardDataModel>
13+
14+
@SiteCoroutineScope
15+
fun siteCoroutineScope(): CoroutineScope
16+
}

libs/commons/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
plugins {
22
alias(libs.plugins.android.library)
33
alias(libs.plugins.kotlin.android)
4+
alias(libs.plugins.kotlin.compose)
45
alias(libs.plugins.kotlin.parcelize)
6+
alias(libs.plugins.ksp)
7+
alias(libs.plugins.google.dagger.hilt)
58
alias(libs.plugins.dependency.analysis)
69
}
710

@@ -19,17 +22,41 @@ android {
1922
targetCompatibility = libs.versions.java.get()
2023
}
2124

25+
buildFeatures {
26+
buildConfig = true
27+
compose = true
28+
}
29+
30+
lintOptions {
31+
// Workaround for kotlinx-metadata version incompatibility:
32+
// Kotlin 2.2.21 generates metadata v2.2.0, but AGP 8.13.2's Compose lint detector
33+
// only supports up to v2.0.0, causing crashes when analyzing Kotlin files.
34+
// This can be removed when AGP updates its bundled kotlinx-metadata-jvm dependency.
35+
disable "StateFlowValueCalledInComposition"
36+
37+
baseline file("lint-baseline.xml")
38+
}
39+
2240
testFixtures.enable = true
2341
}
2442

2543
dependencies {
2644
implementation(libs.androidx.annotation)
45+
implementation(libs.androidx.core.ktx)
46+
implementation(libs.androidx.compose.ui.main)
2747
implementation(libs.glassfish.javax.annotation)
2848
implementation(libs.kotlinx.coroutines.core)
2949
implementation(libs.automattic.tracks.crashlogging)
3050
implementation(libs.androidx.lifecycle.process)
51+
implementation(libs.androidx.preference.ktx)
52+
implementation(libs.eventbus.android)
3153
implementation(libs.google.dagger.hilt.android.main)
3254
implementation(libs.wordpress.utils)
55+
implementation(libs.apache.commons.text)
56+
implementation(project(":libs:fluxc"))
57+
implementation(project(":libs:fluxc-plugin"))
58+
59+
ksp(libs.google.dagger.hilt.compiler)
3360

3461
testImplementation(libs.kotlinx.coroutines.test)
3562
testImplementation(libs.assertj.core)
@@ -38,6 +65,7 @@ dependencies {
3865
testImplementation(libs.androidx.arch.core.testing)
3966
testImplementation(libs.androidx.lifecycle.runtime.testing)
4067

68+
testFixturesImplementation(libs.androidx.compose.ui.main)
4169
testFixturesCompileOnly(libs.kotlinx.coroutines.test)
4270
testFixturesCompileOnly(libs.junit)
4371
testFixturesCompileOnly(libs.mockito.kotlin)

libs/commons/lint-baseline.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<issues format="6" by="lint 8.7.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.2)" variant="all" version="8.7.2">
3+
4+
<issue
5+
id="StateFlowValueCalledInComposition"
6+
message="Calling value on a StateFlow inside of a composable function will not observe changes to the StateFlow"
7+
errorLine1=" state.value?.let { return it }"
8+
errorLine2=" ~~~~~">
9+
<location
10+
file="src/main/java/com/woocommerce/android/tools/SelectedSite.kt"
11+
line="64"
12+
column="15"/>
13+
</issue>
14+
15+
</issues>

WooCommerce/src/main/kotlin/com/woocommerce/android/di/SiteComponent.kt renamed to libs/commons/src/main/java/com/woocommerce/android/di/SiteComponent.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package com.woocommerce.android.di
22

3-
import androidx.datastore.core.DataStore
4-
import com.woocommerce.android.ui.mystore.data.DashboardDataModel
53
import dagger.BindsInstance
64
import dagger.hilt.DefineComponent
7-
import dagger.hilt.EntryPoint
8-
import dagger.hilt.InstallIn
95
import dagger.hilt.components.SingletonComponent
106
import kotlinx.coroutines.CoroutineScope
117
import org.wordpress.android.fluxc.model.SiteModel
@@ -29,15 +25,6 @@ interface SiteComponent {
2925
}
3026
}
3127

32-
@InstallIn(SiteComponent::class)
33-
@EntryPoint
34-
interface SiteComponentEntryPoint {
35-
fun dashboardDataStore(): DataStore<DashboardDataModel>
36-
37-
@SiteCoroutineScope
38-
fun siteCoroutineScope(): CoroutineScope
39-
}
40-
4128
@Qualifier
4229
@MustBeDocumented
4330
@Retention(RUNTIME)

WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/NumberExt.kt renamed to libs/commons/src/main/java/com/woocommerce/android/extensions/NumberExt.kt

File renamed without changes.

WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringExt.kt renamed to libs/commons/src/main/java/com/woocommerce/android/extensions/StringExt.kt

File renamed without changes.

WooCommerce/src/main/kotlin/com/woocommerce/android/tools/SelectedSite.kt renamed to libs/commons/src/main/java/com/woocommerce/android/tools/SelectedSite.kt

File renamed without changes.

WooCommerce/src/main/kotlin/com/woocommerce/android/tools/SiteConnectionType.kt renamed to libs/commons/src/main/java/com/woocommerce/android/tools/SiteConnectionType.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.woocommerce.android.tools
22

3-
import com.woocommerce.android.BuildConfig
43
import com.woocommerce.android.util.WooLog
4+
import com.woocommerce.commons.BuildConfig
55
import org.wordpress.android.fluxc.model.SiteModel
66

77
enum class SiteConnectionType {

0 commit comments

Comments
 (0)