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

Update: MySiteViewModel Architecture #19869

Merged
merged 264 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
264 commits
Select commit Hold shift + click to select a range
44b80ca
- Removes: redundant cards builder
AjeshRPai Dec 28, 2023
64ad3a0
↑ Updates: the logic in dashboard to use parallel coroutines
AjeshRPai Dec 29, 2023
6034e78
- Removes: Redundant Card builder class
AjeshRPai Dec 29, 2023
e871a4f
↑ [WIP] Updates: the AccountDataSource.kt to be a viewmodel slice
AjeshRPai Dec 29, 2023
b583ef9
↑ [WIP] Updates: the blaze viewmodel slice to fetch data for blaze card
AjeshRPai Dec 29, 2023
16fcef4
↑ [WIP] Updates: the domain registraction source to be VM Slice
AjeshRPai Dec 29, 2023
f4378e4
↑ [WIP] Updates: the DynamicCardsViewModelSlice to fix lint error
AjeshRPai Dec 29, 2023
6f42448
↑ [WIP] Updates: DynamicCardsViewModelSlice to use ui live data
AjeshRPai Dec 29, 2023
339746c
↑ [WIP] Updates: the CardSource with card fetching and building logic
AjeshRPai Dec 29, 2023
d57ec2f
↑ [WIP] Updates: the BloggingPromptCardViewModelSlice to add card logic
AjeshRPai Dec 30, 2023
8832e56
↑ [WIP] Updates: the PersonalizeCardViewModelSlice to build card
AjeshRPai Dec 30, 2023
73846cc
↑ [WIP] Updates: QuickStartCardSource.kt to QuickStartCardVewModelSlice
AjeshRPai Dec 30, 2023
87def84
↑ [WIP] Updates: SiteInfoHeaderViewModelSlice to build card
AjeshRPai Dec 30, 2023
2bf6fcb
+ Adds: the logic to merge more than 6 live data
AjeshRPai Dec 31, 2023
7152ff8
+ Adds: VM slice for jp migration success card
AjeshRPai Dec 31, 2023
8237cc5
* Renames: the JetpackInstallFullPluginCardBuilder.kt to VMSlice
AjeshRPai Dec 31, 2023
a000ce8
↑ Updates: the BloganuaryNudgeCardViewModelSlice to use livedata for …
AjeshRPai Dec 31, 2023
5bf829f
↑ Updates: BloggingPromptCardViewModelSlice to use refresh live data
AjeshRPai Dec 31, 2023
feaade2
↑ Updates: the viewmodel slice to use live data for card
AjeshRPai Dec 31, 2023
0c771aa
↑ Updates: QuickLinksItemViewModelSlice to use state from quickstart
AjeshRPai Dec 31, 2023
36d7e6e
* Fixes: the lint formatting
AjeshRPai Dec 31, 2023
08a66a6
↑ Updates: the CardViewModelSlice to use public functions
AjeshRPai Dec 31, 2023
acb412a
↑ Updates: VM slice to use type alias for ui model
AjeshRPai Dec 31, 2023
8082518
[WIP] ↑ Updates: the unused parameter to use underscore
AjeshRPai Dec 31, 2023
2d227a2
[WIP] ↑ Updates: the sitemodel to use site icon progress
AjeshRPai Dec 31, 2023
a4f6fa4
+ Adds: DashboardCardsViewModelSlice to cardviewmodel slice
AjeshRPai Dec 31, 2023
36b5723
[WIP] ↑ Updates: the unused parameter to use underscore
AjeshRPai Dec 31, 2023
3291b71
- Removes: the MySiteSourceManager.kt
AjeshRPai Dec 31, 2023
0d429af
[WIP] ↑ Updates: the logic to remove selected site repository check
AjeshRPai Jan 1, 2024
d4c2f4b
[WIP] ↑ Updates: the logic to remove null check and refresh
AjeshRPai Jan 1, 2024
dcebbd8
[WIP] ↑ Updates: the logic to remove selected site repository check
AjeshRPai Jan 1, 2024
9215c2c
[WIP] - Removes: duplicate functions and site null check
AjeshRPai Jan 1, 2024
a3b28d5
[WIP] ↑ Updates: the logic to build cards on resume and refresh
AjeshRPai Jan 1, 2024
15b0177
[WIP] - Removes: site null check
AjeshRPai Jan 1, 2024
d3eb4e2
↑ Updates: the BlazeCardViewModelSlice logic
AjeshRPai Jan 1, 2024
8dd618b
↑ Updates: the BloganuaryNudgeCardViewModelSlice logic
AjeshRPai Jan 1, 2024
05439a7
↑ Updates: the BloggingPromptCardViewModelSlice logic
AjeshRPai Jan 1, 2024
5306ba5
↑ Updates: the JetpackInstallFullPluginCardViewModelSlice logic
AjeshRPai Jan 1, 2024
0f6fe10
↑ Updates: JpMigrationSuccessCardViewModelSlice to use nullable livedata
AjeshRPai Jan 1, 2024
f0d8a3f
↑ Updates: the PlansCardViewModelSlice logic
AjeshRPai Jan 1, 2024
c8ee457
↑ Updates: the SiteInfoHeaderCardViewModelSlice logic
AjeshRPai Jan 1, 2024
69ce6e0
↑ Updates: the QuickLinksItemViewModelSlice logic
AjeshRPai Jan 1, 2024
e05b3e8
* Fixes: the loading loop in CardViewModelSlice
AjeshRPai Jan 1, 2024
8616096
↑ Updates: the DashboardCardsViewModelSlice logic
AjeshRPai Jan 1, 2024
7975de4
- Removes: Scan and Selected
AjeshRPai Jan 1, 2024
1ff57d5
- Removes: BlazeCardSource.kt
AjeshRPai Jan 1, 2024
52167e3
- Removes: the BloggingPromptCardSource.kt
AjeshRPai Jan 1, 2024
e17ce4d
* Fixes: the SiteInfoHeaderCard logic to show site icon
AjeshRPai Jan 1, 2024
58f416b
↑ Updates: the QuickStartCardVewModelSlice
AjeshRPai Jan 1, 2024
0c3aafd
+ Adds: quick start card to DashboardCardsViewModelSlice
AjeshRPai Jan 1, 2024
e8d24f8
↑ Updates: the SelectedSiteRepository to format the variables
AjeshRPai Jan 1, 2024
3e77786
- Removes: the MySiteSource and Test class
AjeshRPai Jan 1, 2024
d547b63
* Fixes: refresh indicator on fetching data
AjeshRPai Jan 1, 2024
77e9e6b
+ Adds: the scope variables to the DashboardCardsViewModelSlice
AjeshRPai Jan 1, 2024
61ff274
- Removes: Refresh indicator code
AjeshRPai Jan 1, 2024
280b39a
[WIP] Removes and comments out redundant code
AjeshRPai Jan 1, 2024
442c6b2
* Fixes: dependency mismatch on BloggingPromptCardViewModelSliceTest
AjeshRPai Jan 1, 2024
e20ab72
+ Adds: JetpackFeatureCardViewModelSlice for jetpack feature card
AjeshRPai Jan 2, 2024
a7ea3bf
+ Adds: JetpackSwitchMenuViewModelSlice for building jetpack switch menu
AjeshRPai Jan 2, 2024
c9d6fc1
- Removes: redundant line space
AjeshRPai Jan 2, 2024
dec8e2c
+ Adds: JetpackBadgeViewModelSlice for building jetpack badge
AjeshRPai Jan 2, 2024
ba57590
↑ Updates: the logic for readability
AjeshRPai Jan 2, 2024
b9b2f39
+ Adds: the logic for building site items in SiteItemsViewModelSlice
AjeshRPai Jan 2, 2024
3d673f7
↑ Updates: the logic in WpSotw2023NudgeCardViewModelSlice
AjeshRPai Jan 2, 2024
19efbcf
↑ Updates: the ui model to be nullable
AjeshRPai Jan 2, 2024
e84d4c4
↑ Updates: JetpackBadgeViewModelSlice
AjeshRPai Jan 2, 2024
1e06831
↑ Updates: JetpackFeatureCardViewModelSlice
AjeshRPai Jan 2, 2024
c0d346b
↑ Updates: the build function to be suspend function
AjeshRPai Jan 2, 2024
d5a884b
+ Adds: DashboardItemsViewModelSlice to build the site items
AjeshRPai Jan 2, 2024
142bb7b
- Removes: update MySiteViewModel to use DashboardItemsViewModelSlice
AjeshRPai Jan 2, 2024
45016ab
↑ Updates: the DashboardItemsViewModelSlice.kt to add card build logic
AjeshRPai Jan 2, 2024
9afb395
+ Adds: the logic to check if the dashboard cards should be built or not
AjeshRPai Jan 2, 2024
4761e16
↑ Updates: the live data's in VM slices to use distinct untill changed
AjeshRPai Jan 3, 2024
2075e5f
Updates: live data to use distinct untill changed
AjeshRPai Jan 3, 2024
24f5152
↑ Updates: the VM slice to emit empty list if items not built
AjeshRPai Jan 3, 2024
c24ea63
+ Adds: the logic to build site items on onResume
AjeshRPai Jan 3, 2024
f8354a1
+ Adds: the logic of building card in AccountDataViewModelSlice
AjeshRPai Jan 4, 2024
df58331
+ Adds: AccountDataViewModel Slice logic to MySiteViewModel
AjeshRPai Jan 4, 2024
0dd2eab
↑ Updates: the logic of showing avatar details in empty view
AjeshRPai Jan 4, 2024
a0a26e1
+ Adds: the logic of refreshing DashboardItemsViewModelSlice
AjeshRPai Jan 4, 2024
b9edebc
+ Adds: the logic of refreshing DashboardItemsViewModelSlice
AjeshRPai Jan 4, 2024
63db7b6
+ Adds: the logic of refreshing site items on swipe to refresh
AjeshRPai Jan 4, 2024
053ab72
↑ Updates: the logic in AccountDataViewModelSlice for readability
AjeshRPai Jan 4, 2024
7fdebe4
- Removes: the redundant check for display size
AjeshRPai Jan 4, 2024
f3b1d3e
* Renames: AccountDataSourceTest.kt to AccountDataViewModelSliceTest
AjeshRPai Jan 4, 2024
2830bac
↑ Updates: the logic of unit tests
AjeshRPai Jan 5, 2024
8fc10b3
- Removes: ScanAndBackupSourceTest.kt class
AjeshRPai Jan 5, 2024
fd25fcb
- Removes: redundant source tests
AjeshRPai Jan 9, 2024
3395ec1
- Updates: BloggingPromptCardSourceTest naming to viewmodel slice
AjeshRPai Jan 9, 2024
f619e69
- Reverts: Local env changes
AjeshRPai Jan 9, 2024
632d299
- Reverts: Local env changes
AjeshRPai Jan 9, 2024
db3f9bc
Add and update unit tests. Mark methods private as needed.
zwarm Jan 9, 2024
58cb463
Refactor: rename unit test class to match implemented class
zwarm Jan 9, 2024
c59949c
Fix failing unit tests. Use annotation @VisibleForTesting on the buil…
zwarm Jan 10, 2024
642d2e5
Fix failing unit tests. Use annotation @VisibleForTesting on the buil…
zwarm Jan 10, 2024
4697d19
Fix failing unit tests. Use annotation @VisibleForTesting on the buil…
zwarm Jan 10, 2024
955ddba
Merge branch 'moves_account_data_to_viewmodel_slice' into move-site-m…
AjeshRPai Jan 11, 2024
b47e2c3
↑ Updates: the AccountDataViewModelSliceTest
AjeshRPai Jan 11, 2024
4d5c79b
↑ Updates: SiteInfoHeaderCardViewModelSliceTest to add ignore annotation
AjeshRPai Jan 11, 2024
cb90f2d
- Removes: Redundant CardBuilder.kt class
AjeshRPai Jan 11, 2024
e94c724
- Removes: Redundant imports and unused dependancy
AjeshRPai Jan 11, 2024
c68bcfd
+ Adds: Ignore annotation to MySiteViewModelTest
AjeshRPai Jan 11, 2024
06fda16
+ Adds: Ignore annotation to DynamicCardsViewModelSliceTest
AjeshRPai Jan 11, 2024
cfa3b56
+ Adds: Ignore annotation to PagesCardViewModelSliceTest
AjeshRPai Jan 11, 2024
b314eca
+ Adds: Ignore annotation to TodaysStatsViewModelSliceTest
AjeshRPai Jan 11, 2024
d810755
+ Adds: Ignore annotation to PostsCardViewModelSliceTest
AjeshRPai Jan 11, 2024
1efcdc0
+ Adds: Ignore annotation to CardsViewModelSliceTest
AjeshRPai Jan 11, 2024
d45a926
↑ Updates: DomainRegistrationViewModelSlice to use public function
AjeshRPai Jan 11, 2024
14ddb38
+ Adds: ignore annotation to DomainRegistrationViewModelSliceTest
AjeshRPai Jan 11, 2024
f5ef75e
+ Adds: ignore annotation to WpSotw2023NudgeCardViewModelSliceTest
AjeshRPai Jan 11, 2024
fe2cdb5
+ Adds: ignore annotation to BloganuaryNudgeCardViewModelSliceTest
AjeshRPai Jan 11, 2024
56d2c46
+ Adds: the ignore annotation to the SiteItemsViewModelSliceTest
AjeshRPai Jan 11, 2024
269d8a0
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Jan 11, 2024
8aebe10
Fix failing unit tests to adhere to new architecture
zwarm Jan 11, 2024
3be53e0
Fix detekt long line
zwarm Jan 11, 2024
44a8129
Add unit tests for JetpackInstallFullPluginCardViewModelSlice
zwarm Jan 11, 2024
bdcb769
- Removes: deleted classess after merge
AjeshRPai Jan 11, 2024
f0fc640
Refactor existing unit tests and add new. Add DomainRegistrationTrack…
zwarm Jan 12, 2024
6ef5648
Add unit tests. Mark params as visibleForTesting so click methods can…
zwarm Jan 14, 2024
d1ed462
Refactor: remove * kotlin import and add individual classes
zwarm Jan 14, 2024
b286e15
Add unit tests for when card is built and not built
zwarm Jan 14, 2024
ce7a871
Fix: remove unused import
zwarm Jan 14, 2024
c68547b
Add unit tests for JpMigrationSuccessCardViewModelSlice
zwarm Jan 14, 2024
8be1489
Add the missing else branch for buildCard
zwarm Jan 14, 2024
4d84674
Fix the failing unit tests
zwarm Jan 14, 2024
8509c40
* Implements: changes to CardsViewModelSlice from this PR
AjeshRPai Jan 15, 2024
846f50e
- Removes: Ignore annotation as the tests are upto date
AjeshRPai Jan 15, 2024
544450a
- Removes: Ignore annotation as the tests are upto date
AjeshRPai Jan 15, 2024
c22fec0
- Removes: Ignore annotation from PostsCardViewModelSliceTest
AjeshRPai Jan 15, 2024
c9fbc00
* Fixes: SiteItemsViewModelSliceTest errors
AjeshRPai Jan 15, 2024
825d72b
* Fixes: CardViewModelSlice and adds tests
AjeshRPai Jan 15, 2024
2dcba91
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Jan 16, 2024
49cf480
* Fixes: AccountDataViewModelSliceTest
AjeshRPai Jan 16, 2024
8392608
+ Adds: the logic of showing no cards message
AjeshRPai Jan 18, 2024
0abe193
Updates: the naming of DomainRegistrationViewModelSlice.kt
AjeshRPai Jan 18, 2024
89a1cd6
+ Adds: the logic of the showing domain registration card
AjeshRPai Jan 18, 2024
9767ede
↑ Updates: the JetpackBadgeViewModelSlice and adds test
AjeshRPai Jan 18, 2024
08074a4
* Fixes: JetpackBadgeViewModelSlice and tests
AjeshRPai Jan 18, 2024
9f22dcc
Fix failing unit tests
zwarm Jan 18, 2024
157c0be
Add tests for verification of card build
zwarm Jan 18, 2024
cbc5973
* Fixes: Site icon upload not reflecting
AjeshRPai Jan 18, 2024
5387c56
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Jan 19, 2024
56b74dd
* Fixes: Typo in QuickStartCardViewModelSlice
AjeshRPai Jan 19, 2024
56f476e
→ Moves: SiteInfoHeaderCardViewModelSlice on Resume inside site check
AjeshRPai Jan 19, 2024
a1ae2be
+ Adds: Missing show quick start notice function
AjeshRPai Jan 19, 2024
674904c
+ Adds: logic to refresh the blogging prompt data
AjeshRPai Jan 20, 2024
f6fd8ca
Add tests for dashboardItemsViewModelSlice
zwarm Jan 21, 2024
fb2b9a4
Add tests for dashboardCardsViewModelSlice
zwarm Jan 21, 2024
ae70da2
- Removes: redundant ui model clear logic
AjeshRPai Jan 23, 2024
4199dc6
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Jan 24, 2024
bc2e73d
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Feb 5, 2024
c567d58
→ Moves: refresh data to outside the flow
AjeshRPai Feb 5, 2024
7635a43
↑ Updates: the implementation to pass the site model
AjeshRPai Feb 5, 2024
b66b9f0
↑ Updates: DashboardItemsViewModelSlice implementation to use site model
AjeshRPai Feb 5, 2024
770f9f8
- Removes: Selected site repository from DashboardItemsViewModelSlice
AjeshRPai Feb 5, 2024
31a3c11
* Fixes: Unit tests
AjeshRPai Feb 5, 2024
657682c
[WIP] : Fixes some of the unit tests in QuickStartCardViewModelSlice
AjeshRPai Feb 6, 2024
6d4d11c
↑ Updates: the on site picked logic in my site viewmodel
AjeshRPai Feb 6, 2024
c9850df
+ Adds: a clear value and should build card check
AjeshRPai Feb 6, 2024
e13919d
* Fixes: Blogging prompt card refresh logic
AjeshRPai Feb 7, 2024
beca431
* Updates: the clear and switch site logic
AjeshRPai Feb 7, 2024
6e1a955
* Fixes: the switch from one wp.com site to another wp.com
AjeshRPai Feb 7, 2024
40fc54f
* Fixes: Quick start card not shown after the site is created
AjeshRPai Feb 7, 2024
a433574
→ Moves: refresh logic to child VM Slices
AjeshRPai Feb 7, 2024
cfd2e73
→ Moves: coroutine calls to background thread and updates live data set
AjeshRPai Feb 8, 2024
de1e71c
→ Moves: coroutine calls to background thread
AjeshRPai Feb 8, 2024
dcbc4d7
* Fixes: Incorrect pull to refresh logic
AjeshRPai Feb 8, 2024
dc5d3b0
+ Adds: the logic to track and clear tracker on CardViewModelSlice
AjeshRPai Feb 8, 2024
b17fd0d
→ Moves: the logic to track JetpackInstallFullPluginCard
AjeshRPai Feb 8, 2024
f9f068a
→ Moves: the logic to track DomainRegistrationCard
AjeshRPai Feb 8, 2024
5eec174
→ Moves: the logic to track Personalize Card
AjeshRPai Feb 8, 2024
7d44ea2
→ Moves: the logic to track QuickStart Card
AjeshRPai Feb 8, 2024
4f7fc93
→ Moves: the logic to track NoCardsMessage
AjeshRPai Feb 8, 2024
c7abcfe
→ Moves: the logic to track PlansCard
AjeshRPai Feb 8, 2024
15a8e83
→ Moves: the logic to track cards to background
AjeshRPai Feb 8, 2024
7c4ede0
+ Adds: logic for tracking quick links
AjeshRPai Feb 8, 2024
275b8ee
+ Adds: a check for tracking job and cancellation
AjeshRPai Feb 8, 2024
0e74d16
<- Reverts: local env change
AjeshRPai Feb 8, 2024
31d68d7
+ Adds: the logic to track site items on self hosted site
AjeshRPai Feb 11, 2024
6229933
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Feb 13, 2024
cd836b4
↑ Updates: the logic of scroll position of quick start focus point
AjeshRPai Feb 29, 2024
7d4c91d
- Removes: redundant state code
AjeshRPai Feb 29, 2024
a35db4b
Merge remote-tracking branch 'origin/move-site-menu-items-to-viewmode…
AjeshRPai Mar 10, 2024
064a78d
↑ Updates: the blaze card fetch logic to include changes from PR
AjeshRPai Mar 10, 2024
1cb5205
- Remove: redundant variable
AjeshRPai Mar 10, 2024
36f9d7c
* Fix: warnings for paramters
AjeshRPai Mar 10, 2024
44885f1
- Remove: Redundant dependancy
AjeshRPai Mar 10, 2024
c2a9955
- Remove: Redundant file
AjeshRPai Mar 10, 2024
5768789
- Remove: Redundant code from MySiteViewModelTest
AjeshRPai Mar 10, 2024
1efe5b5
* Fixes: warnings and lit errors
AjeshRPai Mar 10, 2024
ebad1a9
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Mar 10, 2024
09a7edc
* Fixes: QuickStartCardViewModelSliceTest failure
AjeshRPai Mar 11, 2024
16e1238
* Fixes: null live data failure
AjeshRPai Mar 11, 2024
4b88992
* Fixes: detekt errors
AjeshRPai Mar 11, 2024
eadab98
* Fixes: test dependancies
AjeshRPai Mar 11, 2024
594d763
Fixes: ActivityLogCardViewModelSliceTest
AjeshRPai Mar 11, 2024
e576689
- Removes: BlazeCardSourceTest.kt
AjeshRPai Mar 11, 2024
a2c7a3b
* Fixes: TodaysStatsViewModelSliceTest
AjeshRPai Mar 11, 2024
168c7c8
* Fixes: PostsCardViewModelSliceTest
AjeshRPai Mar 11, 2024
c3c773c
* Fixes: unit tests in PersonalizeCardViewModelSliceTest
AjeshRPai Mar 11, 2024
f0e1c1c
* Fixes: unit tests in BlazeCardViewModelSliceTest
AjeshRPai Mar 11, 2024
0bde4e6
- Removes: Ignore message in BloganuaryNudgeCardViewModelSliceTest
AjeshRPai Mar 11, 2024
96824df
* Fixes: Check style issues
AjeshRPai Mar 11, 2024
96be2fa
[WIP] Fixes: CardsViewModelSliceTest
AjeshRPai Mar 11, 2024
5a5f054
Fixes: CardsViewModelSliceTest
AjeshRPai Mar 12, 2024
9a728de
+ Adds: clear value function to DomainRegistrationCardViewModelSlice
AjeshRPai Mar 12, 2024
f928fab
+ Adds: clear value test to DashboardCardsViewModelSlice
AjeshRPai Mar 12, 2024
b605fb4
* Fixes: DashboardItemsViewModelSlice and adds tests
AjeshRPai Mar 12, 2024
a8af01a
* Fixes: SiteItemsViewModelSliceTest
AjeshRPai Mar 13, 2024
429d1e1
- Removes: Unused builder params
AjeshRPai Mar 13, 2024
2ff9d2c
* Ignores: some of the tests in QuickStartCardViewModelSliceTest
AjeshRPai Mar 13, 2024
1f0fb0b
* Fixes: Lint errors
AjeshRPai Mar 13, 2024
3bc90a2
↑ Updates: the tracking logic in BloggingPromptsCardTrackHelper
AjeshRPai Mar 13, 2024
d7df40a
- Removes: the redundant tests in MySiteViewModelTest
AjeshRPai Mar 13, 2024
211fd16
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Mar 13, 2024
502249a
+ Adds: a debounce delay to fix the tracking
AjeshRPai Mar 13, 2024
fbf9362
[WIP] Fixes: Unnecessary stubbings and removes redundant tests
AjeshRPai Mar 13, 2024
02192d8
+ Adds: OnCleared to the SiteInfoHeaderCardViewModelSlice
AjeshRPai Mar 13, 2024
42ec262
[WIP] Updates: the MySiteViewModelTest
AjeshRPai Mar 13, 2024
b7e9d2d
[WIP] + Adds: tests for MySiteViewModel
AjeshRPai Mar 13, 2024
2bf875b
+ Adds: Tests for refresh scenario in MySiteViewModel
AjeshRPai Mar 13, 2024
9b19236
+ Adds: tests for MySiteViewModel on Resume scenario
AjeshRPai Mar 13, 2024
96ccf63
+ Adds: test for JetpackSwitchMenuViewModelSlice
AjeshRPai Mar 13, 2024
b45d38b
+ Adds: test for JetpackFeatureCardViewModelSlice
AjeshRPai Mar 13, 2024
7757259
* Fixes: detekt issue
AjeshRPai Mar 13, 2024
4f236d6
Fixes: Site icon refresh issue
pantstamp Mar 14, 2024
ff5c0c8
* Fixes: the position of migration success card
AjeshRPai Mar 14, 2024
d08c975
Merge branch 'trunk' into move-site-menu-items-to-viewmodel-slice
AjeshRPai Mar 14, 2024
45384e3
Merge pull request #20460 from wordpress-mobile/pantelis/mysiteviewmo…
pantstamp Mar 14, 2024
20329d7
* Fixes: the order of the dashboard cards
AjeshRPai Mar 18, 2024
7f58150
* Fixes: Jetpack switch menu shown on jetpack app
AjeshRPai Mar 18, 2024
fd87dca
* Fixes: Refreshing indicator shown in site items
AjeshRPai Mar 18, 2024
3cbea9f
Reverts: Local env changes
AjeshRPai Mar 18, 2024
16fa6dd
* Fixes: Blogging prompt card not shown
AjeshRPai Mar 18, 2024
65926a3
↑ Updates: the blogging prompt card feature check
AjeshRPai Mar 18, 2024
2635563
* Fixes: DomainRegistrationCard not being shown
AjeshRPai Mar 18, 2024
8f53226
* Fixes: Register domain card not shown
AjeshRPai Mar 18, 2024
79ffbb9
Moves: the order of the blaze card to the top of plans card
AjeshRPai Mar 18, 2024
14fda30
- Removes: unused parameter
AjeshRPai Mar 18, 2024
1a797a0
* Fixes: BloggingPromptCardViewModelSliceTest
AjeshRPai Mar 18, 2024
f4235e3
Fixes: site menu icon colour
pantstamp Mar 19, 2024
dd0f35f
Separates the dynamic cards so that they could be displayed at the to…
Mar 20, 2024
81090f6
↑ Updates: the check for whether the ui model is empty
AjeshRPai Mar 21, 2024
daa26aa
* Fixes: the order of the cards in viewmodel
AjeshRPai Mar 21, 2024
537ad6d
Merge pull request #20512 from wordpress-mobile/move-site-menu-items-…
Mar 21, 2024
3f43efa
* Fixes: the visibility of refresh function
AjeshRPai Mar 22, 2024
23f9e5a
* Fixes: the visibility of build function
AjeshRPai Mar 22, 2024
b73b46d
↑ Updates: the naming of the function
AjeshRPai Mar 22, 2024
8120e49
Merge remote-tracking branch 'origin/move-site-menu-items-to-viewmode…
AjeshRPai Mar 22, 2024
cbee896
- Removes: Redundant JetpackInstallFullPluginCardBuilderParams
AjeshRPai Mar 25, 2024
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.wordpress.android.ui.mysite

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import org.wordpress.android.fluxc.store.AccountStore
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper
import org.wordpress.android.ui.mysite.MySiteUiState.PartialState.AccountData
import org.wordpress.android.util.BuildConfigWrapper
import javax.inject.Inject

class AccountDataViewModelSlice @Inject constructor(
private val accountStore: AccountStore,
private val buildConfigWrapper: BuildConfigWrapper,
private val jetpackFeatureRemovalPhaseHelper: JetpackFeatureRemovalPhaseHelper
) {
private lateinit var scope: CoroutineScope

private val _isRefreshing = MutableLiveData<Boolean>()
val isRefreshing: LiveData<Boolean> = _isRefreshing

private val _uiModel = MutableLiveData<AccountData?>()
val uiModel: LiveData<AccountData?> = _uiModel

fun initialize(scope: CoroutineScope) {
this.scope = scope
}

fun onResume() {
scope.launch {
if(!shouldBuildCard()) _uiModel.postValue(null)
_isRefreshing.postValue(true)
val account = accountStore.account
account?.let {
val url = account.avatarUrl.orEmpty()
val name =account.displayName?.ifEmpty {
account.userName.orEmpty()
}.orEmpty()
_uiModel.postValue(AccountData(url, name))
}?: {
_uiModel.postValue(null)
}
_isRefreshing.postValue(false)
}
}

fun onRefresh() {
onResume()
}

fun onCleared() {
scope.cancel()
}

private fun shouldBuildCard(): Boolean {
return (!buildConfigWrapper.isJetpackApp
&& jetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures())
}
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,120 @@
package org.wordpress.android.ui.mysite

import androidx.annotation.VisibleForTesting
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.distinctUntilChanged
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.wordpress.android.Result
import org.wordpress.android.analytics.AnalyticsTracker
import org.wordpress.android.fluxc.model.SiteModel
import org.wordpress.android.fluxc.model.blaze.BlazeCampaignModel
import org.wordpress.android.modules.BG_THREAD
import org.wordpress.android.ui.blaze.BlazeFeatureUtils
import org.wordpress.android.ui.blaze.BlazeFlowSource
import org.wordpress.android.ui.blaze.blazecampaigns.campaigndetail.CampaignDetailPageSource
import org.wordpress.android.ui.blaze.blazecampaigns.campaignlisting.CampaignListingPageSource
import org.wordpress.android.ui.blaze.blazecampaigns.campaignlisting.FetchCampaignListUseCase
import org.wordpress.android.ui.mysite.MySiteCardAndItemBuilderParams.BlazeCardBuilderParams
import org.wordpress.android.ui.mysite.MySiteCardAndItemBuilderParams.BlazeCardBuilderParams.CampaignWithBlazeCardBuilderParams
import org.wordpress.android.ui.mysite.MySiteCardAndItemBuilderParams.BlazeCardBuilderParams.PromoteWithBlazeCardBuilderParams
import org.wordpress.android.ui.mysite.MySiteUiState.PartialState.BlazeCardUpdate
import org.wordpress.android.ui.mysite.cards.blaze.BlazeCardBuilder
import org.wordpress.android.ui.mysite.cards.blaze.MostRecentCampaignUseCase
import org.wordpress.android.ui.mysite.cards.dashboard.CardsTracker
import org.wordpress.android.util.NetworkUtilsWrapper
import org.wordpress.android.viewmodel.Event
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton

@Singleton
class BlazeCardViewModelSlice @Inject constructor(
@param:Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher,
private val blazeFeatureUtils: BlazeFeatureUtils,
private val selectedSiteRepository: SelectedSiteRepository,
private val cardsTracker: CardsTracker
private val cardsTracker: CardsTracker,
private val blazeCardBuilder: BlazeCardBuilder,
private val networkUtilsWrapper: NetworkUtilsWrapper,
private val fetchCampaignListUseCase: FetchCampaignListUseCase,
private val mostRecentCampaignUseCase: MostRecentCampaignUseCase,
) {
private lateinit var scope: CoroutineScope

private val _onNavigation = MutableLiveData<Event<SiteNavigationAction>>()
val onNavigation = _onNavigation

private val _refresh = MutableLiveData<Event<Boolean>>()
val refresh = _refresh
private val _isRefreshing = MutableLiveData<Boolean>()
val isRefreshing: LiveData<Boolean> = _isRefreshing

private val _uiModel = MutableLiveData<MySiteCardAndItem.Card.BlazeCard?>()
val uiModel = _uiModel.distinctUntilChanged()

fun initialize(scope: CoroutineScope) {
this.scope = scope
}

fun buildCard(site: SiteModel) {
_isRefreshing.postValue(true)
scope.launch(bgDispatcher){
if (blazeFeatureUtils.shouldShowBlazeCardEntryPoint(site)) {
if (blazeFeatureUtils.shouldShowBlazeCampaigns()) {
fetchCampaigns(site)
} else {
// show blaze promo card if campaign feature is not available
showPromoteWithBlazeCard()
}
} else {
postState(false)
}
}
}

private suspend fun fetchCampaigns(site: SiteModel) {
if (networkUtilsWrapper.isNetworkAvailable().not()) {
getMostRecentCampaignFromDb(site)
} else {
when (fetchCampaignListUseCase.execute(site = site, offset = 0)) {
is Result.Success -> getMostRecentCampaignFromDb(site)
// there are no campaigns or if there is an error , show blaze promo card
is Result.Failure -> showPromoteWithBlazeCard()
}
}
}

private suspend fun getMostRecentCampaignFromDb(site: SiteModel) {
when(val result = mostRecentCampaignUseCase.execute(site)) {
is Result.Success -> postState(true, campaign = result.value)
is Result.Failure -> showPromoteWithBlazeCard()
}
}

private fun showPromoteWithBlazeCard() {
postState(true)
}

fun getBlazeCardBuilderParams(blazeCardUpdate: BlazeCardUpdate?): BlazeCardBuilderParams? {
return blazeCardUpdate?.let {
if (it.blazeEligible) {
it.campaign?.let { campaign ->
private fun postState(isBlazeEligible: Boolean, campaign: BlazeCampaignModel? = null) {
_isRefreshing.postValue(false)
if(isBlazeEligible) {
buildBlazeCard(campaign)?.let {
_uiModel.postValue(it)
}
} else {
_uiModel.postValue(null)
}
}


private fun buildBlazeCard(campaign: BlazeCampaignModel? = null): MySiteCardAndItem.Card.BlazeCard? {
return getBlazeCardBuilderParams(campaign).let { blazeCardBuilder.build(it) }
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun getBlazeCardBuilderParams(campaign: BlazeCampaignModel? = null): BlazeCardBuilderParams {
return campaign?.let {
getCampaignWithBlazeCardBuilderParams(campaign)
} ?: getPromoteWithBlazeCardBuilderParams()
} else null
}
}

private fun getCampaignWithBlazeCardBuilderParams(campaign: BlazeCampaignModel) =
Expand Down Expand Up @@ -89,6 +168,7 @@ class BlazeCardViewModelSlice @Inject constructor(
)
}


private fun getPromoteWithBlazeCardBuilderParams() =
PromoteWithBlazeCardBuilderParams(
onClick = this::onPromoteWithBlazeCardClick,
Expand All @@ -99,7 +179,6 @@ class BlazeCardViewModelSlice @Inject constructor(
)
)


private fun onPromoteCardLearnMoreClick() {
cardsTracker.trackCardMoreMenuItemClicked(
CardsTracker.Type.PROMOTE_WITH_BLAZE.label,
Expand Down Expand Up @@ -138,7 +217,7 @@ class BlazeCardViewModelSlice @Inject constructor(
selectedSiteRepository.getSelectedSite()?.let {
blazeFeatureUtils.hideBlazeCard(it.siteId)
}
_refresh.value = Event(true)
_uiModel.postValue(null)
}

private fun onPromoteCardMoreMenuClick() {
Expand Down Expand Up @@ -170,6 +249,10 @@ class BlazeCardViewModelSlice @Inject constructor(
_onNavigation.value =
Event(SiteNavigationAction.OpenPromoteWithBlazeOverlay(source = BlazeFlowSource.DASHBOARD_CARD))
}

fun clearValue() {
_uiModel.postValue(null)
}
}

enum class CampaignCardMenuItem(val label: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.wordpress.android.modules.BG_THREAD
import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BloggingPromptCard
import org.wordpress.android.ui.mysite.cards.dashboard.bloggingprompts.BloggingPromptsCardAnalyticsTracker
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import javax.inject.Inject
import javax.inject.Named

Expand All @@ -26,30 +25,9 @@ class BloggingPromptsCardTrackHelper @Inject constructor(
) {
private var dashboardUpdateDebounceJob: Job? = null

private val latestPromptCardVisible = AtomicReference<Boolean?>(null)
private val waitingToTrack = AtomicBoolean(false)
private val currentSite = AtomicReference<Int?>(null)

private fun onDashboardRefreshed(state: MySiteViewModel.State.SiteSelected?) {
val bloggingPromptCards = state?.dashboardData
?.filterIsInstance<BloggingPromptCard>()
?: listOf()

latestPromptCardVisible.get()?.let { isPromptCardVisible ->
val attribution = bloggingPromptCards.firstOrNull()?.attribution
if (isPromptCardVisible) tracker.trackMySiteCardViewed(attribution)
waitingToTrack.set(false)
} ?: run {
waitingToTrack.set(true)
}
}


fun onDashboardCardsUpdated(scope: CoroutineScope, state: MySiteViewModel.State.SiteSelected?) {
val bloggingPromptCards = state?.dashboardData
?.filterIsInstance<BloggingPromptCard>()
?: listOf()
private val waitingToTrack = AtomicBoolean(true)

fun onDashboardCardsUpdated(scope: CoroutineScope, bloggingPromptCards: List<BloggingPromptCard>) {
// cancel any existing job (debouncing mechanism)
dashboardUpdateDebounceJob?.cancel()

Expand All @@ -58,8 +36,6 @@ class BloggingPromptsCardTrackHelper @Inject constructor(

// add a delay (debouncing mechanism)
delay(PROMPT_CARD_VISIBLE_DEBOUNCE)

latestPromptCardVisible.set(isVisible)
if (isVisible && waitingToTrack.getAndSet(false)) {
val attribution = bloggingPromptCards.firstOrNull()?.attribution
tracker.trackMySiteCardViewed(attribution)
Expand All @@ -72,15 +48,8 @@ class BloggingPromptsCardTrackHelper @Inject constructor(
}
}

fun onResume(state: MySiteViewModel.State.SiteSelected?) {
onDashboardRefreshed(state)
}

fun onSiteChanged(siteId: Int?, state: MySiteViewModel.State.SiteSelected?) {
if (currentSite.getAndSet(siteId) != siteId) {
latestPromptCardVisible.set(null)
onDashboardRefreshed(state)
}
fun onSiteChanged() {
waitingToTrack.set(true)
}

private val BloggingPromptCard.attribution: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import org.wordpress.android.ui.mysite.cards.nocards.NoCardsMessageViewHolder
import org.wordpress.android.ui.mysite.cards.personalize.PersonalizeCardViewHolder
import org.wordpress.android.ui.mysite.cards.quicklinksitem.QuickLinkRibbonViewHolder
import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartCardViewHolder
import org.wordpress.android.ui.mysite.cards.siteinfo.SiteInfoHeaderCardViewholder
import org.wordpress.android.ui.mysite.cards.siteinfo.SiteInfoHeaderCardViewHolder
import org.wordpress.android.ui.mysite.cards.sotw2023.WpSotw2023NudgeCardViewHolder
import org.wordpress.android.ui.mysite.items.categoryheader.MySiteCategoryItemEmptyViewHolder
import org.wordpress.android.ui.mysite.items.categoryheader.MySiteCategoryItemViewHolder
Expand All @@ -80,7 +80,7 @@ class MySiteAdapter(
@Suppress("ComplexMethod")
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MySiteCardAndItemViewHolder<*> {
return when (viewType) {
MySiteCardAndItem.Type.SITE_INFO_CARD.ordinal -> SiteInfoHeaderCardViewholder(parent, imageManager)
MySiteCardAndItem.Type.SITE_INFO_CARD.ordinal -> SiteInfoHeaderCardViewHolder(parent, imageManager)
MySiteCardAndItem.Type.QUICK_LINK_RIBBON.ordinal -> QuickLinkRibbonViewHolder(parent)
MySiteCardAndItem.Type.DOMAIN_REGISTRATION_CARD.ordinal -> DomainRegistrationViewHolder(parent)
MySiteCardAndItem.Type.QUICK_START_CARD.ordinal -> QuickStartCardViewHolder(parent, uiHelpers)
Expand Down Expand Up @@ -136,7 +136,7 @@ class MySiteAdapter(
@Suppress("ComplexMethod")
override fun onBindViewHolder(holder: MySiteCardAndItemViewHolder<*>, position: Int) {
when (holder) {
is SiteInfoHeaderCardViewholder -> holder.bind(getItem(position) as SiteInfoHeaderCard)
is SiteInfoHeaderCardViewHolder -> holder.bind(getItem(position) as SiteInfoHeaderCard)
is QuickLinkRibbonViewHolder -> holder.bind(getItem(position) as QuickLinksItem)
is DomainRegistrationViewHolder -> holder.bind(getItem(position) as DomainRegistrationCard)
is QuickStartCardViewHolder -> holder.bind(getItem(position) as QuickStartCard)
Expand Down
Loading
Loading