Convert to pure Dart package, fix socket lifecycle bugs, upgrade deps#32
Open
Korpyc wants to merge 16 commits intoknocklabs:mainfrom
Open
Convert to pure Dart package, fix socket lifecycle bugs, upgrade deps#32Korpyc wants to merge 16 commits intoknocklabs:mainfrom
Korpyc wants to merge 16 commits intoknocklabs:mainfrom
Conversation
…package The SDK no longer fetches push notification tokens internally. Users should use firebase_messaging (or their preferred push provider) to obtain FCM/APNS tokens and pass them directly to registerTokenForChannel.
Bump freezed to v3, freezed_annotation to v3, phoenix_socket to v0.8, json_serializable to v6.13, and update SDK constraints. Regenerate all freezed, json_serializable, and mockito files.
…ck prefix Rename ApiResponse to KnockApiResponse, ApiClient to KnockApiClient, and ApiClientStatus to KnockApiClientStatus across all source and test files. Remove ApiRequestBuilder typedef in favor of inline type. Regenerate freezed and mockito files.
The socket getter used `??` instead of `??=`, so the built PhoenixSocket was never stored in `_socket`. This caused every access to create a new WebSocket connection, leaking sockets. It also meant `dispose()` could never clean up the socket since `_socket` was always null.
The "Channel deserializes", "User serializes", and "User mutations" test groups were copy-pasted from user_test.dart and tested User — not channels. These 7 duplicate tests are already covered in user_test.dart.
Move _eventController.close() from onCancel to the API disposal handler so the event stream lifecycle is tied to the API client, not the feed stream subscription. This prevents a zombie state where FeedClient methods fire HTTP requests but silently lose events after unsubscribe. Add isClosed guards on all _eventController.add() calls as a safety net for the async race in _fetch() — an HTTP response can arrive after the API client is disposed.
…eady Feed.initialState() now uses NetworkStatus.initial instead of ready, allowing consumers to differentiate between "haven't fetched yet" (show skeleton/placeholder) and "fetched successfully" (show content). The JSON default remains NetworkStatus.ready since deserialized API responses have already been fetched. Generated files need regeneration via build_runner.
- Close connected socket before dispose to send proper WebSocket close frame - Close _status StreamController to prevent resource leak - Add explicit FeedClient.dispose() for deterministic cleanup - Add defensive cancel before re-subscribing to channel messages - Guard _onNewMessageReceived against post-disposal processing
leave() is async (waits for server ack before removing from cache), so quick unsubscribe/re-subscribe finds the stale cached channel with _joinedOnce = true. Adding immediate removeChannel() after leave() ensures the cache is cleared synchronously while still sending phx_leave to the server.
The previous version (^2.1.0) used deprecated Android Gradle Plugin APIs incompatible with Java 17. Upgraded to ^5.0.1 which supports modern AGP and Java 17. Updated timezone access to use the new TZDateTime.identifier API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've been waiting for almost two years, but no-one is fixing official package, so, I've made, hope you would like it. Because without those changes can't be used for production.
Yes, there are breaking changes, but as a result of those changes it's now work stable and reliable when you want re-init feed with different options(to show user only unread messages vs all in general tab or switch to another tenant id).
Summary
Push token retrieval is now the consumer's responsibility via firebase_messaging or similar.
ApiError -> KnockApiException) to avoid naming collisions