api and storage restructure
This commit is contained in:
@@ -1,36 +1,26 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../../requestCache.dart';
|
||||
import 'getChat.dart';
|
||||
import 'getChatParams.dart';
|
||||
import 'getChatResponse.dart';
|
||||
|
||||
class GetChatCache extends RequestCache<GetChatResponse> {
|
||||
String chatToken;
|
||||
|
||||
class GetChatCache extends SimpleCache<GetChatResponse> {
|
||||
GetChatCache({
|
||||
required void Function(GetChatResponse) onUpdate,
|
||||
void Function(Exception)? onError,
|
||||
required this.chatToken,
|
||||
super.onError,
|
||||
required String chatToken,
|
||||
}) : super(
|
||||
RequestCache.cacheNothing,
|
||||
onUpdate,
|
||||
onError: onError ?? RequestCache.ignore,
|
||||
cacheTime: RequestCache.cacheNothing,
|
||||
loader: () => GetChat(
|
||||
chatToken,
|
||||
GetChatParams(
|
||||
lookIntoFuture: GetChatParamsSwitch.off,
|
||||
setReadMarker: GetChatParamsSwitch.on,
|
||||
limit: 200,
|
||||
),
|
||||
).run(),
|
||||
fromJson: GetChatResponse.fromJson,
|
||||
onUpdate: onUpdate,
|
||||
) {
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user