Skip to content

Commit

Permalink
Merge branch 'feature/ALTAPPS-1034/shared_customizable_challenges' in…
Browse files Browse the repository at this point in the history
…to feature/ALTAPPS-1035/ios_customizable_challenges
  • Loading branch information
ivan-magda authored Nov 18, 2023
2 parents 70b4f01 + d3189ea commit d10b91e
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 48 deletions.
2 changes: 1 addition & 1 deletion androidHyperskillApp/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"
ruby "3.1.0"

gem "fastlane", "2.216.0"
gem "fastlane", "2.217.0"

eval_gemfile("fastlane/Pluginfile")
46 changes: 21 additions & 25 deletions androidHyperskillApp/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.826.0)
aws-sdk-core (3.183.0)
aws-partitions (1.853.0)
aws-sdk-core (3.187.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sdk-kms (1.72.0)
aws-sdk-core (~> 3, >= 3.184.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.135.0)
aws-sdk-s3 (1.137.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-sigv4 (1.6.1)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
Expand All @@ -32,11 +32,10 @@ GEM
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
domain_name (0.6.20231109)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.103.0)
excon (0.104.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -66,7 +65,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.7)
fastlane (2.216.0)
fastlane (2.217.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -106,12 +105,12 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-firebase_app_distribution (0.7.3)
fastlane-plugin-firebase_app_distribution (0.7.4)
google-apis-firebaseappdistribution_v1 (~> 0.3.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.49.0)
google-apis-androidpublisher_v3 (0.52.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.1)
google-apis-core (0.11.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
Expand All @@ -126,19 +125,19 @@ GEM
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.19.0)
google-apis-core (>= 0.9.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.44.0)
google-cloud-storage (1.45.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.19.0)
google-apis-storage_v1 (~> 0.29.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
Expand All @@ -164,8 +163,8 @@ GEM
optparse (0.1.1)
os (1.1.4)
plist (3.7.0)
public_suffix (5.0.3)
rake (13.0.6)
public_suffix (5.0.4)
rake (13.1.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand Down Expand Up @@ -193,13 +192,10 @@ GEM
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcodeproj (1.22.0)
xcodeproj (1.23.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand All @@ -217,7 +213,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
fastlane (= 2.216.0)
fastlane (= 2.217.0)
fastlane-plugin-firebase_app_distribution

RUBY VERSION
Expand Down
2 changes: 1 addition & 1 deletion iosHyperskillApp/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"
ruby "3.1.0"

gem "fastlane", "2.216.0"
gem "fastlane", "2.217.0"
gem "cocoapods", "1.14.2"
gem "generamba", git: "https://github.com/ivan-magda/Generamba.git", branch: "develop"

Expand Down
36 changes: 16 additions & 20 deletions iosHyperskillApp/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GEM
specs:
CFPropertyList (3.0.6)
rexml
activesupport (7.1.1)
activesupport (7.1.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand All @@ -34,23 +34,23 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.843.0)
aws-sdk-core (3.185.1)
aws-partitions (1.853.0)
aws-sdk-core (3.187.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.72.0)
aws-sdk-core (~> 3, >= 3.184.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.136.0)
aws-sdk-s3 (1.137.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.1)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.1.1)
base64 (0.2.0)
bigdecimal (3.1.4)
claide (1.1.0)
cocoapods (1.14.2)
Expand Down Expand Up @@ -99,10 +99,9 @@ GEM
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
domain_name (0.6.20231109)
dotenv (2.8.1)
drb (2.1.1)
drb (2.2.0)
ruby2_keywords
emoji_regex (3.2.3)
escape (0.0.4)
Expand Down Expand Up @@ -138,7 +137,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.7)
fastlane (2.216.0)
fastlane (2.217.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -189,7 +188,7 @@ GEM
git (1.13.0)
addressable (~> 2.8)
rchardet (~> 1.8)
google-apis-androidpublisher_v3 (0.51.0)
google-apis-androidpublisher_v3 (0.52.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -206,19 +205,19 @@ GEM
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.19.0)
google-apis-core (>= 0.9.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.44.0)
google-cloud-storage (1.45.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.19.0)
google-apis-storage_v1 (~> 0.29.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
Expand All @@ -244,7 +243,7 @@ GEM
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.3.0)
mutex_m (0.1.2)
mutex_m (0.2.0)
nanaimo (0.3.0)
nap (1.1.0)
naturally (2.2.1)
Expand Down Expand Up @@ -283,14 +282,11 @@ GEM
tty-screen (0.8.1)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
typhoeus (1.4.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
Expand All @@ -314,7 +310,7 @@ PLATFORMS

DEPENDENCIES
cocoapods (= 1.14.2)
fastlane (= 2.216.0)
fastlane (= 2.217.0)
fastlane-plugin-firebase_app_distribution
fastlane-plugin-sentry
generamba!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.hyperskill.app.challenges.widget.presentation

import kotlin.time.DurationUnit
import kotlin.time.toDuration
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.hyperskill.app.analytic.domain.interactor.AnalyticInteractor
Expand Down Expand Up @@ -29,6 +34,11 @@ class ChallengeWidgetActionDispatcher(
private val sentryInteractor: SentryInteractor,
private val analyticInteractor: AnalyticInteractor
) : CoroutineActionDispatcher<Action, Message>(config.createConfig()) {
private var timerJob: Job? = null

companion object {
private val TIMER_TICK_INTERVAL = 1.toDuration(DurationUnit.MINUTES)
}

init {
solvedStepsSharedFlow
Expand Down Expand Up @@ -61,6 +71,10 @@ class ChallengeWidgetActionDispatcher(
handleCreateMagicLinkAction(action, ::onNewMessage)
is InternalAction.LogAnalyticEvent ->
analyticInteractor.logEvent(action.analyticEvent)
InternalAction.LaunchTimer ->
handleLaunchTimerAction(::onNewMessage)
InternalAction.StopTimer ->
handleStopTimerAction()
else -> {
// no op
}
Expand Down Expand Up @@ -94,4 +108,24 @@ class ChallengeWidgetActionDispatcher(
}
)
}

private fun handleLaunchTimerAction(onNewMessage: (Message) -> Unit) {
if (timerJob != null) {
return
}

timerJob = flow {
while (true) {
delay(TIMER_TICK_INTERVAL)
emit(Unit)
}
}.onEach {
onNewMessage(InternalMessage.TimerTick)
}.launchIn(actionScope)
}

private fun handleStopTimerAction() {
timerJob?.cancel()
timerJob = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ object ChallengeWidgetFeature {
object CreateMagicLinkError : InternalMessage
data class CreateMagicLinkSuccess(val url: String) : InternalMessage

object TimerTick : InternalMessage

// Observe target types changes
object StepSolved : InternalMessage
object DailyStepCompleted : InternalMessage
Expand All @@ -88,6 +90,9 @@ object ChallengeWidgetFeature {
internal sealed interface InternalAction : Action {
object FetchChallenges : InternalAction

object LaunchTimer : InternalAction
object StopTimer : InternalAction

data class CreateMagicLink(val nextUrl: String) : InternalAction

data class LogAnalyticEvent(val analyticEvent: AnalyticEvent) : InternalAction
Expand Down
Loading

0 comments on commit d10b91e

Please sign in to comment.