dart format

This commit is contained in:
2026-05-08 20:12:40 +02:00
parent 9e139b5704
commit 3b8da1d3d6
295 changed files with 6404 additions and 4161 deletions
@@ -11,7 +11,8 @@ class GetChat extends TalkApi<GetChatResponse> {
String chatToken;
GetChatParams params;
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
GetChat(this.chatToken, this.params)
: super('v1/chat/$chatToken', null, getParameters: params.toJson());
@override
GetChatResponse assemble(String raw) {
@@ -20,6 +21,9 @@ class GetChat extends TalkApi<GetChatResponse> {
}
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
Future<Response> request(
Uri uri,
Object? body,
Map<String, String>? headers,
) => http.get(uri, headers: headers);
}
@@ -10,17 +10,17 @@ class GetChatCache extends SimpleCache<GetChatResponse> {
super.onError,
required String chatToken,
}) : super(
cacheTime: RequestCache.cacheNothing,
loader: () => GetChat(
chatToken,
GetChatParams(
lookIntoFuture: GetChatParamsSwitch.off,
setReadMarker: GetChatParamsSwitch.on,
limit: 200,
),
).run(),
fromJson: GetChatResponse.fromJson,
) {
cacheTime: RequestCache.cacheNothing,
loader: () => GetChat(
chatToken,
GetChatParams(
lookIntoFuture: GetChatParamsSwitch.off,
setReadMarker: GetChatParamsSwitch.on,
limit: 200,
),
).run(),
fromJson: GetChatResponse.fromJson,
) {
start('nc-chat-$chatToken');
}
}
@@ -15,20 +15,23 @@ class GetChatParams extends ApiParams {
GetChatParamsSwitch? includeLastKnown;
GetChatParams({
required this.lookIntoFuture,
this.limit,
this.lastKnownMessageId,
this.lastCommonReadId,
this.timeout,
this.setReadMarker,
this.includeLastKnown
required this.lookIntoFuture,
this.limit,
this.lastKnownMessageId,
this.lastCommonReadId,
this.timeout,
this.setReadMarker,
this.includeLastKnown,
});
factory GetChatParams.fromJson(Map<String, dynamic> json) => _$GetChatParamsFromJson(json);
factory GetChatParams.fromJson(Map<String, dynamic> json) =>
_$GetChatParamsFromJson(json);
Map<String, dynamic> toJson() => _$GetChatParamsToJson(this);
}
enum GetChatParamsSwitch {
@JsonValue(1) on,
@JsonValue(0) off,
@JsonValue(1)
on,
@JsonValue(0)
off,
}
@@ -12,7 +12,8 @@ class GetChatResponse extends ApiResponse {
GetChatResponse(this.data);
factory GetChatResponse.fromJson(Map<String, dynamic> json) => _$GetChatResponseFromJson(json);
factory GetChatResponse.fromJson(Map<String, dynamic> json) =>
_$GetChatResponseFromJson(json);
Map<String, dynamic> toJson() => _$GetChatResponseToJson(this);
List<GetChatResponseObject> sortByTimestamp() {
@@ -37,28 +38,30 @@ class GetChatResponseObject {
String message;
Map<String, int>? reactions;
List<String>? reactionsSelf;
@JsonKey(fromJson: _fromJson) Map<String, RichObjectString>? messageParameters;
@JsonKey(fromJson: _fromJson)
Map<String, RichObjectString>? messageParameters;
GetChatResponseObject? parent;
GetChatResponseObject(
this.id,
this.token,
this.actorType,
this.actorId,
this.actorDisplayName,
this.timestamp,
this.systemMessage,
this.messageType,
this.isReplyable,
this.referenceId,
this.message,
this.messageParameters,
this.reactions,
this.reactionsSelf,
this.parent,
this.id,
this.token,
this.actorType,
this.actorId,
this.actorDisplayName,
this.timestamp,
this.systemMessage,
this.messageType,
this.isReplyable,
this.referenceId,
this.message,
this.messageParameters,
this.reactions,
this.reactionsSelf,
this.parent,
);
factory GetChatResponseObject.fromJson(Map<String, dynamic> json) => _$GetChatResponseObjectFromJson(json);
factory GetChatResponseObject.fromJson(Map<String, dynamic> json) =>
_$GetChatResponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetChatResponseObjectToJson(this);
static GetChatResponseObject getDateDummy(int timestamp) {
@@ -66,7 +69,8 @@ class GetChatResponseObject {
return getTextDummy(elementDate.formatDate());
}
static GetChatResponseObject getTextDummy(String text) => GetChatResponseObject(
static GetChatResponseObject getTextDummy(String text) =>
GetChatResponseObject(
0,
'',
GetRoomResponseObjectMessageActorType.user,
@@ -82,15 +86,17 @@ class GetChatResponseObject {
null,
null,
null,
);
);
}
Map<String, RichObjectString>? _fromJson(dynamic json) {
if (json is Map<String, dynamic>) {
final data = <String, RichObjectString>{};
for (final element in json.keys) {
data.putIfAbsent(element, () => RichObjectString.fromJson(json[element] as Map<String, dynamic>));
data.putIfAbsent(
element,
() => RichObjectString.fromJson(json[element] as Map<String, dynamic>),
);
}
return data;
}
@@ -109,17 +115,26 @@ class RichObjectString {
RichObjectString(this.type, this.id, this.name, this.path, this.link);
factory RichObjectString.fromJson(Map<String, dynamic> json) => _$RichObjectStringFromJson(json);
factory RichObjectString.fromJson(Map<String, dynamic> json) =>
_$RichObjectStringFromJson(json);
Map<String, dynamic> toJson() => _$RichObjectStringToJson(this);
}
enum RichObjectStringObjectType {
@JsonValue('user') user,
@JsonValue('group') group,
@JsonValue('file') file,
@JsonValue('guest') guest,
@JsonValue('highlight') highlight,
@JsonValue('talk-poll') talkPoll,
@JsonValue('geo-location') geoLocation,
@JsonValue('call') call,
@JsonValue('user')
user,
@JsonValue('group')
group,
@JsonValue('file')
file,
@JsonValue('guest')
guest,
@JsonValue('highlight')
highlight,
@JsonValue('talk-poll')
talkPoll,
@JsonValue('geo-location')
geoLocation,
@JsonValue('call')
call,
}
@@ -1,9 +1,11 @@
import 'get_chat_response.dart';
class RichObjectStringProcessor {
static String parseToString(String message, Map<String, RichObjectString>? data) {
if(data == null) return message;
static String parseToString(
String message,
Map<String, RichObjectString>? data,
) {
if (data == null) return message;
data.forEach((key, value) {
message = message.replaceAll(RegExp('{$key}'), value.name);