Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] #802877 - Reactions Support #298

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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