Merge pull request #805 from pangeachat/sentry
log actual error in message_audio_card logging statements instead of …
This commit is contained in:
commit
199c1ce655
6 changed files with 131 additions and 60 deletions
|
|
@ -4,7 +4,6 @@ import 'dart:developer';
|
|||
import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart';
|
||||
import 'package:fluffychat/pangea/constants/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/enum/instructions_enum.dart';
|
||||
import 'package:fluffychat/pangea/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
|
@ -180,6 +179,18 @@ class ITController {
|
|||
}
|
||||
|
||||
Future<void> getNextTranslationData() async {
|
||||
if (sourceText == null) {
|
||||
ErrorHandler.logError(
|
||||
e: Exception("sourceText is null in getNextTranslationData"),
|
||||
data: {
|
||||
"sourceText": sourceText,
|
||||
"currentITStep": currentITStep,
|
||||
"nextITStep": nextITStep,
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (completedITSteps.length < goldRouteTracker.continuances.length) {
|
||||
final String currentText = choreographer.currentText;
|
||||
|
|
|
|||
|
|
@ -44,17 +44,13 @@ class ChoicesArrayState extends State<ChoicesArray> {
|
|||
|
||||
void disableInteraction() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
interactionDisabled = true;
|
||||
});
|
||||
if (mounted) setState(() => interactionDisabled = true);
|
||||
});
|
||||
}
|
||||
|
||||
void enableInteractions() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
interactionDisabled = false;
|
||||
});
|
||||
if (mounted) setState(() => interactionDisabled = false);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ extension AnalyticsRoomExtension on Room {
|
|||
await analyticsRoom.requestParticipants();
|
||||
}
|
||||
|
||||
final List<User> participants = analyticsRoom.getParticipants();
|
||||
final List<User> participants = await analyticsRoom.requestParticipants();
|
||||
final List<User> uninvitedTeachers = teachersLocal
|
||||
.where((teacher) => !participants.contains(teacher))
|
||||
.toList();
|
||||
|
|
@ -110,8 +110,12 @@ extension AnalyticsRoomExtension on Room {
|
|||
(teacher) => analyticsRoom.invite(teacher.id).catchError((err, s) {
|
||||
ErrorHandler.logError(
|
||||
e: err,
|
||||
m: "Failed to invite teacher ${teacher.id} to analytics room ${analyticsRoom.id}",
|
||||
m: "Failed to invite teacher to analytics room",
|
||||
s: s,
|
||||
data: {
|
||||
"teacherId": teacher.id,
|
||||
"analyticsRoomId": analyticsRoom.id,
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -89,8 +89,7 @@ class MessageAudioCardState extends State<MessageAudioCard> {
|
|||
// should never happen but just in case
|
||||
debugger(when: kDebugMode);
|
||||
ErrorHandler.logError(
|
||||
e: Exception(),
|
||||
m: 'audioFile duration is null in MessageAudioCardState',
|
||||
e: 'audioFile duration is null in MessageAudioCardState',
|
||||
data: {
|
||||
'audioFile': audioFile,
|
||||
},
|
||||
|
|
@ -124,8 +123,7 @@ class MessageAudioCardState extends State<MessageAudioCard> {
|
|||
// if we didn't find the token, we should pause if debug and log an error
|
||||
debugger(when: kDebugMode);
|
||||
ErrorHandler.logError(
|
||||
e: Exception(),
|
||||
m: 'could not find token for selection in MessageAudioCardState',
|
||||
e: 'could not find token for selection in MessageAudioCardState',
|
||||
data: {
|
||||
'selection': selection,
|
||||
'tokens': tokens,
|
||||
|
|
@ -174,7 +172,7 @@ class MessageAudioCardState extends State<MessageAudioCard> {
|
|||
),
|
||||
);
|
||||
ErrorHandler.logError(
|
||||
e: Exception(),
|
||||
e: e,
|
||||
s: s,
|
||||
m: 'something wrong getting audio in MessageAudioCardState',
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import 'package:fluffychat/pangea/enum/message_mode_enum.dart';
|
|||
import 'package:fluffychat/pangea/matrix_event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/message_toolbar.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/message_toolbar_buttons.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/overlay_footer.dart';
|
||||
|
|
@ -104,16 +105,29 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
/// This is a workaround to prevent that error
|
||||
@override
|
||||
void setState(VoidCallback fn) {
|
||||
if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.idle ||
|
||||
SchedulerBinding.instance.schedulerPhase ==
|
||||
SchedulerPhase.postFrameCallbacks) {
|
||||
final phase = SchedulerBinding.instance.schedulerPhase;
|
||||
if (mounted &&
|
||||
(phase == SchedulerPhase.idle ||
|
||||
phase == SchedulerPhase.postFrameCallbacks)) {
|
||||
// It's safe to call setState immediately
|
||||
super.setState(fn);
|
||||
try {
|
||||
super.setState(fn);
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(
|
||||
e: "Error calling setState in MessageSelectionOverlay: $e",
|
||||
s: s,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Defer the setState call to after the current frame
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
super.setState(fn);
|
||||
try {
|
||||
if (mounted) super.setState(fn);
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(
|
||||
e: "Error calling setState in MessageSelectionOverlay after postframeCallback: $e",
|
||||
s: s,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -260,14 +274,14 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (messageSize == null || messageOffset == null) {
|
||||
if (messageSize == null || messageOffset == null || screenHeight == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// position the overlay directly over the underlying message
|
||||
final headerBottomOffset = screenHeight - headerHeight;
|
||||
final headerBottomOffset = screenHeight! - headerHeight;
|
||||
final footerBottomOffset = footerHeight;
|
||||
final currentBottomOffset = screenHeight -
|
||||
final currentBottomOffset = screenHeight! -
|
||||
messageOffset!.dy -
|
||||
messageSize!.height -
|
||||
belowMessageHeight;
|
||||
|
|
@ -295,7 +309,7 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
animationEndOffset = midpoint - messageSize!.height - belowMessageHeight;
|
||||
final totalTopOffset =
|
||||
animationEndOffset + messageSize!.height + AppConfig.toolbarMaxHeight;
|
||||
final remainingSpace = screenHeight - totalTopOffset;
|
||||
final remainingSpace = screenHeight! - totalTopOffset;
|
||||
if (remainingSpace < headerHeight) {
|
||||
// the overlay could run over the header, so it needs to be shifted down
|
||||
animationEndOffset -= (headerHeight - remainingSpace);
|
||||
|
|
@ -310,7 +324,7 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
// update the message height to fit the screen. The message is scrollable, so
|
||||
// this will make the both the toolbar box and the toolbar buttons visible.
|
||||
if (animationEndOffset < footerHeight + belowMessageHeight) {
|
||||
final double remainingSpace = screenHeight -
|
||||
final double remainingSpace = screenHeight! -
|
||||
AppConfig.toolbarMaxHeight -
|
||||
headerHeight -
|
||||
footerHeight -
|
||||
|
|
@ -348,28 +362,62 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
RenderBox? get messageRenderBox => MatrixState.pAnyState.getRenderBox(
|
||||
RenderBox? get messageRenderBox {
|
||||
try {
|
||||
return MatrixState.pAnyState.getRenderBox(
|
||||
widget._event.eventId,
|
||||
);
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(e: "Error getting message render box: $e", s: s);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Size? get messageSize {
|
||||
try {
|
||||
return messageRenderBox?.size;
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(e: "Error getting message size: $e", s: s);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Offset? get messageOffset {
|
||||
try {
|
||||
return messageRenderBox?.localToGlobal(Offset.zero);
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(e: "Error getting message offset: $e", s: s);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Size? get messageSize => messageRenderBox?.size;
|
||||
Offset? get messageOffset => messageRenderBox?.localToGlobal(Offset.zero);
|
||||
double? adjustedMessageHeight;
|
||||
|
||||
// height of the reply/forward bar + the reaction picker + contextual padding
|
||||
double get footerHeight =>
|
||||
48 + 56 + (FluffyThemes.isColumnMode(context) ? 16.0 : 8.0);
|
||||
|
||||
MediaQueryData? get mediaQuery {
|
||||
try {
|
||||
return MediaQuery.of(context);
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(e: "Error getting media query: $e", s: s);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
double get headerHeight =>
|
||||
(Theme.of(context).appBarTheme.toolbarHeight ?? 56) +
|
||||
MediaQuery.of(context).padding.top;
|
||||
(mediaQuery?.padding.top ?? 0);
|
||||
|
||||
double get screenHeight => MediaQuery.of(context).size.height;
|
||||
double? get screenHeight => mediaQuery?.size.height;
|
||||
|
||||
double get screenWidth => MediaQuery.of(context).size.width;
|
||||
double? get screenWidth => mediaQuery?.size.width;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (messageSize == null) return const SizedBox.shrink();
|
||||
|
||||
final bool showDetails = (Matrix.of(context)
|
||||
.store
|
||||
.getBool(SettingKeys.displayChatDetailsColumn) ??
|
||||
|
|
@ -380,13 +428,17 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
// the default spacing between the side of the screen and the message bubble
|
||||
const double messageMargin = Avatar.defaultSize + 16 + 8;
|
||||
final horizontalPadding = FluffyThemes.isColumnMode(context) ? 8.0 : 0.0;
|
||||
final chatViewWidth = screenWidth -
|
||||
(FluffyThemes.isColumnMode(context)
|
||||
? (FluffyThemes.columnWidth + FluffyThemes.navRailWidth)
|
||||
: 0);
|
||||
|
||||
const totalMaxWidth = (FluffyThemes.columnWidth * 2.5) - messageMargin;
|
||||
double maxWidth = chatViewWidth - (2 * horizontalPadding) - messageMargin;
|
||||
if (maxWidth > totalMaxWidth) {
|
||||
double? maxWidth;
|
||||
if (screenWidth != null) {
|
||||
final chatViewWidth = screenWidth! -
|
||||
(FluffyThemes.isColumnMode(context)
|
||||
? (FluffyThemes.columnWidth + FluffyThemes.navRailWidth)
|
||||
: 0);
|
||||
maxWidth = chatViewWidth - (2 * horizontalPadding) - messageMargin;
|
||||
}
|
||||
if (maxWidth == null || maxWidth > totalMaxWidth) {
|
||||
maxWidth = totalMaxWidth;
|
||||
}
|
||||
|
||||
|
|
@ -445,27 +497,33 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
? FluffyThemes.columnWidth + FluffyThemes.navRailWidth
|
||||
: 0;
|
||||
|
||||
final double? leftPadding = widget._pangeaMessageEvent.ownMessage
|
||||
? null
|
||||
: messageOffset!.dx - horizontalPadding - columnOffset;
|
||||
final double? leftPadding =
|
||||
(widget._pangeaMessageEvent.ownMessage || messageOffset == null)
|
||||
? null
|
||||
: messageOffset!.dx - horizontalPadding - columnOffset;
|
||||
|
||||
final double? rightPadding = widget._pangeaMessageEvent.ownMessage
|
||||
? screenWidth -
|
||||
final double? rightPadding = (widget._pangeaMessageEvent.ownMessage &&
|
||||
screenWidth != null &&
|
||||
messageOffset != null &&
|
||||
messageSize != null)
|
||||
? screenWidth! -
|
||||
messageOffset!.dx -
|
||||
messageSize!.width -
|
||||
horizontalPadding
|
||||
: null;
|
||||
|
||||
final positionedOverlayMessage = _overlayPositionAnimation == null
|
||||
? Positioned(
|
||||
left: leftPadding,
|
||||
right: rightPadding,
|
||||
bottom: screenHeight -
|
||||
messageOffset!.dy -
|
||||
messageSize!.height -
|
||||
belowMessageHeight,
|
||||
child: overlayMessage,
|
||||
)
|
||||
final positionedOverlayMessage = (_overlayPositionAnimation == null)
|
||||
? (screenHeight == null || messageSize == null || messageOffset == null)
|
||||
? const SizedBox.shrink()
|
||||
: Positioned(
|
||||
left: leftPadding,
|
||||
right: rightPadding,
|
||||
bottom: screenHeight! -
|
||||
messageOffset!.dy -
|
||||
messageSize!.height -
|
||||
belowMessageHeight,
|
||||
child: overlayMessage,
|
||||
)
|
||||
: AnimatedBuilder(
|
||||
animation: _overlayPositionAnimation!,
|
||||
builder: (context, child) {
|
||||
|
|
|
|||
|
|
@ -144,14 +144,18 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
|
|||
child: Column(
|
||||
children: [
|
||||
widget.selection != null
|
||||
? Text(
|
||||
selectionTranslation!,
|
||||
style: BotStyle.text(context),
|
||||
)
|
||||
: Text(
|
||||
repEvent!.text,
|
||||
style: BotStyle.text(context),
|
||||
),
|
||||
? selectionTranslation != null
|
||||
? Text(
|
||||
selectionTranslation!,
|
||||
style: BotStyle.text(context),
|
||||
)
|
||||
: const ToolbarContentLoadingIndicator()
|
||||
: repEvent != null
|
||||
? Text(
|
||||
repEvent!.text,
|
||||
style: BotStyle.text(context),
|
||||
)
|
||||
: const ToolbarContentLoadingIndicator(),
|
||||
if (notGoingToTranslate && widget.selection == null)
|
||||
InlineTooltip(
|
||||
instructionsEnum: InstructionsEnum.l1Translation,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue