@@ -83,11 +83,11 @@ internal class TripsSynchronizationService constructor(
8383 }
8484
8585 private fun createServerTrip (localTrip : Trip , syncResult : SynchronizationResult ) {
86- log() { " Creating trip ${localTrip.id} " }
86+ log { " Creating trip ${localTrip.id} " }
8787
8888 val localPlaceIds = localTrip.getLocalPlaceIds()
8989 if (localPlaceIds.isNotEmpty()) {
90- log() {
90+ log {
9191 " Trip cannot be synced because contains places with local id: ${localPlaceIds.joinToString(" , " )} "
9292 }
9393 return
@@ -102,11 +102,11 @@ internal class TripsSynchronizationService constructor(
102102 }
103103
104104 private fun updateServerTrip (localTrip : Trip , syncResult : SynchronizationResult ) {
105- log() { " Updating trip ${localTrip.id} " }
105+ log { " Updating trip ${localTrip.id} " }
106106
107107 val localPlaceIds = localTrip.getLocalPlaceIds()
108108 if (localPlaceIds.isNotEmpty()) {
109- log() {
109+ log {
110110 " Trip cannot be synced because contain places with local id: ${localPlaceIds.joinToString(" , " )} "
111111 }
112112 return
@@ -115,17 +115,17 @@ internal class TripsSynchronizationService constructor(
115115 val updateResponse = apiClient.updateTrip(localTrip.id, tripConverter.toApi(localTrip)).execute()
116116
117117 if (updateResponse.code() == 404 ) {
118- log() { " Trip ${localTrip.id} deleted on server, removing in local store." }
118+ log { " Trip ${localTrip.id} deleted on server, removing in local store." }
119119 tripsService.deleteTrip(localTrip.id)
120120 syncResult.changedTripIds.add(localTrip.id)
121121 return
122122
123123 } else if (updateResponse.code() == 403 ) {
124- log() { " Trip ${localTrip.id} is not allowed to be modified by current user, trying to fetch original." }
124+ log { " Trip ${localTrip.id} is not allowed to be modified by current user, trying to fetch original." }
125125 val tripResponse = apiClient.getTrip(localTrip.id).execute()
126126 if (tripResponse.isSuccessful) {
127127 val apiTripData = tripResponse.body()!! .data!! .trip
128- log() { " Trip ${localTrip.id} is not allowed to be modified by current user; re-fetched." }
128+ log { " Trip ${localTrip.id} is not allowed to be modified by current user; re-fetched." }
129129 updateLocalTrip(apiTripData, syncResult)
130130 }
131131 return
@@ -138,9 +138,8 @@ internal class TripsSynchronizationService constructor(
138138 val apiTripData = data.trip
139139 when (data.conflict_resolution) {
140140 ApiUpdateTripResponse .CONFLICT_RESOLUTION_IGNORED -> {
141- log() { " Trip ${localTrip.id} has conflict: ${data.conflict_resolution} ; ${data.conflict_info} " }
142- val conflictHandler = tripUpdateConflictHandler
143- val conflictResolution = when (conflictHandler) {
141+ log { " Trip ${localTrip.id} has conflict: ${data.conflict_resolution} ; ${data.conflict_info} " }
142+ val conflictResolution = when (val conflictHandler = tripUpdateConflictHandler) {
144143 null -> TripConflictResolution .USE_SERVER_VERSION
145144 else -> {
146145 val conflictInfo = TripConflictInfo (
@@ -153,7 +152,7 @@ internal class TripsSynchronizationService constructor(
153152 }
154153 }
155154
156- log() { " Trip ${localTrip.id} conflict resolution: $conflictResolution " }
155+ log { " Trip ${localTrip.id} conflict resolution: $conflictResolution " }
157156 when (conflictResolution) {
158157 TripConflictResolution .NO_ACTION -> {
159158 // do nothing and let user choose when he will use the app
@@ -177,7 +176,7 @@ internal class TripsSynchronizationService constructor(
177176 }
178177 }
179178 ApiUpdateTripResponse .CONFLICT_RESOLUTION_MERGED , ApiUpdateTripResponse .CONFLICT_RESOLUTION_OVERRODE -> {
180- log() { " Trip ${localTrip.id} has conflict: ${data.conflict_resolution} ; ${data.conflict_info} " }
179+ log { " Trip ${localTrip.id} has conflict: ${data.conflict_resolution} ; ${data.conflict_info} " }
181180 updateLocalTrip(apiTripData, syncResult)
182181 }
183182 ApiUpdateTripResponse .NO_CONFLICT -> {
0 commit comments