Skip to content

Commit

Permalink
error handling and fixed logic with analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
tpkowastaken committed Oct 10, 2023
1 parent 85aaeab commit 4f4c6c4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
String? analyticsDisabled = await readData('disableAnalytics');
// know if this release is debug
if (kDebugMode) {
analyticsDisabled = '1';
}

if (analyticsDisabled != '1' || kDebugMode) {
if (analyticsDisabled != '1') {
analyticsEnabledGlobally = true;
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
Expand Down
20 changes: 12 additions & 8 deletions lib/methods_vars/icanteen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ Future<Canteen> initCanteen({bool hasToBeNew = false, String? url, String? usern
return Future.error('no internet');
}

canteenData = CanteenData(
username: username,
url: url,
uzivatel: await canteenInstance!.ziskejUzivatele(),
jidlaNaBurze: await canteenInstance!.ziskatBurzu(),
jidelnicky: jidelnicky,
pocetJidel: {currentDateWithoutTime: jidelnicky[currentDateWithoutTime]!.jidla.length},
);
try {
canteenData = CanteenData(
username: username,
url: url,
uzivatel: await canteenInstance!.ziskejUzivatele(),
jidlaNaBurze: await canteenInstance!.ziskatBurzu(),
jidelnicky: jidelnicky,
pocetJidel: {currentDateWithoutTime: jidelnicky[currentDateWithoutTime]!.jidla.length},
);
} catch (e) {
return Future.error('no internet');
}
smartPreIndexing(currentDateWithoutTime);

return canteenInstance!;
Expand Down
9 changes: 8 additions & 1 deletion lib/pages/jidelna.dart
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,14 @@ class _ObjednatJidloTlacitkoState extends State<ObjednatJidloTlacitko> {
),
);
});
Canteen canteen = await initCanteen();
late Canteen canteen;
try {
canteen = await initCanteen();
} catch (e) {
snackBarMessage('Nastala chyba při objednávání jídla: $e');
return;
}

switch (stavJidla) {
case StavJidla.neobjednano:
{
Expand Down

0 comments on commit 4f4c6c4

Please sign in to comment.