From 059d10db0753f78ff495b76c7e40579e96b8d7d7 Mon Sep 17 00:00:00 2001 From: Ljupcho Nastevski Date: Thu, 11 Jun 2026 17:46:01 +0200 Subject: [PATCH] fetchUserReactions will only be called once, regardless of number of packs. --- TF1Sample/ReactionBarViewController.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/TF1Sample/ReactionBarViewController.swift b/TF1Sample/ReactionBarViewController.swift index 98f2796..1568a01 100644 --- a/TF1Sample/ReactionBarViewController.swift +++ b/TF1Sample/ReactionBarViewController.swift @@ -80,19 +80,25 @@ class ReactionViewController: UIViewController { } private func fetchReactionPacks(reactionPackIDs: [String]) { + let group = DispatchGroup() for packID in reactionPackIDs { - self.sdk.reaction.getReactionPackInfo(reactionPackID: packID) { result in + group.enter() + self.sdk.reaction.getReactionPackInfo(reactionPackID: packID) { [weak self] result in + defer { group.leave() } + guard let self = self else { return } switch result { case .success(let reactionPack): self.setupReactions(reactionPack: reactionPack) - self.fetchUserReactions() case .failure(let error): print("Error fetching reaction pack info: \(error)") } } } + group.notify(queue: .main) { [weak self] in + self?.fetchUserReactions() + } } - + @objc private func reactionButtonTapped(_ sender: UITapGestureRecognizer!) { if let reactionView = sender.view as? ReactionView { UIAccessibility.post(notification: .layoutChanged, argument: reactionView)