chore: Follow up scroll to event id fix
This commit is contained in:
parent
47481eb676
commit
641343d5fe
1 changed files with 13 additions and 7 deletions
|
|
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:desktop_drop/desktop_drop.dart';
|
import 'package:desktop_drop/desktop_drop.dart';
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
|
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
|
||||||
|
|
@ -216,15 +217,13 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
EmojiPickerType emojiPickerType = EmojiPickerType.keyboard;
|
EmojiPickerType emojiPickerType = EmojiPickerType.keyboard;
|
||||||
|
|
||||||
void requestHistory([_]) async {
|
void requestHistory([_]) async {
|
||||||
if (!timeline!.canRequestHistory) return;
|
|
||||||
Logs().v('Requesting history...');
|
Logs().v('Requesting history...');
|
||||||
await timeline!.requestHistory(historyCount: _loadHistoryCount);
|
await timeline?.requestHistory(historyCount: _loadHistoryCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestFuture() async {
|
void requestFuture() async {
|
||||||
final timeline = this.timeline;
|
final timeline = this.timeline;
|
||||||
if (timeline == null) return;
|
if (timeline == null) return;
|
||||||
if (!timeline.canRequestFuture) return;
|
|
||||||
Logs().v('Requesting future...');
|
Logs().v('Requesting future...');
|
||||||
final mostRecentEventId = timeline.events.first.eventId;
|
final mostRecentEventId = timeline.events.first.eventId;
|
||||||
await timeline.requestFuture(historyCount: _loadHistoryCount);
|
await timeline.requestFuture(historyCount: _loadHistoryCount);
|
||||||
|
|
@ -343,6 +342,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
eventContextId = null;
|
eventContextId = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
timeline?.cancelSubscriptions();
|
||||||
timeline = await room.getTimeline(
|
timeline = await room.getTimeline(
|
||||||
onUpdate: updateView,
|
onUpdate: updateView,
|
||||||
eventContextId: eventContextId,
|
eventContextId: eventContextId,
|
||||||
|
|
@ -905,10 +905,16 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
String eventId, {
|
String eventId, {
|
||||||
bool highlightEvent = true,
|
bool highlightEvent = true,
|
||||||
}) async {
|
}) async {
|
||||||
final eventIndex = timeline!.events
|
final foundEvent =
|
||||||
.where((event) => event.isVisibleInGui)
|
timeline!.events.firstWhereOrNull((event) => event.eventId == eventId);
|
||||||
.toList()
|
|
||||||
.indexWhere((e) => e.eventId == eventId);
|
final eventIndex = foundEvent == null
|
||||||
|
? -1
|
||||||
|
: timeline!.events
|
||||||
|
.where((event) => event.isVisibleInGui || event.eventId == eventId)
|
||||||
|
.toList()
|
||||||
|
.indexOf(foundEvent);
|
||||||
|
|
||||||
if (eventIndex == -1) {
|
if (eventIndex == -1) {
|
||||||
setState(() {
|
setState(() {
|
||||||
timeline = null;
|
timeline = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue