You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces two key changes to improve the reliability of GraphQL
subscriptions when the app transitions between background and foreground
states:
1. New Hook: `useAppStateSubscription`
Added a reusable hook that listens to app state changes using React
Native’s AppState API. Executes a provided callback (onAppResume) when
the app returns to the foreground (e.g., after being backgrounded or
locked).
Useful for re-subscribing to real-time data or refetching stale content.
Example:
```js
AppStateSubscription(() => {
refetch({ id: chatRoom.id }, { fetchPolicy: 'store-and-network' })
})
```
2. Improved `useMessagesListSubscription` Hook
Enhanced the subscription lifecycle by subscribing and unsubscribing
based on the app's active/inactive state.
Ensures real-time updates are re-established automatically after app
resumes from the background or device unlock.
Prevents missed events or stale subscriptions due to suspended WebSocket
connections on iOS.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Introduced a new hook to detect when the app returns to the
foreground.
* **Improvements**
* Enhanced message subscription logic to better handle app state
transitions, providing more reliable updates when the app becomes active
or inactive.
* **Chores**
* Updated several internal dependencies across packages to their latest
versions.
* Incremented package versions and updated changelogs for improved
tracking.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Copy file name to clipboardExpand all lines: packages/components/CHANGELOG.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,19 @@
1
1
# @baseapp-frontend/components
2
2
3
+
## 1.2.8
4
+
5
+
### Minor Changes
6
+
7
+
- Improved the `useMessagesListSubscription` hook to subscribe and unsubscribe based on the application's state — e.g., when the app goes inactive and then returns to the foreground, or vice versa.
0 commit comments