package com.suno.android.ui.screens.onboarding.allow_notifications import com.suno.android.common_mvi.MviProcessorFactory import com.suno.android.common_mvi.MviViewModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel class OnboardingAllowNotificationsScreenVM @Inject constructor( processorFactory: MviProcessorFactory, ) : MviViewModel< OnboardingAllowNotificationsScreenEvent, OnboardingAllowNotificationsScreenState, OnboardingAllowNotificationsScreenEffect, >( processorFactory = processorFactory, initialState = OnboardingAllowNotificationsScreenState(), ) { override suspend fun reduceEvent( currentState: OnboardingAllowNotificationsScreenState, event: OnboardingAllowNotificationsScreenEvent, emitEffect: suspend (OnboardingAllowNotificationsScreenEffect) -> Unit, ): OnboardingAllowNotificationsScreenState = when (event) { OnboardingAllowNotificationsScreenEvent.RequestNotificationPermission -> { emitEffect(OnboardingAllowNotificationsScreenEffect.RequestNotificationPermission) currentState.copy( skipActionIsVisible = true, ) } is OnboardingAllowNotificationsScreenEvent.OnNotificationPermissionResult -> { if (event.isGranted) { emitEffect(OnboardingAllowNotificationsScreenEffect.NavigateToNextScreen) } currentState.copy( loading = false, permissionGranted = event.isGranted, ) } } }