-
Notifications
You must be signed in to change notification settings - Fork 132
[Dynamic dashboard] Improve "has orders" logic #11469
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,11 @@ import org.greenrobot.eventbus.ThreadMode | |
import org.wordpress.android.fluxc.Dispatcher | ||
import org.wordpress.android.fluxc.action.AccountAction | ||
import org.wordpress.android.fluxc.generated.AccountActionBuilder | ||
import org.wordpress.android.fluxc.generated.WCOrderActionBuilder | ||
import org.wordpress.android.fluxc.model.SiteModel | ||
import org.wordpress.android.fluxc.store.AccountStore.AuthenticationErrorType | ||
import org.wordpress.android.fluxc.store.AccountStore.OnAccountChanged | ||
import org.wordpress.android.fluxc.store.AccountStore.OnAuthenticationChanged | ||
import org.wordpress.android.fluxc.store.AccountStore.UpdateTokenPayload | ||
import org.wordpress.android.fluxc.store.WCOrderStore.FetchOrderStatusOptionsPayload | ||
import org.wordpress.android.fluxc.store.WooCommerceStore | ||
import javax.inject.Inject | ||
|
||
|
@@ -82,11 +80,6 @@ class MainPresenter @Inject constructor( | |
override fun selectedSiteChanged(site: SiteModel) { | ||
productImageMap.reset() | ||
|
||
// Fetch a fresh list of order status options | ||
dispatcher.dispatch( | ||
WCOrderActionBuilder | ||
.newFetchOrderStatusOptionsAction(FetchOrderStatusOptionsPayload(site)) | ||
) | ||
Comment on lines
-85
to
-89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was moved to the |
||
coroutineScope.launch { clearCardReaderDataAction() } | ||
|
||
updateStatsWidgets() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.woocommerce.android.ui.onboarding | ||
|
||
import com.woocommerce.android.AppPrefsWrapper | ||
import com.woocommerce.android.WooException | ||
import com.woocommerce.android.extensions.isFreeTrial | ||
import com.woocommerce.android.tools.SelectedSite | ||
|
@@ -25,7 +26,8 @@ import javax.inject.Singleton | |
class StoreOnboardingRepository @Inject constructor( | ||
private val onboardingStore: OnboardingStore, | ||
private val selectedSite: SelectedSite, | ||
private val siteStore: SiteStore | ||
private val siteStore: SiteStore, | ||
private val appPrefs: AppPrefsWrapper | ||
) { | ||
private val onboardingTasksCacheFlow: MutableSharedFlow<OnboardingTasksEvent> = MutableSharedFlow(replay = 1) | ||
val hasCachedTasks | ||
|
@@ -60,6 +62,13 @@ class StoreOnboardingRepository @Inject constructor( | |
?.sortedBy { it.isComplete } | ||
?: emptyList() | ||
|
||
// Update onboarding completed status based on the tasks completion status | ||
if (mobileSupportedTasks.all { it.isComplete }) { | ||
appPrefs.updateOnboardingCompletedStatus(selectedSite.getSelectedSiteId(), true) | ||
} else if (appPrefs.isOnboardingCompleted(selectedSite.getSelectedSiteId())) { | ||
appPrefs.updateOnboardingCompletedStatus(selectedSite.getSelectedSiteId(), false) | ||
} | ||
Comment on lines
+65
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this logic here instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! I saw this as well on my site and planned to look into it. |
||
|
||
onboardingTasksCacheFlow.emit(OnboardingTasksEvent(selectedSite.get().id, mobileSupportedTasks)) | ||
Result.success(Unit) | ||
} | ||
|
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.
The change to use
coroutineScope
withlaunch
builders is to allow parallel requests.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.
Clever!