fix: remove reaction subscription to prevent overlay jumping (#5100)
This commit is contained in:
parent
532e376895
commit
5aa3d759e0
3 changed files with 6 additions and 41 deletions
|
|
@ -20,13 +20,13 @@ class PangeaMessageReactions extends StatefulWidget {
|
|||
final Event event;
|
||||
final Timeline timeline;
|
||||
final ChatController controller;
|
||||
final double? maxWidth;
|
||||
final double? width;
|
||||
|
||||
const PangeaMessageReactions(
|
||||
this.event,
|
||||
this.timeline,
|
||||
this.controller, {
|
||||
this.maxWidth,
|
||||
this.width,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ class _PangeaMessageReactionsState extends State<PangeaMessageReactions> {
|
|||
return SizedBox(
|
||||
width: allReactionEvents.any((e) => e.status.isSending)
|
||||
? null
|
||||
: widget.maxWidth,
|
||||
: widget.width,
|
||||
child: Directionality(
|
||||
textDirection: ownMessage ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Wrap(
|
||||
|
|
|
|||
|
|
@ -51,9 +51,6 @@ class MessageSelectionPositioner extends StatefulWidget {
|
|||
|
||||
class MessageSelectionPositionerState extends State<MessageSelectionPositioner>
|
||||
with TickerProviderStateMixin {
|
||||
StreamSubscription? _reactionSubscription;
|
||||
StreamSubscription? _contentChangedSubscription;
|
||||
|
||||
ScrollController? scrollController;
|
||||
|
||||
ValueNotifier<bool> finishedTransition = ValueNotifier(false);
|
||||
|
|
@ -79,36 +76,10 @@ class MessageSelectionPositionerState extends State<MessageSelectionPositioner>
|
|||
});
|
||||
},
|
||||
);
|
||||
|
||||
_reactionSubscription =
|
||||
widget.chatController.room.client.onSync.stream.where(
|
||||
(update) {
|
||||
// check if this sync update has a reaction event or a
|
||||
// redaction (of a reaction event). If so, rebuild the overlay
|
||||
final room = widget.chatController.room;
|
||||
final timelineEvents = update.rooms?.join?[room.id]?.timeline?.events;
|
||||
if (timelineEvents == null) return false;
|
||||
|
||||
final eventID = widget.event.eventId;
|
||||
return timelineEvents.any(
|
||||
(e) =>
|
||||
e.type == EventTypes.Redaction ||
|
||||
(e.type == EventTypes.Reaction &&
|
||||
Event.fromMatrixEvent(e, room).relationshipEventId ==
|
||||
eventID),
|
||||
);
|
||||
},
|
||||
).listen((_) => setState(() {}));
|
||||
|
||||
_contentChangedSubscription = widget
|
||||
.overlayController.selectModeController.contentChangedStream.stream
|
||||
.listen(_onContentSizeChanged);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_reactionSubscription?.cancel();
|
||||
_contentChangedSubscription?.cancel();
|
||||
scrollController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
|
@ -156,11 +127,11 @@ class MessageSelectionPositionerState extends State<MessageSelectionPositioner>
|
|||
return hasReactions ? 28.0 : 0.0;
|
||||
}
|
||||
|
||||
double get reactionsWidth {
|
||||
double? get reactionsWidth {
|
||||
if (_reactionsRenderBox != null) {
|
||||
return _reactionsRenderBox!.size.width;
|
||||
}
|
||||
return 0.0;
|
||||
return null;
|
||||
}
|
||||
|
||||
bool get ownMessage =>
|
||||
|
|
@ -388,12 +359,6 @@ class MessageSelectionPositionerState extends State<MessageSelectionPositioner>
|
|||
return boxHeight;
|
||||
}
|
||||
|
||||
void _onContentSizeChanged(_) {
|
||||
Future.delayed(FluffyThemes.animationDuration, () {
|
||||
if (mounted) setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void onStartedTransition() {
|
||||
if (mounted) _startedTransition.value = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class OverlayCenterContent extends StatelessWidget {
|
|||
event,
|
||||
chatController.timeline!,
|
||||
chatController,
|
||||
maxWidth: reactionsWidth,
|
||||
width: reactionsWidth,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue