Merge pull request #6924 from AlphaWallet/skip-coingeck-dev-flag

[DEV] Skip CoinGecko API calls if development flag isAutoFetchingDisabled is true
pull/6925/head
Hwee-Boon Yar 1 year ago committed by GitHub
commit 4b27bca2a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/BaseCoinTickersFetcher.swift
  2. 4
      modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/CoinGecko/CoinGeckoTickerIdsFetcher.swift

@ -52,6 +52,10 @@ public class BaseCoinTickersFetcher: CoinTickersFetcher {
}
public func fetchTickers(for tokens: [TokenMappedToTicker], force: Bool = false, currency: Currency) {
//TODO pass in Config instance instead
if Config().development.isAutoFetchingDisabled {
return
}
//NOTE: cancel all previous requests for prev currency
inflightFetchers.removeAll { $0.currency != currency }
@ -103,6 +107,10 @@ public class BaseCoinTickersFetcher: CoinTickersFetcher {
/// Returns cached chart history if its not expired otherwise download a new version of history, if ticker id has found
public func fetchChartHistories(for token: TokenMappedToTicker, force: Bool, periods: [ChartHistoryPeriod], currency: Currency) async -> [ChartHistoryPeriod: ChartHistory] {
//TODO pass in an instance instead
if Config().development.isAutoFetchingDisabled {
return [:]
}
let unorderedHistoryToPeriods = await periods.asyncMap { await fetchChartHistory(force: force, period: $0, for: token, currency: currency) }
let historyToPeriods = unorderedHistoryToPeriods.reorder(by: periods)
var values: [ChartHistoryPeriod: ChartHistory] = [:]

@ -51,6 +51,10 @@ public final class SupportedTickerIdsFetcher: TickerIdsFetcher {
}
private func fetchSupportedTickerIds() async throws {
//TODO pass in Config instance instead
if Config().development.isAutoFetchingDisabled {
return
}
if let lastFetchingDate = config.tickerIdsLastFetchedDate, Date().timeIntervalSince(lastFetchingDate) <= pricesCacheLifetime, await storage.hasTickerIds() {
return
} else {

Loading…
Cancel
Save