Skip to content

Commit 590a29d

Browse files
committed
Run ./gradlew ktlintFormat
Signed-off-by: matt-ramotar <[email protected]>
1 parent 6ebaf2b commit 590a29d

File tree

5 files changed

+311
-313
lines changed

5 files changed

+311
-313
lines changed

store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/Logger.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ interface Logger {
1010
* @param message The error message to log.
1111
* @param throwable An optional [Throwable] associated with the error.
1212
*/
13-
fun error(message: String, throwable: Throwable? = null)
13+
fun error(
14+
message: String,
15+
throwable: Throwable? = null,
16+
)
1417

1518
/**
1619
* Logs a debug message.
1720
*
1821
* @param message The debug message to log.
1922
*/
2023
fun debug(message: String)
21-
}
24+
}

store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/DefaultLogger.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import org.mobilenativefoundation.store.store5.Logger
77
* Default implementation of [Logger] using the Kermit logging library.
88
*/
99
internal class DefaultLogger : Logger {
10-
1110
private val delegate =
1211
co.touchlab.kermit.Logger.apply {
1312
setLogWriters(listOf(CommonWriter()))
@@ -18,7 +17,10 @@ internal class DefaultLogger : Logger {
1817
delegate.d(message)
1918
}
2019

21-
override fun error(message: String, throwable: Throwable?) {
20+
override fun error(
21+
message: String,
22+
throwable: Throwable?,
23+
) {
2224
delegate.e(message, throwable)
2325
}
24-
}
26+
}

store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealMutableStore.kt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
3131
private val delegate: RealStore<Key, Network, Output, Local>,
3232
private val updater: Updater<Key, Output, *>,
3333
private val bookkeeper: Bookkeeper<Key>?,
34-
private val logger: Logger = DefaultLogger()
34+
private val logger: Logger = DefaultLogger(),
3535
) : MutableStore<Key, Output>, Clear.Key<Key> by delegate, Clear.All by delegate {
3636
private val storeLock = Mutex()
3737
private val keyToWriteRequestQueue = mutableMapOf<Key, WriteRequestQueue<Key, Output, *>>()
@@ -42,7 +42,6 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
4242
safeInitStore(request.key)
4343

4444
when (val eagerConflictResolutionResult = tryEagerlyResolveConflicts<Response>(request.key)) {
45-
4645
// TODO(matt-ramotar): Many use cases will not want to pull immediately after failing
4746
// to push local changes. We should enable configuration of conflict resolution strategies,
4847
// such as logging, retrying, canceling.
@@ -56,10 +55,11 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
5655
}
5756

5857
is EagerConflictResolutionResult.Success.ConflictsResolved -> {
59-
val message = when (val result = eagerConflictResolutionResult.value) {
60-
is UpdaterResult.Success.Typed<*> -> result.value.toString()
61-
is UpdaterResult.Success.Untyped -> result.value.toString()
62-
}
58+
val message =
59+
when (val result = eagerConflictResolutionResult.value) {
60+
is UpdaterResult.Success.Typed<*> -> result.value.toString()
61+
is UpdaterResult.Success.Untyped -> result.value.toString()
62+
}
6363
logger.debug(message)
6464
}
6565

@@ -230,18 +230,17 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
230230

231231
@AnyThread
232232
private suspend fun <Response : Any> tryEagerlyResolveConflicts(key: Key): EagerConflictResolutionResult<Response> {
233-
234-
val (latest, conflictsExist) = withThreadSafety(key) {
235-
val latest = delegate.latestOrNull(key)
236-
val conflictsExist = latest != null && bookkeeper != null && conflictsMightExist(key)
237-
latest to conflictsExist
238-
}
233+
val (latest, conflictsExist) =
234+
withThreadSafety(key) {
235+
val latest = delegate.latestOrNull(key)
236+
val conflictsExist = latest != null && bookkeeper != null && conflictsMightExist(key)
237+
latest to conflictsExist
238+
}
239239

240240
if (!conflictsExist || latest == null) {
241241
return EagerConflictResolutionResult.Success.NoConflicts
242242
}
243243

244-
245244
return try {
246245
val updaterResult =
247246
updater.post(key, latest).also { updaterResult ->
@@ -266,7 +265,7 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
266265
if (keyToThreadSafety[key] == null) {
267266
keyToThreadSafety[key] = ThreadSafety()
268267
}
269-
if(keyToWriteRequestQueue[key] == null) {
268+
if (keyToWriteRequestQueue[key] == null) {
270269
keyToWriteRequestQueue[key] = ArrayDeque()
271270
}
272271
}

0 commit comments

Comments
 (0)