Skip to content

Commit

Permalink
AP-2214 Fix crash on monitorAdsSlotChangesTask
Browse files Browse the repository at this point in the history
(cherry picked from commit e10908a)
  • Loading branch information
gmagpayo authored and harryyan1238 committed Oct 29, 2024
1 parent 43e122d commit 499156c
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ final public class AdsSlotViewModel: ObservableObject {
self.appEnvironmentUseCase = appEnvironmentUseCase
}

deinit {
monitorAdsSlotChangesTask?.cancel()
monitorAdsSlotChangesTask = nil
}

// MARK: Setup
func setupSubscriptions() {
NotificationCenter.default
Expand Down Expand Up @@ -64,11 +59,9 @@ final public class AdsSlotViewModel: ObservableObject {

// MARK: Ads Slot changes
func monitorAdsSlotChanges() {
monitorAdsSlotChangesTask = Task { [weak self] in
guard let self else { return }
monitorAdsSlotChangesTask = Task { [weak self, adsSlotChangeStream] in
for await newAdsSlotConfig in adsSlotChangeStream.adsSlotStream {
if Task.isCancelled { return }
await updateAdsSlot(newAdsSlotConfig)
await self?.updateAdsSlot(newAdsSlotConfig)
}
}
}
Expand Down

0 comments on commit 499156c

Please sign in to comment.