removed old marianum message structure
This commit is contained in:
parent
8968e53e5c
commit
8ff993bf19
@ -1,14 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../mhslApi.dart';
|
||||
import 'getMessagesResponse.dart';
|
||||
|
||||
class GetMessages extends MhslApi<GetMessagesResponse> {
|
||||
GetMessages() : super('message/messages.json');
|
||||
@override
|
||||
GetMessagesResponse assemble(String raw) => GetMessagesResponse.fromJson(jsonDecode(raw));
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) => http.get(uri);
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../../requestCache.dart';
|
||||
import 'getMessages.dart';
|
||||
import 'getMessagesResponse.dart';
|
||||
|
||||
class GetMessagesCache extends RequestCache<GetMessagesResponse> {
|
||||
GetMessagesCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
|
||||
start('message');
|
||||
}
|
||||
|
||||
@override
|
||||
GetMessagesResponse onLocalData(String json) => GetMessagesResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetMessagesResponse> onLoad() => GetMessages().run();
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../../apiResponse.dart';
|
||||
|
||||
part 'getMessagesResponse.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetMessagesResponse extends ApiResponse {
|
||||
String base;
|
||||
Set<GetMessagesResponseObject> messages;
|
||||
|
||||
GetMessagesResponse(this.base, this.messages);
|
||||
|
||||
factory GetMessagesResponse.fromJson(Map<String, dynamic> json) => _$GetMessagesResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetMessagesResponseToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetMessagesResponseObject {
|
||||
String name;
|
||||
String date;
|
||||
String url;
|
||||
|
||||
GetMessagesResponseObject(this.name, this.date, this.url);
|
||||
|
||||
factory GetMessagesResponseObject.fromJson(Map<String, dynamic> json) => _$GetMessagesResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetMessagesResponseObjectToJson(this);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'getMessagesResponse.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GetMessagesResponse _$GetMessagesResponseFromJson(Map<String, dynamic> json) =>
|
||||
GetMessagesResponse(
|
||||
json['base'] as String,
|
||||
(json['messages'] as List<dynamic>)
|
||||
.map((e) =>
|
||||
GetMessagesResponseObject.fromJson(e as Map<String, dynamic>))
|
||||
.toSet(),
|
||||
)..headers = (json['headers'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, e as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetMessagesResponseToJson(GetMessagesResponse instance) {
|
||||
final val = <String, dynamic>{};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('headers', instance.headers);
|
||||
val['base'] = instance.base;
|
||||
val['messages'] = instance.messages.map((e) => e.toJson()).toList();
|
||||
return val;
|
||||
}
|
||||
|
||||
GetMessagesResponseObject _$GetMessagesResponseObjectFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
GetMessagesResponseObject(
|
||||
json['name'] as String,
|
||||
json['date'] as String,
|
||||
json['url'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetMessagesResponseObjectToJson(
|
||||
GetMessagesResponseObject instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'date': instance.date,
|
||||
'url': instance.url,
|
||||
};
|
@ -25,7 +25,6 @@ import 'model/chatList/chatListProps.dart';
|
||||
import 'model/chatList/chatProps.dart';
|
||||
import 'model/files/filesProps.dart';
|
||||
import 'model/holidays/holidaysProps.dart';
|
||||
import 'model/message/messageProps.dart';
|
||||
import 'model/timetable/timetableProps.dart';
|
||||
import 'storage/base/settingsProvider.dart';
|
||||
import 'theming/darkAppTheme.dart';
|
||||
@ -71,7 +70,6 @@ Future<void> main() async {
|
||||
ChangeNotifierProvider(create: (context) => ChatProps()),
|
||||
ChangeNotifierProvider(create: (context) => FilesProps()),
|
||||
|
||||
ChangeNotifierProvider(create: (context) => MessageProps()),
|
||||
ChangeNotifierProvider(create: (context) => HolidaysProps()),
|
||||
],
|
||||
child: const Main(),
|
||||
|
@ -1,25 +0,0 @@
|
||||
|
||||
import '../../api/apiResponse.dart';
|
||||
import '../../api/mhsl/message/getMessages/getMessagesCache.dart';
|
||||
import '../../api/mhsl/message/getMessages/getMessagesResponse.dart';
|
||||
import '../dataHolder.dart';
|
||||
|
||||
class MessageProps extends DataHolder {
|
||||
GetMessagesResponse? _getMessagesResponse;
|
||||
GetMessagesResponse get getMessagesResponse => _getMessagesResponse!;
|
||||
|
||||
@override
|
||||
List<ApiResponse?> properties() => [_getMessagesResponse];
|
||||
|
||||
@override
|
||||
void run({renew}) {
|
||||
GetMessagesCache(
|
||||
renew: renew,
|
||||
onUpdate: (GetMessagesResponse data) => {
|
||||
_getMessagesResponse = data,
|
||||
notifyListeners(),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user