11package  eu.darken.sdmse.main.ui.dashboard 
22
3- import  android.content.Context 
4- import  androidx.lifecycle.SavedStateHandle 
53import  androidx.lifecycle.asLiveData 
64import  dagger.hilt.android.lifecycle.HiltViewModel 
7- import  dagger.hilt.android.qualifiers.ApplicationContext 
85import  eu.darken.sdmse.App 
96import  eu.darken.sdmse.MainDirections 
107import  eu.darken.sdmse.analyzer.core.Analyzer 
@@ -39,7 +36,6 @@ import eu.darken.sdmse.common.flow.intervalFlow
3936import  eu.darken.sdmse.common.flow.replayingShare 
4037import  eu.darken.sdmse.common.flow.setupCommonEventHandlers 
4138import  eu.darken.sdmse.common.flow.throttleLatest 
42- import  eu.darken.sdmse.common.pkgs.PkgRepo 
4339import  eu.darken.sdmse.common.review.ReviewTool 
4440import  eu.darken.sdmse.common.rngString 
4541import  eu.darken.sdmse.common.uix.ViewModel3 
@@ -103,10 +99,8 @@ import kotlin.time.Duration.Companion.seconds
10399
104100@HiltViewModel
105101class  DashboardViewModel  @Inject constructor(
106-     @Suppress(" unused" private  val  handle :  SavedStateHandle ,
107102    dispatcherProvider :  DispatcherProvider ,
108103    private  val  areaManager :  DataAreaManager ,
109-     private  val  pkgRepo :  PkgRepo ,
110104    private  val  taskManager :  TaskManager ,
111105    private  val  setupManager :  SetupManager ,
112106    private  val  corpseFinder :  CorpseFinder ,
@@ -125,8 +119,7 @@ class DashboardViewModel @Inject constructor(
125119    private  val  motdRepo :  MotdRepo ,
126120    private  val  releaseManager :  ReleaseManager ,
127121    private  val  reviewTool :  ReviewTool ,
128-     private  val  statsRepo :  StatsRepo ,
129-     @ApplicationContext private  val  context :  Context ,
122+     statsRepo :  StatsRepo ,
130123) : ViewModel3(dispatcherProvider = dispatcherProvider) {
131124
132125    init  {
@@ -187,6 +180,8 @@ class DashboardViewModel @Inject constructor(
187180        .setupCommonEventHandlers(TAG ) { " upgradeInfo" 
188181        .replayingShare(vmScope)
189182
183+     private  val  easterEggTriggered =  MutableStateFlow (false )
184+ 
190185    private  val  titleCardItem =  combine(
191186        upgradeInfo,
192187        taskManager.state,
@@ -196,6 +191,7 @@ class DashboardViewModel @Inject constructor(
196191            webpageTool =  webpageTool,
197192            isWorking =  ! taskState.isIdle,
198193            onRibbonClicked =  { webpageTool.open(SdmSeLinks .ISSUES ) },
194+             onMascotTriggered =  { easterEggTriggered.value =  it }
199195        )
200196    }
201197
@@ -447,7 +443,7 @@ class DashboardViewModel @Inject constructor(
447443        )
448444    }
449445
450-     private  val  listItemsInternal :  Flow <List < DashboardAdapter . Item > > =  eu.darken.sdmse.common.flow.combine(
446+     private  val  listStateInternal :  Flow <ListState > =  eu.darken.sdmse.common.flow.combine(
451447        recorderModule.state,
452448        debugCardProvider.create(this ),
453449        titleCardItem,
@@ -465,6 +461,7 @@ class DashboardViewModel @Inject constructor(
465461        motdItem,
466462        reviewItem,
467463        statsItem,
464+         easterEggTriggered,
468465        refreshTrigger,
469466    ) { recorderState:  RecorderModule .State ,
470467        debugItem:  DebugCardVH .Item ? ,
@@ -483,6 +480,7 @@ class DashboardViewModel @Inject constructor(
483480        motdItem:  MotdCardVH .Item ? ,
484481        reviewItem:  ReviewCardVH .Item ? ,
485482        statsItem:  StatsDashCardVH .Item ? ,
483+         easterEggTriggered,
486484        _ -> 
487485        val  items =  mutableListOf<DashboardAdapter .Item >(titleInfo)
488486
@@ -546,7 +544,11 @@ class DashboardViewModel @Inject constructor(
546544            }
547545
548546        debugItem?.let  { items.add(it) }
549-         items
547+ 
548+         ListState (
549+             items =  items,
550+             isEasterEgg =  easterEggTriggered,
551+         )
550552    }
551553        .onEach {
552554            if  (! Bugs .isDebug) return @onEach
@@ -556,8 +558,12 @@ class DashboardViewModel @Inject constructor(
556558        .throttleLatest(500 )
557559        .replayingShare(vmScope)
558560
559-     val  listItems  =  listItemsInternal .asLiveData()
561+     val  listState  =  listStateInternal .asLiveData()
560562
563+     data class  ListState (
564+         val  items :  List <DashboardAdapter .Item >,
565+         val  isEasterEgg :  Boolean  = false ,
566+     )
561567
562568    data class  BottomBarState (
563569        val  isReady :  Boolean ,
@@ -584,7 +590,7 @@ class DashboardViewModel @Inject constructor(
584590        systemCleaner.state,
585591        appCleaner.state,
586592        generalSettings.enableDashboardOneClick.flow,
587-         listItemsInternal .map { items  ->  items.any { it is  MainActionItem  } },
593+         listStateInternal .map { state  ->  state. items.any { it is  MainActionItem  } },
588594    ) { upgradeInfo,
589595        taskState,
590596        corpseState,
0 commit comments