Skip to content

Commit

Permalink
Merge pull request #298 from takenet/feature/802877-reactions
Browse files Browse the repository at this point in the history
[Feature] #802877 - Reactions Support
  • Loading branch information
mpamaro authored Feb 7, 2025
2 parents 500fda2 + a39ba5c commit 58b83c8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
21 changes: 17 additions & 4 deletions lib/src/models/ds_reply_content.model.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../utils/ds_message_content_type.util.dart';
import 'ds_reply_content_in_reply_to.model.dart';
import 'ds_reply_content_replied.model.dart';

Expand All @@ -11,11 +12,9 @@ class DSReplyContent {
});

DSReplyContent.fromJson(Map<String, dynamic> json)
: replied = DSReplyContentReplied.fromJson(
json['replied'],
),
: replied = _getContent(json),
inReplyTo = DSReplyContentInReplyTo.fromJson(
json['inReplyTo'],
json['inReplyTo'] ?? json['inReactionTo'],
);

Map<String, dynamic> toJson() {
Expand All @@ -24,4 +23,18 @@ class DSReplyContent {
'inReplyTo': inReplyTo.toJson(),
};
}

static DSReplyContentReplied _getContent(Map<String, dynamic> json) =>
json['replied'] != null
? DSReplyContentReplied.fromJson(
json['replied'],
)
: DSReplyContentReplied(
type: DSMessageContentType.textPlain,
value: String.fromCharCodes(
(json['emoji']['values'] as List).map(
(e) => e as int,
),
),
);
}
1 change: 1 addition & 0 deletions lib/src/utils/ds_message_content_type.util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ abstract class DSMessageContentType {
static const String applicationJson = 'application/json';
static const String reply = 'application/vnd.lime.reply+json';
static const String callsMedia = 'application/vnd.iris.calls.media+json';
static const String reaction = 'application/vnd.lime.reaction+json';
}
12 changes: 4 additions & 8 deletions lib/src/widgets/utils/ds_card.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ class DSCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
return _resolveWidget();
}

Widget _resolveWidget() {
switch (type) {
case DSMessageContentType.textPlain:
case DSMessageContentType.sensitive:
Expand All @@ -94,10 +90,7 @@ class DSCard extends StatelessWidget {
onTapReply: onTapReply,
);

case DSMessageContentType.contact:
return _buildContact();

case DSMessageContentType.reply:
case DSMessageContentType.reply || DSMessageContentType.reaction:
final replyContent = DSReplyContent.fromJson(content);

return DSCard(
Expand All @@ -118,6 +111,9 @@ class DSCard extends StatelessWidget {
onTapReply: onTapReply,
);

case DSMessageContentType.contact:
return _buildContact();

case DSMessageContentType.mediaLink:
return _buildMediaLink();

Expand Down
2 changes: 1 addition & 1 deletion sample/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.3.3"
version: "0.3.4"
boolean_selector:
dependency: transitive
description:
Expand Down

0 comments on commit 58b83c8

Please sign in to comment.