Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan committed Sep 15, 2021
2 parents afb0977 + 8b70261 commit 120e6d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ fun List<PurchaseHistoryRecord>.toPurchaseHistoryList(): List<PurchaseHistory> =
RemoveAdType.getBySku(purchaseHistoryRecord.skus.firstOrNull())?.let {
PurchaseHistory(purchaseHistoryRecord.purchaseTime, it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch

private const val NUMBER_OF_REFRESH_IN_DAY = 3

class ApiController(
private val apiRepository: ApiRepository,
private val offlineRatesRepository: OfflineRatesRepository
Expand All @@ -26,7 +28,7 @@ class ApiController(
kermit.d { "refreshing" }
updateCurrencies()

delay(DAY)
delay(DAY / NUMBER_OF_REFRESH_IN_DAY)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ class BillingManager(private val context: Context) :
fun acknowledgePurchase() {
acknowledgePurchaseParams?.let {
billingClient.acknowledgePurchase(it, this)
} ?: run {
scope.launch {
_effect.emit(BillingEffect.SuccessfulPurchase)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import com.github.mustafaozhan.ccc.client.model.PurchaseHistory
import com.github.mustafaozhan.ccc.client.model.RemoveAdData
import com.github.mustafaozhan.ccc.client.model.RemoveAdType
import com.github.mustafaozhan.ccc.client.util.calculateAdRewardEnd
import com.github.mustafaozhan.ccc.client.util.isRewardExpired
import com.github.mustafaozhan.ccc.client.util.launchIgnored
import com.github.mustafaozhan.ccc.common.settings.SettingsRepository
import com.github.mustafaozhan.ccc.common.util.nowAsLong
import com.github.mustafaozhan.logmob.kermit
import com.github.mustafaozhan.scopemob.whether
import com.github.mustafaozhan.scopemob.whetherNot
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
Expand Down Expand Up @@ -50,16 +52,18 @@ class AdRemoveViewModel(
}
}


fun restorePurchase(purchaseHistoryList: List<PurchaseHistory>) = purchaseHistoryList
.maxByOrNull {
it.purchaseType.calculateAdRewardEnd(it.purchaseDate)
}?.whether { historyRecord ->
RemoveAdType.getSkuList().any { it == historyRecord.purchaseType.data.skuId }
}?.whether { it.purchaseDate > settingsRepository.adFreeEndDate }
?.apply {
updateAddFreeDate(RemoveAdType.getBySku(purchaseType.data.skuId), this.purchaseDate)
}?.whether { purchaseHistory ->
RemoveAdType.getSkuList().any { it == purchaseHistory.purchaseType.data.skuId }
}?.whether {
purchaseDate > settingsRepository.adFreeEndDate
}?.whetherNot {
purchaseType.calculateAdRewardEnd(purchaseDate).isRewardExpired()
}?.apply {
clientScope.launch { _effect.emit(AdRemoveEffect.AlreadyAdFree) }
updateAddFreeDate(RemoveAdType.getBySku(purchaseType.data.skuId), this.purchaseDate)
}

fun showLoadingView(shouldShow: Boolean) {
Expand Down

0 comments on commit 120e6d0

Please sign in to comment.