-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shared, iOS: Improve track switching flow (#1110)
^ALTAPPS-1290
- Loading branch information
1 parent
e4c6e91
commit 9940fa7
Showing
29 changed files
with
420 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...kill/app/study_plan/domain/analytic/StudyPlanClickedChangeTrackHyperskillAnalyticEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.hyperskill.app.study_plan.domain.analytic | ||
|
||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticAction | ||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticEvent | ||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticPart | ||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticRoute | ||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticTarget | ||
|
||
/** | ||
* Represents a click on "Change track" button analytic event. | ||
* | ||
* JSON payload: | ||
* ``` | ||
* { | ||
* "route": "/study-plan"", | ||
* "action": "click", | ||
* "part": "main", | ||
* "target": "change_track" | ||
* } | ||
* ``` | ||
* | ||
* @see HyperskillAnalyticEvent | ||
*/ | ||
object StudyPlanClickedChangeTrackHyperskillAnalyticEvent : HyperskillAnalyticEvent( | ||
route = HyperskillAnalyticRoute.StudyPlan(), | ||
action = HyperskillAnalyticAction.CLICK, | ||
part = HyperskillAnalyticPart.MAIN, | ||
target = HyperskillAnalyticTarget.CHANGE_TRACK | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
.../hyperskill/app/track_selection/details/cache/TrackSelectionDetailsCacheDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.hyperskill.app.track_selection.details.cache | ||
|
||
import com.russhwolf.settings.Settings | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.Json | ||
import org.hyperskill.app.core.utils.mutate | ||
import org.hyperskill.app.track_selection.details.data.source.TrackSelectionDetailsCacheDataSource | ||
|
||
@Serializable | ||
private class TrackSelectionDetailsCountContainer(val map: Map<Long, Int>) | ||
|
||
internal class TrackSelectionDetailsCacheDataSourceImpl( | ||
private val json: Json, | ||
private val settings: Settings | ||
) : TrackSelectionDetailsCacheDataSource { | ||
override fun getTracksSelectionCountMap(): Map<Long, Int> = | ||
settings | ||
.getStringOrNull(TrackSelectionDetailsCacheKeyValues.TRACK_SELECTION_DETAILS_COUNT_MAP) | ||
?.let { json.decodeFromString(TrackSelectionDetailsCountContainer.serializer(), it).map } | ||
?: emptyMap() | ||
|
||
override fun incrementTrackSelectionCount(trackId: Long) { | ||
val updatedMap = getTracksSelectionCountMap().mutate { | ||
val current = get(trackId) ?: 0 | ||
set(trackId, current + 1) | ||
} | ||
settings.putString( | ||
TrackSelectionDetailsCacheKeyValues.TRACK_SELECTION_DETAILS_COUNT_MAP, | ||
json.encodeToString( | ||
TrackSelectionDetailsCountContainer.serializer(), | ||
TrackSelectionDetailsCountContainer(updatedMap) | ||
) | ||
) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...n/org/hyperskill/app/track_selection/details/cache/TrackSelectionDetailsCacheKeyValues.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.hyperskill.app.track_selection.details.cache | ||
|
||
internal object TrackSelectionDetailsCacheKeyValues { | ||
const val TRACK_SELECTION_DETAILS_COUNT_MAP = "track_selection_details_count_map" | ||
} |
15 changes: 15 additions & 0 deletions
15
...rskill/app/track_selection/details/data/repository/TrackSelectionDetailsRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.hyperskill.app.track_selection.details.data.repository | ||
|
||
import org.hyperskill.app.track_selection.details.data.source.TrackSelectionDetailsCacheDataSource | ||
import org.hyperskill.app.track_selection.details.domain.repository.TrackSelectionDetailsRepository | ||
|
||
internal class TrackSelectionDetailsRepositoryImpl( | ||
private val trackSelectionDetailsCacheDataSource: TrackSelectionDetailsCacheDataSource | ||
) : TrackSelectionDetailsRepository { | ||
override fun getTracksSelectionCountMap(): Map<Long, Int> = | ||
trackSelectionDetailsCacheDataSource.getTracksSelectionCountMap() | ||
|
||
override fun incrementTrackSelectionCount(trackId: Long) { | ||
trackSelectionDetailsCacheDataSource.incrementTrackSelectionCount(trackId) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...yperskill/app/track_selection/details/data/source/TrackSelectionDetailsCacheDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.hyperskill.app.track_selection.details.data.source | ||
|
||
interface TrackSelectionDetailsCacheDataSource { | ||
fun getTracksSelectionCountMap(): Map<Long, Int> | ||
fun incrementTrackSelectionCount(trackId: Long) | ||
} |
6 changes: 6 additions & 0 deletions
6
...perskill/app/track_selection/details/domain/repository/TrackSelectionDetailsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.hyperskill.app.track_selection.details.domain.repository | ||
|
||
interface TrackSelectionDetailsRepository { | ||
fun getTracksSelectionCountMap(): Map<Long, Int> | ||
fun incrementTrackSelectionCount(trackId: Long) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...rg/hyperskill/app/track_selection/details/injection/TrackSelectionDetailsDataComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.hyperskill.app.track_selection.details.injection | ||
|
||
import org.hyperskill.app.track_selection.details.domain.repository.TrackSelectionDetailsRepository | ||
|
||
interface TrackSelectionDetailsDataComponent { | ||
val trackSelectionDetailsRepository: TrackSelectionDetailsRepository | ||
} |
20 changes: 20 additions & 0 deletions
20
...yperskill/app/track_selection/details/injection/TrackSelectionDetailsDataComponentImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.hyperskill.app.track_selection.details.injection | ||
|
||
import org.hyperskill.app.core.injection.AppGraph | ||
import org.hyperskill.app.track_selection.details.cache.TrackSelectionDetailsCacheDataSourceImpl | ||
import org.hyperskill.app.track_selection.details.data.repository.TrackSelectionDetailsRepositoryImpl | ||
import org.hyperskill.app.track_selection.details.data.source.TrackSelectionDetailsCacheDataSource | ||
import org.hyperskill.app.track_selection.details.domain.repository.TrackSelectionDetailsRepository | ||
|
||
internal class TrackSelectionDetailsDataComponentImpl( | ||
appGraph: AppGraph | ||
) : TrackSelectionDetailsDataComponent { | ||
private val trackSelectionDetailsCacheDataSource: TrackSelectionDetailsCacheDataSource = | ||
TrackSelectionDetailsCacheDataSourceImpl( | ||
json = appGraph.commonComponent.json, | ||
settings = appGraph.commonComponent.settings | ||
) | ||
|
||
override val trackSelectionDetailsRepository: TrackSelectionDetailsRepository | ||
get() = TrackSelectionDetailsRepositoryImpl(trackSelectionDetailsCacheDataSource) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.