37 lines
876 B
Dart
37 lines
876 B
Dart
import 'dart:convert';
|
|
|
|
import '../../../requestCache.dart';
|
|
import 'getChat.dart';
|
|
import 'getChatParams.dart';
|
|
import 'getChatResponse.dart';
|
|
|
|
class GetChatCache extends RequestCache<GetChatResponse> {
|
|
String chatToken;
|
|
|
|
GetChatCache({
|
|
required void Function(GetChatResponse) onUpdate,
|
|
void Function(Exception)? onError,
|
|
required this.chatToken,
|
|
}) : super(
|
|
RequestCache.cacheNothing,
|
|
onUpdate,
|
|
onError: onError ?? RequestCache.ignore,
|
|
) {
|
|
start('nc-chat-$chatToken');
|
|
}
|
|
|
|
@override
|
|
Future<GetChatResponse> onLoad() => GetChat(
|
|
chatToken,
|
|
GetChatParams(
|
|
lookIntoFuture: GetChatParamsSwitch.off,
|
|
setReadMarker: GetChatParamsSwitch.on,
|
|
limit: 200,
|
|
)
|
|
).run();
|
|
|
|
@override
|
|
GetChatResponse onLocalData(String json) => GetChatResponse.fromJson(jsonDecode(json));
|
|
|
|
}
|