Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(connection): refresh network status after app activation #5597

ClosedDominicVonk(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/5597/headopened View on GitHub

Showing 8 changed files with 157 additions and 21 deletions (loading 6).

x
0 of 8 viewed, 8 left
2 additions and 21 deletionsapps/mobile/src/connection/platform.tsModified
View file
@@ -56,31 +56,12 @@
changes: Stream.callback((queue) =>
Effect.acquireRelease(
Effect.sync(() => {
- let active = true;
const networkSubscription = Network.addNetworkStateListener((state) => {
Queue.offerUnsafe(queue, networkStatus(state));
});
- const appStateSubscription = AppState.addEventListener("change", (state) => {
- if (state !== "active") {
- return;
- }
- void Network.getNetworkStateAsync()
- .then((current) => {
- if (active) {
- Queue.offerUnsafe(queue, networkStatus(current));
- }
- })
- .catch(() => undefined);
- });
- return {
- close: () => {
- active = false;
- networkSubscription.remove();
- appStateSubscription.remove();
- },
- };
+ return networkSubscription;
}),
- ({ close }) => Effect.sync(close),