Refresh bridge capabilities after account sync
This commit is contained in:
parent
8ab640bc5a
commit
135772015f
@ -100,6 +100,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
identifier: identifier,
|
||||
password: _accountPasswordController.text,
|
||||
);
|
||||
await _refreshBridgeCapabilities();
|
||||
} finally {
|
||||
_accountPasswordController.clear();
|
||||
}
|
||||
@ -110,6 +111,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
await widget.controller.settingsController.syncAccountSettings(
|
||||
baseUrl: _accountBaseUrlController.text.trim(),
|
||||
);
|
||||
await _refreshBridgeCapabilities();
|
||||
}
|
||||
|
||||
Future<void> _verifyAccountMfa(SettingsSnapshot settings) async {
|
||||
@ -119,11 +121,29 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
baseUrl: _accountBaseUrlController.text.trim(),
|
||||
code: _accountMfaCodeController.text.trim(),
|
||||
);
|
||||
await _refreshBridgeCapabilities();
|
||||
} finally {
|
||||
_accountMfaCodeController.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _refreshBridgeCapabilities() async {
|
||||
final dynamic controller = widget.controller;
|
||||
try {
|
||||
await controller.refreshSingleAgentCapabilitiesInternal(
|
||||
forceRefresh: true,
|
||||
);
|
||||
} catch (_) {
|
||||
// Best effort only. Account sync should still succeed if runtime refresh
|
||||
// is temporarily unavailable.
|
||||
}
|
||||
try {
|
||||
await controller.refreshAcpCapabilitiesInternal(forceRefresh: true);
|
||||
} catch (_) {
|
||||
// Best effort only. Runtime capabilities can be retried later.
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _cancelAccountMfa() async {
|
||||
await widget.controller.settingsController.cancelAccountMfaChallenge();
|
||||
_accountPasswordController.clear();
|
||||
|
||||
@ -138,6 +138,10 @@ void main() {
|
||||
await controller.settingsController.syncAccountSettings(
|
||||
baseUrl: controller.settings.accountBaseUrl,
|
||||
);
|
||||
await controller.refreshSingleAgentCapabilitiesInternal(
|
||||
forceRefresh: true,
|
||||
);
|
||||
await controller.refreshAcpCapabilitiesInternal(forceRefresh: true);
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
@ -148,6 +152,8 @@ void main() {
|
||||
controller.settingsController.syncedBaseUrls,
|
||||
isNot(contains('https://draft-accounts.svc.plus')),
|
||||
);
|
||||
expect(controller.singleAgentRefreshCount, 1);
|
||||
expect(controller.acpRefreshCount, 1);
|
||||
|
||||
await controller.settingsController.logoutAccount();
|
||||
await tester.pump();
|
||||
@ -268,6 +274,8 @@ class _FakeSettingsPageController extends ChangeNotifier
|
||||
final _FakeSettingsController settingsController;
|
||||
|
||||
SettingsSnapshot _settingsDraft;
|
||||
int singleAgentRefreshCount = 0;
|
||||
int acpRefreshCount = 0;
|
||||
|
||||
@override
|
||||
SettingsSnapshot get settings => settingsController.snapshot;
|
||||
@ -280,6 +288,18 @@ class _FakeSettingsPageController extends ChangeNotifier
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> refreshSingleAgentCapabilitiesInternal({
|
||||
bool forceRefresh = false,
|
||||
}) async {
|
||||
singleAgentRefreshCount += 1;
|
||||
}
|
||||
|
||||
Future<void> refreshAcpCapabilitiesInternal({
|
||||
bool forceRefresh = false,
|
||||
}) async {
|
||||
acpRefreshCount += 1;
|
||||
}
|
||||
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
@ -290,6 +310,13 @@ class _FakeSettingsController extends SettingsController {
|
||||
|
||||
final List<String> syncedBaseUrls = <String>[];
|
||||
|
||||
@override
|
||||
Future<void> saveSnapshot(SettingsSnapshot snapshot) async {
|
||||
snapshotInternal = snapshot;
|
||||
lastSnapshotJsonInternal = snapshot.toJsonString();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void seedSignedOutState(SettingsSnapshot settings) {
|
||||
snapshotInternal = settings.copyWith(accountLocalMode: true);
|
||||
lastSnapshotJsonInternal = snapshotInternal.toJsonString();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user