Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up unecessary subscriptions in PagedRelaySubscription #1205

Merged

Conversation

mplorentz
Copy link
Member

Issues covered

This was something I noticed and fixed while debugging #1192, but I put it in a separate PR.

Description

We weren't clearing out old subscriptions from the PagedRelaySubscription.pagedSubscriptionID array. The actual websocket subscriptions were being closed, but we were keeping references to the RelaySubscription objects around unnecessarily. It wasn't hurting anything necessarily but this cleans them up.

How to test

You can put Log.debug("pagedSubscriptionIDs count: \(pagedSubscriptionIDs.count)") at the end of the PagedRelaySubscription.loadMore() function before this PR and watch the number climb the more you scroll the home feed. After it should remain equal to the number of relays you have in your relay list.

}
}

subscriptionsToRemove.forEach { subscription in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like when the solution involves using the right data structure. Given that we are already switching to a Set, how about making subscriptionsToRemove a Set of IDs, so that this line I'm commenting can be just pagedSubscriptionIDs.subtract(subscriptionsToRemove)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, great idea!

@mplorentz mplorentz requested a review from martindsq June 3, 2024 18:01
@mplorentz mplorentz added this pull request to the merge queue Jun 4, 2024
Merged via the queue into main with commit 636b555 Jun 4, 2024
5 checks passed
@mplorentz mplorentz deleted the clean-up-pagedrelaysubscription-pagedsubscriptionids branch June 4, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants