Change if-elseif to case switch for test schools

This commit is contained in:
Pearoo 2024-03-21 17:47:20 +01:00
parent 14bcb62184
commit a805d8292f

View File

@ -83,7 +83,10 @@ Future loginAPI({
}
// if institute matches one of test things do test login
if (instituteCode == 'refilc-test-sweden') {
switch (instituteCode) {
// by using a switch statement we are saving a whopping 0.0000001 seconds
// (actually it just makes it easier to add more test schools later on)
case 'refilc-test-sweden':
School school = School(
city: "Stockholm",
instituteCode: "refilc-test-sweden",
@ -91,7 +94,8 @@ Future loginAPI({
);
await testLogin(school);
} else if (instituteCode == 'refilc-test-spain') {
break;
case 'refilc-test-spain':
School school = School(
city: "Madrid",
instituteCode: "refilc-test-spain",
@ -99,7 +103,8 @@ Future loginAPI({
);
await testLogin(school);
} else {
break;
default:
// normal login from here
Provider.of<KretaClient>(context, listen: false).userAgent =
Provider.of<SettingsProvider>(context, listen: false).config.userAgent;
@ -185,6 +190,7 @@ Future loginAPI({
}
}
}
break;
}
return LoginState.failed;