Skip to content

Commit d562340

Browse files
authored
Shared: Revert fake topics in mobile apps adopted course study plan (#1199)
^ALTAPPS-1362
1 parent 0c86f75 commit d562340

File tree

8 files changed

+77
-196
lines changed

8 files changed

+77
-196
lines changed

config/detekt/baseline.xml

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
<ID>LongMethod:StepQuizCodeBlanksReducer.kt$StepQuizCodeBlanksReducer$private fun handleSuggestionClicked( state: State, message: Message.SuggestionClicked ): StepQuizCodeBlanksReducerResult?</ID>
7373
<ID>LongMethod:StepQuizCodeBlanksViewStateMapper.kt$StepQuizCodeBlanksViewStateMapper$private fun mapContentState( state: StepQuizCodeBlanksFeature.State.Content ): StepQuizCodeBlanksViewState.Content</ID>
7474
<ID>LongMethod:StreakFreezeDialogFragment.kt$StreakFreezeDialogFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID>
75-
<ID>LongMethod:StudyPlanWidgetReducer.kt$StudyPlanWidgetReducer$private fun handleLearningActivitiesWithSectionsFetchSuccess( state: State, message: StudyPlanWidgetFeature.LearningActivitiesWithSectionsFetchResult.Success ): StudyPlanWidgetReducerResult</ID>
7675
<ID>LongMethod:TrackProgressContent.kt$@Composable fun TrackProgressContent( viewState: ProgressScreenViewState.TrackProgressViewState.Content, onNewMessage: (ProgressScreenFeature.Message) -&gt; Unit, modifier: Modifier = Modifier )</ID>
7776
<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>
7877
<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>

iosHyperskillApp/iosHyperskillApp/Sources/Extensions/SwiftUI/View/View+OnTapWhenDisabled.swift

+28-28
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ extension View {
1515
}
1616
}
1717

18-
#if DEBUG
19-
@available(iOS 17.0, *)
20-
#Preview {
21-
@Previewable @State var isButtonDisabled = true
22-
23-
VStack {
24-
Button(
25-
action: {
26-
print("Button tapped!")
27-
},
28-
label: {
29-
Text("Submit")
30-
.padding()
31-
.background(isButtonDisabled ? Color.gray : Color.blue)
32-
.foregroundColor(.white)
33-
.cornerRadius(8)
34-
}
35-
)
36-
.disabled(isButtonDisabled)
37-
.onTapWhenDisabled(isDisabled: isButtonDisabled) {
38-
print("Button is disabled!")
39-
}
40-
41-
Toggle("Disable View", isOn: $isButtonDisabled)
42-
.padding()
43-
}
44-
}
45-
#endif
18+
// #if DEBUG
19+
// @available(iOS 17.0, *)
20+
// #Preview {
21+
// @Previewable @State var isButtonDisabled = true
22+
//
23+
// VStack {
24+
// Button(
25+
// action: {
26+
// print("Button tapped!")
27+
// },
28+
// label: {
29+
// Text("Submit")
30+
// .padding()
31+
// .background(isButtonDisabled ? Color.gray : Color.blue)
32+
// .foregroundColor(.white)
33+
// .cornerRadius(8)
34+
// }
35+
// )
36+
// .disabled(isButtonDisabled)
37+
// .onTapWhenDisabled(isDisabled: isButtonDisabled) {
38+
// print("Button is disabled!")
39+
// }
40+
//
41+
// Toggle("Disable View", isOn: $isButtonDisabled)
42+
// .padding()
43+
// }
44+
// }
45+
// #endif

iosHyperskillApp/iosHyperskillApp/Sources/Views/SwiftUI/Effects/BounceEffect.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ extension View {
2929
}
3030
}
3131

32-
#if DEBUG
33-
@available(iOS 17.0, *)
34-
#Preview {
35-
@Previewable @State var isBouncing = false
36-
37-
Button {
38-
isBouncing.toggle()
39-
} label: {
40-
Text("Retry")
41-
}
42-
.buttonStyle(RoundedRectangleButtonStyle(style: .violet))
43-
.bounceEffect(isActive: isBouncing)
44-
.padding()
45-
}
46-
#endif
32+
// #if DEBUG
33+
// @available(iOS 17.0, *)
34+
// #Preview {
35+
// @Previewable @State var isBouncing = false
36+
//
37+
// Button {
38+
// isBouncing.toggle()
39+
// } label: {
40+
// Text("Retry")
41+
// }
42+
// .buttonStyle(RoundedRectangleButtonStyle(style: .violet))
43+
// .bounceEffect(isActive: isBouncing)
44+
// .padding()
45+
// }
46+
// #endif

iosHyperskillApp/iosHyperskillApp/Sources/Views/SwiftUI/Effects/JiggleEffect.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ extension View {
3939
}
4040
}
4141

42-
#if DEBUG
43-
@available(iOS 17.0, *)
44-
#Preview {
45-
@Previewable @State var isJiggling = false
46-
47-
Button {
48-
isJiggling.toggle()
49-
} label: {
50-
Text("Retry")
51-
}
52-
.buttonStyle(RoundedRectangleButtonStyle(style: .violet))
53-
.jiggleEffect(amount: 2, isActive: isJiggling)
54-
.padding()
55-
}
56-
#endif
42+
// #if DEBUG
43+
// @available(iOS 17.0, *)
44+
// #Preview {
45+
// @Previewable @State var isJiggling = false
46+
//
47+
// Button {
48+
// isJiggling.toggle()
49+
// } label: {
50+
// Text("Retry")
51+
// }
52+
// .buttonStyle(RoundedRectangleButtonStyle(style: .violet))
53+
// .jiggleEffect(amount: 2, isActive: isJiggling)
54+
// .padding()
55+
// }
56+
// #endif

shared/src/commonMain/kotlin/org/hyperskill/app/study_plan/widget/presentation/StudyPlanWidgetFakeTopicsFeature.kt

-73
This file was deleted.

shared/src/commonMain/kotlin/org/hyperskill/app/study_plan/widget/presentation/StudyPlanWidgetReducer.kt

+11-48
Original file line numberDiff line numberDiff line change
@@ -145,42 +145,8 @@ class StudyPlanWidgetReducer : StateReducer<State, Message, Action> {
145145
state: State,
146146
message: StudyPlanWidgetFeature.LearningActivitiesWithSectionsFetchResult.Success
147147
): StudyPlanWidgetReducerResult {
148-
val isFakeTopicsFeatureAvailable =
149-
StudyPlanWidgetFakeTopicsFeature.isFakeTopicsFeatureAvailable(
150-
trackId = state.profile?.trackId,
151-
subscription = message.subscription
152-
)
153-
val fakeTopics = if (isFakeTopicsFeatureAvailable) {
154-
StudyPlanWidgetFakeTopicsFeature.topics
155-
} else {
156-
emptyList()
157-
}
158-
159-
val studyPlanSections =
160-
if (isFakeTopicsFeatureAvailable) {
161-
message.studyPlanSections.map { section ->
162-
if (section.type == StudyPlanSectionType.ROOT_TOPICS) {
163-
section.copy(
164-
isVisible = true,
165-
activities = section.activities + fakeTopics.map { it.id }
166-
)
167-
} else {
168-
section
169-
}
170-
}
171-
} else {
172-
message.studyPlanSections
173-
}
174-
175-
val learningActivities =
176-
if (isFakeTopicsFeatureAvailable) {
177-
message.learningActivities + fakeTopics
178-
} else {
179-
message.learningActivities
180-
}
181-
val learningActivitiesIds = learningActivities.map { it.id }.toSet()
182-
183-
val visibleSections = getVisibleSections(studyPlanSections, learningActivitiesIds)
148+
val learningActivitiesIds = message.learningActivities.map { it.id }.toSet()
149+
val visibleSections = getVisibleSections(message.studyPlanSections, learningActivitiesIds)
184150
val currentSectionId = visibleSections.firstOrNull()?.id ?: return state.copy(
185151
studyPlanSections = emptyMap(),
186152
sectionsStatus = ContentStatus.LOADED,
@@ -190,18 +156,15 @@ class StudyPlanWidgetReducer : StateReducer<State, Message, Action> {
190156

191157
val supportedSections = visibleSections
192158
.filter { studyPlanSection ->
193-
when (studyPlanSection.type) {
194-
StudyPlanSectionType.NEXT_PROJECT ->
195-
// ALTAPPS-1186: We should hide next project section for freemium users
196-
message.subscription.type.isProjectSelectionEnabled
197-
StudyPlanSectionType.NEXT_TRACK ->
198-
// ALTAPPS-1355: We should hide next track section for freemium users
199-
!isFakeTopicsFeatureAvailable
200-
else -> true
159+
// ALTAPPS-1186: We should hide next project section for freemium users
160+
if (!message.subscription.type.isProjectSelectionEnabled) {
161+
studyPlanSection.type != StudyPlanSectionType.NEXT_PROJECT
162+
} else {
163+
true
201164
}
202165
}
203166

204-
val resultStudyPlanSections = supportedSections.associate { studyPlanSection ->
167+
val studyPlanSections = supportedSections.associate { studyPlanSection ->
205168
studyPlanSection.id to StudyPlanWidgetFeature.StudyPlanSectionInfo(
206169
studyPlanSection = studyPlanSection,
207170
isExpanded = studyPlanSection.id == currentSectionId,
@@ -216,19 +179,19 @@ class StudyPlanWidgetReducer : StateReducer<State, Message, Action> {
216179
}
217180

218181
val loadedSectionsState = state.copy(
219-
studyPlanSections = resultStudyPlanSections,
182+
studyPlanSections = studyPlanSections,
220183
sectionsStatus = ContentStatus.LOADED,
221184
isRefreshing = false,
222185
learnedTopicsCount = message.learnedTopicsCount,
223-
activities = learningActivities.associateBy { it.id },
186+
activities = message.learningActivities.associateBy { it.id },
224187
subscriptionLimitType = message.subscriptionLimitType
225188
)
226189

227190
return if (loadedSectionsState.studyPlanSections.isNotEmpty()) {
228191
handleNewActivities(
229192
loadedSectionsState,
230193
sectionId = currentSectionId,
231-
activities = learningActivities,
194+
activities = message.learningActivities,
232195
targetPage = SectionPage.MAIN
233196
)
234197
} else {

shared/src/commonMain/kotlin/org/hyperskill/app/study_plan/widget/presentation/StudyPlanWidgetStateExtensions.kt

+7-11
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,13 @@ internal fun StudyPlanWidgetFeature.State.isActivityLocked(
109109
sectionId: Long,
110110
activityId: Long,
111111
): Boolean {
112-
if (StudyPlanWidgetFakeTopicsFeature.topicsIds.contains(activityId)) {
113-
return true
114-
} else {
115-
val unlockedActivitiesCount = getUnlockedActivitiesCount(sectionId)
116-
return unlockedActivitiesCount != null &&
117-
getLoadedSectionActivities(sectionId)
118-
.take(unlockedActivitiesCount)
119-
.map { it.id }
120-
.contains(activityId)
121-
.not()
122-
}
112+
val unlockedActivitiesCount = getUnlockedActivitiesCount(sectionId)
113+
return unlockedActivitiesCount != null &&
114+
getLoadedSectionActivities(sectionId)
115+
.take(unlockedActivitiesCount)
116+
.map { it.id }
117+
.contains(activityId)
118+
.not()
123119
}
124120

125121
/**

shared/src/commonMain/kotlin/org/hyperskill/app/study_plan/widget/view/mapper/StudyPlanWidgetViewStateMapper.kt

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import org.hyperskill.app.core.view.mapper.date.SharedDateFormatter
55
import org.hyperskill.app.learning_activities.domain.model.LearningActivity
66
import org.hyperskill.app.learning_activities.domain.model.LearningActivityState
77
import org.hyperskill.app.learning_activities.view.mapper.LearningActivityTextsMapper
8-
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFakeTopicsFeature
98
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFeature
109
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFeature.ContentStatus
1110
import org.hyperskill.app.study_plan.widget.presentation.StudyPlanWidgetFeature.PageContentStatus
@@ -107,15 +106,12 @@ class StudyPlanWidgetViewStateMapper(private val dateFormatter: SharedDateFormat
107106
emptyActivitiesState
108107
} else {
109108
val unlockedActivitiesCount = state.getUnlockedActivitiesCount(sectionId)
110-
val fakeTopicsIds = StudyPlanWidgetFakeTopicsFeature.topicsIds
111109
SectionContent.Content(
112110
sectionItems = loadedActivities.mapIndexed { index, activity ->
113-
val isLocked = fakeTopicsIds.contains(activity.id) ||
114-
(unlockedActivitiesCount != null && index + 1 > unlockedActivitiesCount)
115111
mapSectionItem(
116112
activity = activity,
117113
currentActivityId = currentActivityId,
118-
isLocked = isLocked
114+
isLocked = unlockedActivitiesCount != null && index + 1 > unlockedActivitiesCount
119115
)
120116
},
121117
nextPageLoadingState = mapPageContentStatusToViewState(sectionInfo.nextPageContentStatus),

0 commit comments

Comments
 (0)