2022-01-28 13:36:43 -08:00
|
|
|
//
|
|
|
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the MIT License (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
|
//
|
|
|
|
|
// OperationQueue+Extensions.swift
|
|
|
|
|
//
|
|
|
|
|
// Created by Joshua Liebowitz on 1/20/22.
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
extension OperationQueue {
|
|
|
|
|
|
2022-12-21 08:13:41 -08:00
|
|
|
final func addCacheableOperation<T: CacheableNetworkOperation>(
|
|
|
|
|
with factory: CacheableNetworkOperationFactory<T>,
|
|
|
|
|
cacheStatus: CallbackCacheStatus
|
|
|
|
|
) {
|
2022-01-28 13:36:43 -08:00
|
|
|
switch cacheStatus {
|
|
|
|
|
case .firstCallbackAddedToList:
|
2022-12-21 08:13:41 -08:00
|
|
|
self.addOperation(factory.create())
|
2023-08-11 15:39:44 -07:00
|
|
|
|
|
|
|
|
Logger.verbose(Strings.network.enqueing_operation(factory.operationType,
|
|
|
|
|
cacheKey: factory.cacheKey))
|
|
|
|
|
|
2022-01-28 13:36:43 -08:00
|
|
|
case .addedToExistingInFlightList:
|
2023-07-27 09:16:49 +02:00
|
|
|
Logger.debug(
|
|
|
|
|
Strings.network.reusing_existing_request_for_operation(
|
|
|
|
|
T.self,
|
2023-10-25 20:24:23 -07:00
|
|
|
Logger.verboseLogsEnabled
|
2023-07-27 09:16:49 +02:00
|
|
|
? factory.cacheKey
|
|
|
|
|
: factory.cacheKey.prefix(15) + "…"
|
|
|
|
|
)
|
|
|
|
|
)
|
2022-01-28 13:36:43 -08:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|