mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-25 05:22:13 +00:00
add missing mounted guards
This commit is contained in:
parent
fcb93830e1
commit
5722cb71bb
9 changed files with 14 additions and 1 deletions
|
|
@ -39,6 +39,7 @@ class _VerificationBadgeCompState extends State<VerificationBadgeComp> {
|
|||
_streamAllVerified = twonlyDB.keyVerificationDao
|
||||
.watchAllGroupMembersVerified(widget.group!.groupId)
|
||||
.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isVerified = update;
|
||||
});
|
||||
|
|
@ -47,6 +48,7 @@ class _VerificationBadgeCompState extends State<VerificationBadgeComp> {
|
|||
_streamContactVerification = twonlyDB.keyVerificationDao
|
||||
.watchContactVerification(widget.contact!.userId)
|
||||
.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isVerified = update.isNotEmpty;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class _UserListItem extends State<GroupListItemComp> {
|
|||
_lastReactionStream = twonlyDB.reactionsDao
|
||||
.watchLastReactions(widget.group.groupId)
|
||||
.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_lastReaction = update;
|
||||
});
|
||||
|
|
@ -92,6 +93,7 @@ class _UserListItem extends State<GroupListItemComp> {
|
|||
_lastMediaFilesStream = twonlyDB.mediaFilesDao
|
||||
.watchNewestMediaFiles()
|
||||
.listen((mediaFiles) {
|
||||
if (!mounted) return;
|
||||
for (final mediaFile in mediaFiles) {
|
||||
final index = _previewMediaFiles.indexWhere(
|
||||
(t) => t.mediaId == mediaFile.mediaId,
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class _ChatMessagesViewState extends State<ChatMessagesView> {
|
|||
final groupStream = twonlyDB.groupsDao.watchGroup(widget.groupId);
|
||||
userSub = groupStream.listen((newGroup) {
|
||||
if (newGroup == null) return;
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_group = newGroup;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class _AllReactionsViewState extends State<AllReactionsView> {
|
|||
);
|
||||
|
||||
reactionsSub = stream.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
reactionsUsers = update;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class _ChatListEntryState extends State<ChatListEntry> {
|
|||
);
|
||||
|
||||
reactionsSub = stream.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
reactions = update;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class _InChatAudioPlayerState extends State<InChatAudioPlayer> {
|
|||
DurationType.max,
|
||||
);
|
||||
_maxDuration = _displayDuration;
|
||||
setState(() {});
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class _MessageInputState extends State<MessageInput> {
|
|||
void _initializeControllers() {
|
||||
recorderController = RecorderController();
|
||||
recorderController.onCurrentDuration.listen((duration) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_currentDuration = duration.inMilliseconds;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ class _MessageInfoViewState extends State<MessageInfoView> {
|
|||
widget.message.messageId,
|
||||
);
|
||||
actionsStream = streamActions.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
messageActions = update;
|
||||
});
|
||||
|
|
@ -67,6 +68,7 @@ class _MessageInfoViewState extends State<MessageInfoView> {
|
|||
widget.message.groupId,
|
||||
);
|
||||
groupMemberStream = streamGroup.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
groupMembers = update;
|
||||
});
|
||||
|
|
@ -76,6 +78,7 @@ class _MessageInfoViewState extends State<MessageInfoView> {
|
|||
widget.message.messageId,
|
||||
);
|
||||
historyStream = streamHistory.listen((update) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
messageHistory = update;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ class _RetransmissionDataViewState extends State<RetransmissionDataView> {
|
|||
subscriptionContacts = twonlyDB.contactsDao.watchAllContacts().listen((
|
||||
updated,
|
||||
) {
|
||||
if (!mounted) return;
|
||||
for (final contact in updated) {
|
||||
contacts[contact.userId] = contact;
|
||||
}
|
||||
|
|
@ -85,6 +86,7 @@ class _RetransmissionDataViewState extends State<RetransmissionDataView> {
|
|||
subscriptionRetransmission = twonlyDB.receiptsDao.watchAll().listen((
|
||||
updated,
|
||||
) {
|
||||
if (!mounted) return;
|
||||
retransmissions = updated.reversed.toList();
|
||||
if (contacts.isNotEmpty) {
|
||||
messages = RetransMsg.fromRaw(retransmissions, contacts);
|
||||
|
|
|
|||
Loading…
Reference in a new issue