From f8d125bec09a5ccf4ce634f2bec03211267744a9 Mon Sep 17 00:00:00 2001 From: Joe Szymanski Date: Fri, 8 Dec 2017 10:46:07 -0500 Subject: [PATCH] Update unsubscribe to remove subscriptions from the tracked subscriptions list --- Sources/ParseLiveQuery/Client.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/ParseLiveQuery/Client.swift b/Sources/ParseLiveQuery/Client.swift index c46c4eb1..da7a963c 100644 --- a/Sources/ParseLiveQuery/Client.swift +++ b/Sources/ParseLiveQuery/Client.swift @@ -206,11 +206,15 @@ extension Client { } func unsubscribe(matching matcher: @escaping (SubscriptionRecord) -> Bool) { - subscriptions.filter { - matcher($0) - }.forEach { - _ = sendOperationAsync(.unsubscribe(requestId: $0.requestId)) + var temp = [SubscriptionRecord]() + subscriptions.forEach { + if matcher($0) { + _ = sendOperationAsync(.unsubscribe(requestId: $0.requestId)) + } else { + temp.append($0) + } } + subscriptions = temp } }