Merge branch 'develop' into develop-replyToMessages

This commit is contained in:
2024-05-12 12:35:52 +00:00
16 changed files with 24 additions and 23 deletions

View File

@ -6,7 +6,7 @@ import 'getHolidaysResponse.dart';
class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
GetHolidaysCache({onUpdate, renew}) : super(RequestCache.cacheDay, onUpdate, renew: renew) {
start('MarianumMobile', 'state-holidays');
start('state-holidays');
}
@override

View File

@ -9,7 +9,7 @@ class GetChatCache extends RequestCache<GetChatResponse> {
String chatToken;
GetChatCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
start('MarianumMobile', 'nc-chat-$chatToken');
start('nc-chat-$chatToken');
}
@override

View File

@ -8,7 +8,7 @@ class GetParticipantsCache extends RequestCache<GetParticipantsResponse> {
String chatToken;
GetParticipantsCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
start('MarianumMobile', 'nc-chat-participants-$chatToken');
start('nc-chat-participants-$chatToken');
}
@override

View File

@ -8,7 +8,7 @@ import 'getRoomResponse.dart';
class GetRoomCache extends RequestCache<GetRoomResponse> {
GetRoomCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('MarianumMobile', 'nc-rooms');
start('nc-rooms');
}
@override

View File

@ -12,7 +12,7 @@ class ListFilesCache extends RequestCache<ListFilesResponse> {
ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) {
var bytes = utf8.encode('MarianumMobile-$path');
var cacheName = md5.convert(bytes).toString();
start('MarianumMobile', 'wd-folder-$cacheName');
start('wd-folder-$cacheName');
}
@override

View File

@ -6,7 +6,7 @@ import 'getBreakersResponse.dart';
class GetBreakersCache extends RequestCache<GetBreakersResponse> {
GetBreakersCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('MarianumMobile', 'breakers');
start('breakers');
}
@override

View File

@ -9,7 +9,7 @@ class GetCustomTimetableEventCache extends RequestCache<GetCustomTimetableEventR
GetCustomTimetableEventParams params;
GetCustomTimetableEventCache(this.params, {onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('MarianumMobile', 'customTimetableEvents');
start('customTimetableEvents');
}
@override

View File

@ -6,7 +6,7 @@ import 'getMessagesResponse.dart';
class GetMessagesCache extends RequestCache<GetMessagesResponse> {
GetMessagesCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('MarianumMobile', 'message');
start('message');
}
@override

View File

@ -11,6 +11,8 @@ abstract class RequestCache<T extends ApiResponse?> {
static const int cacheHour = 60 * 60;
static const int cacheDay = 60 * 60 * 24;
static String collection = 'MarianumMobile';
int maxCacheTime;
Function(T) onUpdate;
Function(Exception) onError;
@ -20,8 +22,8 @@ abstract class RequestCache<T extends ApiResponse?> {
static void ignore(Exception e) {}
Future<void> start(String file, String document) async {
var tableData = await Localstore.instance.collection(file).doc(document).get();
Future<void> start(String document) async {
var tableData = await Localstore.instance.collection(collection).doc(document).get();
if(tableData != null) {
onUpdate(onLocalData(tableData['json']));
}
@ -34,7 +36,7 @@ abstract class RequestCache<T extends ApiResponse?> {
var newValue = await onLoad();
onUpdate(newValue);
Localstore.instance.collection(file).doc(document).set({
Localstore.instance.collection(collection).doc(document).set({
'json': jsonEncode(newValue),
'lastupdate': DateTime.now().millisecondsSinceEpoch
});

View File

@ -6,7 +6,7 @@ import 'getHolidaysResponse.dart';
class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
GetHolidaysCache({onUpdate}) : super(RequestCache.cacheDay, onUpdate) {
start('MarianumMobile', 'wu-holidays');
start('wu-holidays');
}
@override

View File

@ -6,7 +6,7 @@ import 'getRoomsResponse.dart';
class GetRoomsCache extends RequestCache<GetRoomsResponse> {
GetRoomsCache({onUpdate}) : super(RequestCache.cacheHour, onUpdate) {
start('MarianumMobile', 'wu-rooms');
start('wu-rooms');
}
@override

View File

@ -6,7 +6,7 @@ import 'getSubjectsResponse.dart';
class GetSubjectsCache extends RequestCache<GetSubjectsResponse> {
GetSubjectsCache({onUpdate}) : super(RequestCache.cacheHour, onUpdate) {
start('MarianumMobile', 'wu-subjects');
start('wu-subjects');
}
@override

View File

@ -11,7 +11,7 @@ class GetTimetableCache extends RequestCache<GetTimetableResponse> {
int enddate;
GetTimetableCache({required onUpdate, onError, required this.startdate, required this.enddate}) : super(RequestCache.cacheMinute, onUpdate, onError: onError) {
start('MarianumMobile', 'wu-timetable-$startdate-$enddate');
start('wu-timetable-$startdate-$enddate');
}
@override