Designed talk message reactions

This commit is contained in:
2023-07-08 21:50:25 +02:00
parent db87b7c3ff
commit 0b2fab5b6d
6 changed files with 222 additions and 171 deletions

View File

@ -1,3 +1,4 @@
import 'package:jiffy/jiffy.dart';
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
@ -34,6 +35,8 @@ class GetChatResponseObject {
bool isReplyable;
String referenceId;
String message;
Map<String, int>? reactions;
List<String>? reactionsSelf;
@JsonKey(fromJson: _fromJson) Map<String, RichObjectString>? messageParameters;
GetChatResponseObject(
@ -48,11 +51,35 @@ class GetChatResponseObject {
this.isReplyable,
this.referenceId,
this.message,
this.messageParameters);
this.messageParameters,
this.reactions,
this.reactionsSelf
);
factory GetChatResponseObject.fromJson(Map<String, dynamic> json) => _$GetChatResponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetChatResponseObjectToJson(this);
static GetChatResponseObject getDateDummy(int timestamp) {
DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
return GetChatResponseObject(
0,
"",
GetRoomResponseObjectMessageActorType.user,
"",
"",
timestamp,
elementDate.toIso8601String(),
GetRoomResponseObjectMessageType.system,
false,
"",
Jiffy.parseFromDateTime(elementDate).format(pattern: "dd.MM.yyyy"),
null,
null,
null
);
}
}
Map<String, RichObjectString>? _fromJson(json) {

View File

@ -35,6 +35,12 @@ GetChatResponseObject _$GetChatResponseObjectFromJson(
json['referenceId'] as String,
json['message'] as String,
_fromJson(json['messageParameters']),
(json['reactions'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as int),
),
(json['reactionsSelf'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
);
Map<String, dynamic> _$GetChatResponseObjectToJson(
@ -53,6 +59,8 @@ Map<String, dynamic> _$GetChatResponseObjectToJson(
'isReplyable': instance.isReplyable,
'referenceId': instance.referenceId,
'message': instance.message,
'reactions': instance.reactions,
'reactionsSelf': instance.reactionsSelf,
'messageParameters':
instance.messageParameters?.map((k, e) => MapEntry(k, e.toJson())),
};

View File

@ -54,7 +54,7 @@ abstract class TalkApi<T> extends ApiRequest {
return assembled;
} catch (_) {
// TODO report error
log("Error assembling Talk API response on $endpoint with body: $body and headers: ${headers.toString()}");
log("Error assembling Talk API ${T.toString()} response on ${endpoint.path} with body: $body and headers: ${headers.toString()}");
}
throw Exception("Error assembling Talk API response");