Skip to content

Commit 188e5b3

Browse files
authored
Merge pull request #236 from deaflynx/fix/alarm-comment
fix: alarm comment crash and wrong display format
2 parents 5af55e2 + 46e0138 commit 188e5b3

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

lib/modules/alarm/data/datasource/details/alarm_details_datasource.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class AlarmDetailsDatasource implements IAlarmDetailsDatasource {
2929
required String comment,
3030
}) {
3131
return thingsboardClient.getAlarmService().postAlarmComment(
32-
AlarmComment(null, null, alarmId, null, AlarmCommentType.OTHER, comment, null),
33-
32+
AlarmComment(null, null, alarmId, null, AlarmCommentType.OTHER, {'text': comment}, null),
3433
);
3534
}
3635

@@ -49,7 +48,7 @@ class AlarmDetailsDatasource implements IAlarmDetailsDatasource {
4948
required String comment,
5049
}) {
5150
return thingsboardClient.getAlarmService().postAlarmComment(
52-
AlarmComment(id, null, alarmId, null, AlarmCommentType.OTHER, comment, null)
51+
AlarmComment(id, null, alarmId, null, AlarmCommentType.OTHER, {'text': comment, 'edited': 'true'}, null),
5352
);
5453
}
5554

lib/modules/alarm/presentation/widgets/activity/alarm_edit_comment_textfield.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class _AlarmEditCommentState extends State<AlarmEditCommentTextField> {
7878

7979
@override
8080
void initState() {
81-
textController.text = widget.commentToEdit.comment.toString();
81+
textController.text = (widget.commentToEdit.comment as AlarmCommentJsonNode).text;
8282
super.initState();
8383
}
8484

lib/modules/alarm/presentation/widgets/activity/system_activity_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SystemActivityWidget extends StatelessWidget {
2424
),
2525
),
2626
Text(
27-
activity.comment.toString(),
27+
(activity.comment as AlarmCommentJsonNode).text,
2828
style: TbTextStyles.bodyLarge.copyWith(
2929
color: Colors.black.withValues(alpha: .54),
3030
),

lib/modules/alarm/presentation/widgets/activity/user_comment_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class _UserCommentState extends State<UserCommentWidget> {
163163
),
164164
const SizedBox(width: 4),
165165
Visibility(
166-
visible: widget.activity.comment.edited == true,
166+
visible: (widget.activity.comment as AlarmCommentJsonNode).edited,
167167
child: Text(
168168
' ${S.of(context).edited}',
169169
style: TbTextStyles.bodyMedium.copyWith(
@@ -174,7 +174,7 @@ class _UserCommentState extends State<UserCommentWidget> {
174174
],
175175
),
176176
Text(
177-
widget.activity.comment.toString(),
177+
(widget.activity.comment as AlarmCommentJsonNode).text,
178178
style: TbTextStyles.bodyLarge.copyWith(
179179
color: Colors.black.withValues(alpha: .54),
180180
),

0 commit comments

Comments
 (0)