Commit Graph

47 Commits

Author SHA1 Message Date
Roland Geider
9333afd38e Keep the session while the iOS keychain is locked
Closes #1417
2026-11-12 20:30:22 +01:00
Roland Geider
21da74fe01 Merge master into feature/gym-notifications 2026-10-29 21:03:02 +01:00
Roland Geider
999ac4b546 Drop the stored workout progress with the local data 2026-10-26 22:39:19 +01:00
Roland Geider
e1ad69afb1 Default debug builds to the test server on a fresh install 2026-10-25 14:23:35 +01:00
Roland Geider
104b4ee71b Treat a pre-release server as below its release 2026-09-27 01:06:32 +02:00
Roland Geider
233a3c8312 Regenerate code for freezed 4 and drop field @override 2026-09-26 23:18:36 +02:00
Roland Geider
1b121ff22c Merge branch 'pr-1332-probe' into feat/upgrade-flutter-1316 2026-09-26 22:08:32 +02:00
Roland Geider
31783745f2 Ask the probe for a body before treating a 403 as a rejection 2026-09-06 16:00:57 +02:00
Roland Geider
25e3e6485e Anchor the access token lifetime to the local clock 2026-09-06 15:51:18 +02:00
Roland Geider
c46763ffd0 Renew an expired access token before the first-time probe 2026-09-06 15:51:18 +02:00
Roland Geider
e701519d8f Keep the session through a failed or transient token refresh 2026-09-06 15:48:13 +02:00
Roland Geider
48dc290224 Renew an expired token instead of dropping the upload 2026-09-06 15:48:13 +02:00
Roland Geider
5c52b3481b Improve semver checks for min server version 2026-09-06 15:26:10 +02:00
pankaj-basnet
f7930ce68b fix: remove material_ui imports where not needed 2026-09-01 21:12:14 +05:45
Roland Geider
9e9f2b1fbf Time out hanging token fetches instead of freezing the sync 2026-08-28 10:48:22 +02:00
Roland Geider
deddaf7a48 Merge branch 'master' into feature/release-2.7 2026-08-26 13:52:53 +02:00
Roland Geider
db054ca4c1 Trim and consolidate more translation strings 2026-08-26 13:41:16 +02:00
Roland Geider
b6aa38c219 Log the reason for the connection 2026-08-26 12:11:52 +02:00
Roland Geider
6096eadb37 Split up auth provider 2026-08-25 14:51:08 +02:00
Roland Geider
f6ff275526 Replace the revalidation listeners instead of stacking them 2026-08-25 14:04:01 +02:00
Roland Geider
6f23e492bb Pass the 401 through when a refresh could not deliver a new token 2026-08-25 13:32:51 +02:00
Roland Geider
ed65a0e42c Discard a token refresh that outlives its session 2026-08-24 22:56:29 +02:00
Roland Geider
185e5341ba Merge remote-tracking branch 'origin/master' into feature/release-2.7 2026-08-21 22:37:02 +02:00
Roland Geider
2c26c93d68 Merge remote-tracking branch 'origin/master' into fix/build-phase-ui-side-effects 2026-08-21 18:01:56 +02:00
Roland Geider
de758b5dfa Final fixes 2026-08-21 17:42:28 +02:00
Roland Geider
2a596349df Report reachability from the bottom of the client stack 2026-08-21 16:04:52 +02:00
Roland Geider
a0fd3ad0e2 Make one provider the single Connectivity consumer 2026-08-21 15:29:52 +02:00
Roland Geider
9cb25ad538 Guard the probe pass against a mid-flight invalidation 2026-08-21 15:10:01 +02:00
Roland Geider
94d8352c3d Arm the sync watchdog inside connectPowerSync 2026-08-21 15:00:13 +02:00
Roland Geider
74fbb9db95 Coalesce overlapping reachability probes 2026-08-21 14:51:09 +02:00
Ben Tucker
fe33f693a8 fix(core): make UI side effects and provider reads safe during build
Errors handled while the widget tree is building crashed or wedged the
app in three related ways:

- FlutterError.onError showed dialogs and snackbars synchronously.
  Pushing a route mid-build trips the navigator's !_debugLocked
  assertion, and because the one-dialog guard was set before showDialog
  threw, its release never attached: every later error dialog was then
  silently suppressed while nothing was on screen, leaving a blank,
  unresponsive app until restart. Snackbars crashed outright via the
  messenger's setState.
- The sync status and barcode dialogs did ref.read inside their route
  builders, which run during build. With the provider chain dirty (any
  token refresh dirties wgerBase -> auth), the read flushed it there and
  Riverpod scheduled a scope refresh mid-build. The barcode builder also
  created its search future inline, re-firing the search on every dialog
  rebuild.
- Provider create bodies that widgets watch during build read providers
  synchronously: the dashboard's routine hydration chain crashed on cold
  start right after a token refresh, and TrophyStateNotifier.build()
  has the same shape in the post-login window, where invalidation order
  left networkStatusProvider dirty while its dependents rebuilt.

lib/core/build_safety.dart adds the two idioms as helpers: runAfterFrame
defers UI side effects past the build phase, yieldPastBuild yields
provider create bodies past their synchronous phase (a microtask, not a
timer, since widget tests assert !timersPending at teardown). The error
dialog guard is released when the context is gone or the push fails, the
snackbar helpers re-resolve the messenger inside the callback, the
dialog builders snapshot their providers in the tap handler, and
post-login invalidation runs leaf-first. Regression tests cover each
shape.
2026-08-16 17:29:43 -05:00
Roland Geider
9a97202dd4 Cleanup 2026-08-14 17:37:47 +02:00
Roland Geider
23291513dc Fix logger name 2026-08-14 16:10:20 +02:00
Roland Geider
6e5555fe2f Mark the probe as in flight before the connectivity lookup 2026-08-14 16:09:32 +02:00
Roland Geider
a986091ab8 Make the network status follow real traffic instead of a 1s probe 2026-08-14 15:20:45 +02:00
Roland Geider
5e332e18aa Connect PowerSync on the adapter state, not on the reachability probe 2026-08-14 14:52:49 +02:00
Roland Geider
4fd83ce202 Merge PR #1309 (remove old API token exchange) for 2.7 integration testing
# Conflicts:
#	lib/core/network/network_provider.g.dart
#	lib/database/powersync/powersync.g.dart
2026-08-13 14:10:24 +02:00
Ben Tucker
57fe12677c fix(auth): do not await PowerSync disconnect during session clear
A rejected refresh token runs clearSessionOnly inside the single-flight
refresh future. PowerSync's disconnect can block on an in-flight sync
fetch that is itself awaiting that same refresh future through
AuthHttpClient's pre-emptive refresh, closing a three-party cycle
(refresh -> disconnect -> sync fetch -> refresh) that permanently wedges
every authenticated request behind the never-completing refresh. The
session-expired message never appears because it is sequenced after the
hanging call, and an app restart re-triggers the same rejected refresh
during startup revalidation, so the deadlock re-forms immediately.

On the keep-data path the DB is not wiped, so there is no re-attach race
to guard against; the disconnect is only a courtesy stop of the sync
loop and is now fire-and-forget. The wipe path (explicit logout) keeps
its ordering. The disconnect hook is injectable for tests because
PowerSyncDatabase is a base class that cannot be faked.
2026-08-12 19:08:24 -05:00
Roland Geider
fb05d1e872 Log network state changes and the sync connection 2026-08-09 22:43:40 +02:00
Roland Geider
7b6306703b Remove old API token exchange 2026-08-09 21:04:49 +02:00
Roland Geider
914e9ac575 Surface involuntary logouts and revalidate the session on app resume
This makes it obvious why users are redirected to the auth screen, since the
snackbar could be easily missed.

See #1265
2026-07-30 15:47:04 +02:00
Roland Geider
b732b619c2 Describe updated behaviour in comments 2026-07-30 15:02:04 +02:00
Roland Geider
3a57479585 Scope the self-signed setting to one host and apply without a restart 2026-07-30 13:57:41 +02:00
Roland Geider
3ee512fd6c More intelligent powersync service URL handling
When the server-provided powersync URL is not reachable, try using $server-url/ps/.
This should help with self-hosted instances where SITE_URL points to localhost
or other similar misconfigurations

See https://github.com/wger-project/wger/issues/2432
2026-07-28 15:06:34 +02:00
Roland Geider
ed623f9108 Improve PowerSync sync diagnostics and token expiry handling 2026-07-23 13:58:06 +02:00
Roland Geider
938001b152 Optimistically set the online status
This avoids having the app register as "offline" after bringing it back from
the background
2026-07-17 21:31:29 +02:00
Roland Geider
60c9f67282 Move shared infra to lib/core/ 2026-07-01 20:28:06 +02:00