feat: Antwort-Zitat antippen springt zur zitierten Nachricht (inkl. Aufleuchten)
_ReplyPreview nutzt den Sprung-Mechanismus der Suche (pendingJumpEventProvider). Der Sprung scrollt jetzt schrittweise Richtung aeltere Nachrichten, wenn das Ziel zwar geladen, aber in der lazy ListView noch nicht gezeichnet ist (vorher gab er dann nach 40 Versuchen auf); dasselbe Zitat darf erneut angetippt werden. UI-Durchlauf prueft den Sprung per Screenshot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
382747cdb1
commit
7063ebfceb
@@ -77,11 +77,25 @@ class _ChatViewState extends ConsumerState<ChatView> {
|
||||
setState(() { _jumpInProgress = false; _highlightEventId = null; _jumpEventId = null; _highlightOn = false; });
|
||||
return;
|
||||
}
|
||||
// Not built yet — load older history toward the target every few tries.
|
||||
// Not built yet. Die Liste baut nur sichtbare Einträge (lazy, reverse):
|
||||
// Ist das Ziel schon geladen, Richtung ältere Nachrichten scrollen, bis
|
||||
// es gezeichnet ist (Antwort-Zitate zeigen fast immer nach oben); sonst
|
||||
// zusätzlich ältere Historie nachladen.
|
||||
final timeline = ref.read(timelineProvider(widget.roomId)).valueOrNull;
|
||||
if (timeline != null && timeline.canRequestHistory && attempt % 3 == 0) {
|
||||
final loaded =
|
||||
timeline?.events.any((e) => e.eventId == _jumpEventId) ?? false;
|
||||
if (!loaded &&
|
||||
timeline != null &&
|
||||
timeline.canRequestHistory &&
|
||||
attempt % 3 == 0) {
|
||||
timeline.requestHistory(historyCount: 100).catchError((_) {});
|
||||
}
|
||||
if (_scrollCtrl.hasClients && (loaded || attempt % 3 == 1)) {
|
||||
final pos = _scrollCtrl.position;
|
||||
final step = pos.viewportDimension * 0.8;
|
||||
final target = (pos.pixels + step).clamp(0.0, pos.maxScrollExtent);
|
||||
if (target > pos.pixels) _scrollCtrl.jumpTo(target);
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Future.delayed(const Duration(milliseconds: 120), () => _attemptJump(attempt + 1));
|
||||
});
|
||||
@@ -313,7 +327,9 @@ class _ChatViewState extends ConsumerState<ChatView> {
|
||||
// listen) so it also fires when this ChatView is freshly mounted for a
|
||||
// DIFFERENT room — listen would miss a value set before registration.
|
||||
final pendingJump = ref.watch(pendingJumpEventProvider);
|
||||
if (pendingJump != null && !_jumpInProgress && pendingJump != _jumpEventId) {
|
||||
// (Kein Vergleich mit _jumpEventId mehr: dasselbe Zitat darf zweimal
|
||||
// hintereinander angetippt werden – _startJump verbraucht die Anfrage.)
|
||||
if (pendingJump != null && !_jumpInProgress) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted &&
|
||||
!_jumpInProgress &&
|
||||
|
||||
Reference in New Issue
Block a user