Skip to content

Commit

Permalink
Shared: Revert fake topics in mobile apps adopted course study plan (#…
Browse files Browse the repository at this point in the history
…1199)

^ALTAPPS-1362
  • Loading branch information
ivan-magda authored Oct 7, 2024
1 parent 0c86f75 commit d562340
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 196 deletions.
1 change: 0 additions & 1 deletion config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<ID>LongMethod:StepQuizCodeBlanksReducer.kt$StepQuizCodeBlanksReducer$private fun handleSuggestionClicked( state: State, message: Message.SuggestionClicked ): StepQuizCodeBlanksReducerResult?</ID>
<ID>LongMethod:StepQuizCodeBlanksViewStateMapper.kt$StepQuizCodeBlanksViewStateMapper$private fun mapContentState( state: StepQuizCodeBlanksFeature.State.Content ): StepQuizCodeBlanksViewState.Content</ID>
<ID>LongMethod:StreakFreezeDialogFragment.kt$StreakFreezeDialogFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID>
<ID>LongMethod:StudyPlanWidgetReducer.kt$StudyPlanWidgetReducer$private fun handleLearningActivitiesWithSectionsFetchSuccess( state: State, message: StudyPlanWidgetFeature.LearningActivitiesWithSectionsFetchResult.Success ): StudyPlanWidgetReducerResult</ID>
<ID>LongMethod:TrackProgressContent.kt$@Composable fun TrackProgressContent( viewState: ProgressScreenViewState.TrackProgressViewState.Content, onNewMessage: (ProgressScreenFeature.Message) -&gt; Unit, modifier: Modifier = Modifier )</ID>
<ID>LongParameterList:AppInteractor.kt$AppInteractor$( private val appRepository: AppRepository, private val authInteractor: AuthInteractor, private val currentProfileStateRepository: CurrentProfileStateRepository, private val userStorageInteractor: UserStorageInteractor, private val analyticInteractor: AnalyticInteractor, private val progressesRepository: ProgressesRepository, private val trackRepository: TrackRepository, private val providersRepository: ProvidersRepository, private val projectsRepository: ProjectsRepository, private val shareStreakRepository: ShareStreakRepository, private val pushNotificationsInteractor: PushNotificationsInteractor )</ID>
<ID>LongParameterList:AuthRemoteDataSourceImpl.kt$AuthRemoteDataSourceImpl$( private val authCacheMutex: Mutex, private val deauthorizationFlow: Flow&lt;UserDeauthorized&gt;, private val authSocialHttpClient: HttpClient, private val authCredentialsHttpClient: HttpClient, private val networkEndpointConfigInfo: NetworkEndpointConfigInfo, private val json: Json, private val settings: Settings )</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ extension View {
}
}

#if DEBUG
@available(iOS 17.0, *)
#Preview {
@Previewable @State var isButtonDisabled = true

VStack {
Button(
action: {
print("Button tapped!")
},
label: {
Text("Submit")
.padding()
.background(isButtonDisabled ? Color.gray : Color.blue)
.foregroundColor(.white)
.cornerRadius(8)
}
)
.disabled(isButtonDisabled)
.onTapWhenDisabled(isDisabled: isButtonDisabled) {
print("Button is disabled!")
}

Toggle("Disable View", isOn: $isButtonDisabled)
.padding()
}
}
#endif
// #if DEBUG
// @available(iOS 17.0, *)
// #Preview {
// @Previewable @State var isButtonDisabled = true
//
// VStack {
// Button(
// action: {
// print("Button tapped!")
// },
// label: {
// Text("Submit")
// .padding()
// .background(isButtonDisabled ? Color.gray : Color.blue)
// .foregroundColor(.white)
// .cornerRadius(8)
// }
// )
// .disabled(isButtonDisabled)
// .onTapWhenDisabled(isDisabled: isButtonDisabled) {
// print("Button is disabled!")
// }
//
// Toggle("Disable View", isOn: $isButtonDisabled)
// .padding()
// }
// }
// #endif
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ extension View {
}
}

#if DEBUG
@available(iOS 17.0, *)
#Preview {
@Previewable @State var isBouncing = false

Button {
isBouncing.toggle()
} label: {
Text("Retry")
}
.buttonStyle(RoundedRectangleButtonStyle(style: .violet))
.bounceEffect(isActive: isBouncing)
.padding()
}
#endif
// #if DEBUG
// @available(iOS 17.0, *)
// #Preview {
// @Previewable @State var isBouncing = false
//
// Button {
// isBouncing.toggle()
// } label: {
// Text("Retry")
// }
// .buttonStyle(RoundedRectangleButtonStyle(style: .violet))
// .bounceEffect(isActive: isBouncing)
// .padding()
// }
// #endif
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ extension View {
}
}

#if DEBUG
@available(iOS 17.0, *)
#Preview {
@Previewable @State var isJiggling = false

Button {
isJiggling.toggle()
} label: {
Text("Retry")
}
.buttonStyle(RoundedRectangleButtonStyle(style: .violet))
.jiggleEffect(amount: 2, isActive: isJiggling)
.padding()
}
#endif
// #if DEBUG
// @available(iOS 17.0, *)
// #Preview {
// @Previewable @State var isJiggling = false
//
// Button {
// isJiggling.toggle()
// } label: {
// Text("Retry")
// }
// .buttonStyle(RoundedRectangleButtonStyle(style: .violet))
// .jiggleEffect(amount: 2, isActive: isJiggling)
// .padding()
// }
// #endif

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -145,42 +145,8 @@ class StudyPlanWidgetReducer : StateReducer<State, Message, Action> {
state: State,
message: StudyPlanWidgetFeature.LearningActivitiesWithSectionsFetchResult.Success
): StudyPlanWidgetReducerResult {
val isFakeTopicsFeatureAvailable =
StudyPlanWidgetFakeTopicsFeature.isFakeTopicsFeatureAvailable(
trackId = state.profile?.trackId,
subscription = message.subscription
)
val fakeTopics = if (isFakeTopicsFeatureAvailable) {
StudyPlanWidgetFakeTopicsFeature.topics
} else {
emptyList()
}

val studyPlanSections =
if (isFakeTopicsFeatureAvailable) {
message.studyPlanSections.map { section ->
if (section.type == StudyPlanSectionType.ROOT_TOPICS) {
section.copy(
isVisible = true,
activities = section.activities + fakeTopics.map { it.id }
)
} else {
section
}
}
} else {
message.studyPlanSections
}

val learningActivities =
if (isFakeTopicsFeatureAvailable) {
message.learningActivities + fakeTopics
} else {
message.learningActivities
}
val learningActivitiesIds = learningActivities.map { it.id }.toSet()

val visibleSections = getVisibleSections(studyPlanSections, learningActivitiesIds)
val learningActivitiesIds = message.learningActivities.map { it.id }.toSet()
val visibleSections = getVisibleSections(message.studyPlanSections, learningActivitiesIds)
val currentSectionId = visibleSections.firstOrNull()?.id ?: return state.copy(
studyPlanSections = emptyMap(),
sectionsStatus = ContentStatus.LOADED,
Expand All @@ -190,18 +156,15 @@ class StudyPlanWidgetReducer : StateReducer<State, Message, Action> {

val supportedSections = visibleSections
.filter { studyPlanSection ->
when (studyPlanSection.type) {
StudyPlanSectionType.NEXT_PROJECT ->
// ALTAPPS-1186: We should hide next project section for freemium users
message.subscription.type.isProjectSelectionEnabled
StudyPlanSectionType.NEXT_TRACK ->
// ALTAPPS-1355: We should hide next track section for freemium users
!isFakeTopicsFeatureAvailable
else -> true
// ALTAPPS-1186: We should hide next project section for freemium users
if (!message.subscription.type.isProjectSelectionEnabled) {
studyPlanSection.type != StudyPlanSectionType.NEXT_PROJECT
} else {
true
}
}

val resultStudyPlanSections = supportedSections.associate { studyPlanSection ->
val studyPlanSections = supportedSections.associate { studyPlanSection ->
studyPlanSection.id to StudyPlanWidgetFeature.StudyPlanSectionInfo(
studyPlanSection = studyPlanSection,
isExpanded = studyPlanSection.id == currentSectionId,
Expand All @@ -216,19 +179,19 @@ class StudyPlanWidgetReducer : StateReducer<State, Message, Action> {
}

val loadedSectionsState = state.copy(
studyPlanSections = resultStudyPlanSections,
studyPlanSections = studyPlanSections,
sectionsStatus = ContentStatus.LOADED,
isRefreshing = false,
learnedTopicsCount = message.learnedTopicsCount,
activities = learningActivities.associateBy { it.id },
activities = message.learningActivities.associateBy { it.id },
subscriptionLimitType = message.subscriptionLimitType
)

return if (loadedSectionsState.studyPlanSections.isNotEmpty()) {
handleNewActivities(
loadedSectionsState,
sectionId = currentSectionId,
activities = learningActivities,
activities = message.learningActivities,
targetPage = SectionPage.MAIN
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,13 @@ internal fun StudyPlanWidgetFeature.State.isActivityLocked(
sectionId: Long,
activityId: Long,
): Boolean {
if (StudyPlanWidgetFakeTopicsFeature.topicsIds.contains(activityId)) {
return true
} else {
val unlockedActivitiesCount = getUnlockedActivitiesCount(sectionId)
return unlockedActivitiesCount != null &&
getLoadedSectionActivities(sectionId)
.take(unlockedActivitiesCount)
.map { it.id }
.contains(activityId)
.not()
}
val unlockedActivitiesCount = getUnlockedActivitiesCount(sectionId)
return unlockedActivitiesCount != null &&
getLoadedSectionActivities(sectionId)
.take(unlockedActivitiesCount)
.map { it.id }
.contains(activityId)
.not()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.hyperskill.app.core.view.mapper.date.SharedDateFormatter
import org.hyperskill.app.learning_activities.domain.model.LearningActivity
import org.hyperskill.app.learning_activities.domain.model.LearningActivityState
import org.hyperskill.app.learning_activities.view.mapper.LearningActivityTextsMapper
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFakeTopicsFeature
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFeature
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFeature.ContentStatus
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFeature.PageContentStatus
Expand Down Expand Up @@ -107,15 +106,12 @@ class StudyPlanWidgetViewStateMapper(private val dateFormatter: SharedDateFormat
emptyActivitiesState
} else {
val unlockedActivitiesCount = state.getUnlockedActivitiesCount(sectionId)
val fakeTopicsIds = StudyPlanWidgetFakeTopicsFeature.topicsIds
SectionContent.Content(
sectionItems = loadedActivities.mapIndexed { index, activity ->
val isLocked = fakeTopicsIds.contains(activity.id) ||
(unlockedActivitiesCount != null && index + 1 > unlockedActivitiesCount)
mapSectionItem(
activity = activity,
currentActivityId = currentActivityId,
isLocked = isLocked
isLocked = unlockedActivitiesCount != null && index + 1 > unlockedActivitiesCount
)
},
nextPageLoadingState = mapPageContentStatusToViewState(sectionInfo.nextPageContentStatus),
Expand Down

0 comments on commit d562340

Please sign in to comment.