Skip to content

Commit

Permalink
Merge pull request #27 from InsanusMokrassar/0.2.4
Browse files Browse the repository at this point in the history
0.2.4
  • Loading branch information
InsanusMokrassar authored Jul 3, 2023
2 parents 8ef6dbf + d9e790e commit 49a76ef
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Navigation Changelog

## 0.2.4

* Fixes in part of non-storable nodes in hierarchy saving

## 0.2.3

* `Versions`:
Expand Down
40 changes: 26 additions & 14 deletions core/src/commonMain/kotlin/repo/HierarchyRepoUpdater.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,43 @@ fun <T> NavigationConfigsRepo<T>.enableSavingHierarchy(
}

fun NavigationNode<out T, T>.enableListeningUpdates(scope: CoroutineScope) {
configState.subscribeSafelyWithoutExceptions(scope) {
save("config change")
if (storableInNavigationHierarchy) {
configState.subscribeSafelyWithoutExceptions(scope) {
save("config change")
}
}
}

fun NavigationChain<T>.enableListeningUpdates(scope: CoroutineScope) {
val currentSubscope = scope.LinkedSupervisorScope()
onNodesStackDiffFlow.filter { it.isEmpty() }.subscribeSafelyWithoutExceptions(currentSubscope) {
save("initialization")
var needSave = false
needSave = it.added.any { it.value.storableInNavigationHierarchy } || needSave
needSave = it.replaced.any { it.first.value.storableInNavigationHierarchy || it.second.value.storableInNavigationHierarchy } || needSave
needSave = it.removed.any { it.value.storableInNavigationHierarchy } || needSave
if (needSave) {
save("initialization")
}
}
onNodeAddedFlow.flatten().subscribeSafelyWithoutExceptions(currentSubscope) { (_, newNode) ->
save("node adding")
newNode.enableListeningUpdates(currentSubscope)
newNode.onChainAddedFlow.subscribeSafelyWithoutExceptions(scope) { newChains ->
save("chain adding")
newChains.forEach { newChain ->
newChain.value.enableListeningUpdates(scope)
if (newNode.storableInNavigationHierarchy) {
save("node adding")
newNode.enableListeningUpdates(currentSubscope)
newNode.onChainAddedFlow.subscribeSafelyWithoutExceptions(scope) { newChains ->
save("chain adding")
newChains.forEach { newChain ->
newChain.value.enableListeningUpdates(scope)
}
}
newNode.onChainRemovedFlow.subscribeSafelyWithoutExceptions(scope) {
save("chain removing")
}
}
newNode.onChainRemovedFlow.subscribeSafelyWithoutExceptions(scope) {
save("chain removing")
}
}
onNodeRemovedFlow.flatten().subscribeSafelyWithoutExceptions(currentSubscope) { _ ->
save("node removing")
onNodeRemovedFlow.flatten().subscribeSafelyWithoutExceptions(currentSubscope) { (i, node) ->
if (node.storableInNavigationHierarchy) {
save("node removing")
}
}
stack.forEach {
it.enableListeningUpdates(currentSubscope)
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ org.gradle.jvmargs=-Xmx1g
# Project data

group=dev.inmo
version=0.2.3
android_code_version=24
version=0.2.4
android_code_version=25

0 comments on commit 49a76ef

Please sign in to comment.