fixed warns and timetable thing again

This commit is contained in:
Kima 2023-09-18 20:22:42 +02:00
parent 6d7a21dc02
commit c4dc03f41d
4 changed files with 10 additions and 7 deletions

View File

@ -20,7 +20,6 @@ class Ad {
}); });
factory Ad.fromJson(Map json) { factory Ad.fromJson(Map json) {
print(json);
return Ad( return Ad(
title: json['title'] ?? 'Ad', title: json['title'] ?? 'Ad',
description: json['description'] ?? '', description: json['description'] ?? '',

View File

@ -26,6 +26,8 @@ class KretaClient {
late final UserProvider _user; late final UserProvider _user;
late final StatusProvider _status; late final StatusProvider _status;
bool _loginRefreshing = false;
KretaClient({ KretaClient({
this.accessToken, this.accessToken,
required SettingsProvider settings, required SettingsProvider settings,
@ -164,6 +166,9 @@ class KretaClient {
} }
Future<void> refreshLogin() async { Future<void> refreshLogin() async {
if (_loginRefreshing) return;
_loginRefreshing = true;
User? loginUser = _user.user; User? loginUser = _user.user;
if (loginUser == null) return; if (loginUser == null) return;
@ -215,5 +220,7 @@ class KretaClient {
} }
} }
} }
_loginRefreshing = false;
} }
} }

View File

@ -5,7 +5,7 @@ import 'package:filcnaplo_kreta_api/client/api.dart';
import 'package:filcnaplo_kreta_api/client/client.dart'; import 'package:filcnaplo_kreta_api/client/client.dart';
import 'package:filcnaplo_kreta_api/models/lesson.dart'; import 'package:filcnaplo_kreta_api/models/lesson.dart';
import 'package:filcnaplo_kreta_api/models/week.dart'; import 'package:filcnaplo_kreta_api/models/week.dart';
import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart';
class TimetableProvider with ChangeNotifier { class TimetableProvider with ChangeNotifier {
Map<Week, List<Lesson>> lessons = {}; Map<Week, List<Lesson>> lessons = {};
@ -69,14 +69,14 @@ class TimetableProvider with ChangeNotifier {
.getAPI(KretaAPI.timetable(iss, start: week.start, end: week.end)); .getAPI(KretaAPI.timetable(iss, start: week.start, end: week.end));
if (lessonsJson == null) { if (lessonsJson == null) {
if (kDebugMode) print('Cannot fetch Lessons for User ${user.id}');
return; return;
// throw "Cannot fetch Lessons for User ${user.id}"; // throw "Cannot fetch Lessons for User ${user.id}";
} else { } else {
List<Lesson> lessonsList = List<Lesson> lessonsList =
lessonsJson.map((e) => Lesson.fromJson(e)).toList(); lessonsJson.map((e) => Lesson.fromJson(e)).toList();
if (lessons.isEmpty) return;
lessons[week] = lessonsList; lessons[week] = lessonsList;
await store(); await store();

View File

@ -13,9 +13,6 @@ class AdTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print('geic');
print(ad);
return Padding( return Padding(
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0), padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
child: PanelButton( child: PanelButton(