fix: resolve some sentry issues

This commit is contained in:
Sorunome 2020-11-16 11:31:31 +01:00
parent dbbab93350
commit 2c3693e4eb
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
4 changed files with 36 additions and 12 deletions

View File

@ -86,16 +86,24 @@ class _ImageBubbleState extends State<ImageBubble> {
}
if (_thumbnail == null && !_requestedThumbnail && !isUnencrypted) {
_getThumbnail().then((MatrixFile thumbnail) {
if (mounted) {
setState(() => _thumbnail = thumbnail);
}
}, onError: (error, stacktrace) {
if (mounted) {
setState(() => _error = error);
}
});
}
if (_file == null && !widget.thumbnailOnly && !_requestedFile) {
_getFile().then((MatrixFile file) {
if (mounted) {
setState(() => _file = file);
}
}, onError: (error, stacktrace) {
if (mounted) {
setState(() => _error = error);
}
});
}
final display = _file ?? _thumbnail;

View File

@ -121,6 +121,9 @@ class _ChatState extends State<_Chat> {
}
void _updateScrollController() {
if (!mounted) {
return;
}
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent &&
timeline.events.isNotEmpty &&
@ -176,17 +179,27 @@ class _ChatState extends State<_Chat> {
if (timeline == null) {
timeline = await room.getTimeline(onUpdate: updateView);
if (timeline.events.isNotEmpty) {
unawaited(room.sendReadReceipt(timeline.events.first.eventId));
unawaited(room
.sendReadReceipt(timeline.events.first.eventId)
.catchError((err) {
if (err is MatrixException && err.errcode == 'M_FORBIDDEN') {
// ignore if the user is not in the room (still joining)
return;
}
throw err;
}));
}
// when the scroll controller is attached we want to scroll to an event id, if specified
// and update the scroll controller...which will trigger a request history, if the
// "load more" button is visible on the screen
SchedulerBinding.instance.addPostFrameCallback((_) async {
if (mounted) {
if (widget.scrollToEventId != null) {
_scrollToEventId(widget.scrollToEventId, context: context);
}
_updateScrollController();
}
});
}
updateView();
@ -406,6 +419,9 @@ class _ChatState extends State<_Chat> {
await task;
}
}
if (!mounted) {
return;
}
await _scrollController.scrollToIndex(eventIndex,
preferPosition: AutoScrollPosition.middle);
_updateScrollController();

View File

@ -215,8 +215,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "66572bd03209c1c6488cde53a0c72c11faef341d"
resolved-ref: "66572bd03209c1c6488cde53a0c72c11faef341d"
ref: c8d5bbfd144fd4ed36ebb12abc83e7676b9e45b0
resolved-ref: c8d5bbfd144fd4ed36ebb12abc83e7676b9e45b0
url: "https://gitlab.com/famedly/famedlysdk.git"
source: git
version: "0.0.1"
@ -1151,5 +1151,5 @@ packages:
source: hosted
version: "0.1.2"
sdks:
dart: ">=2.10.2 <2.11.0"
dart: ">=2.10.2 <=2.11.0-161.0.dev"
flutter: ">=1.22.2 <2.0.0"

View File

@ -23,7 +23,7 @@ dependencies:
famedlysdk:
git:
url: https://gitlab.com/famedly/famedlysdk.git
ref: 66572bd03209c1c6488cde53a0c72c11faef341d
ref: c8d5bbfd144fd4ed36ebb12abc83e7676b9e45b0
localstorage: ^3.0.3+6
file_picker_cross: 4.2.2