From ded926cdf9b82bae12404651c74b14c1ca853f38 Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Sun, 29 Aug 2021 19:24:44 +0200
Subject: [PATCH] Fix a few null warnings

---
 resources/qml/MessageView.qml                   | 10 +++++-----
 resources/qml/TimelineView.qml                  |  9 ++++-----
 resources/qml/dialogs/ImagePackEditorDialog.qml |  1 -
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index e5c6b4ecc..6446e61b1 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -33,7 +33,7 @@ ScrollView {
         verticalLayoutDirection: ListView.BottomToTop
         onCountChanged: {
             // Mark timeline as read
-            if (atYEnd)
+            if (atYEnd && room)
                 model.currentIndex = 0;
 
         }
@@ -233,8 +233,8 @@ ScrollView {
                     id: dateBubble
 
                     anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined
-                    visible: previousMessageDay !== day
-                    text: chat.model.formatDateSeparator(timestamp)
+                    visible: room && previousMessageDay !== day
+                    text: room ? room.formatDateSeparator(timestamp) : ""
                     color: Nheko.colors.text
                     height: Math.round(fontMetrics.height * 1.4)
                     width: contentWidth * 1.2
@@ -257,10 +257,10 @@ ScrollView {
 
                         width: Nheko.avatarSize
                         height: Nheko.avatarSize
-                        url: chat.model.avatarUrl(userId).replace("mxc://", "image://MxcImage/")
+                        url: !room ? "" : room.avatarUrl(userId).replace("mxc://", "image://MxcImage/")
                         displayName: userName
                         userid: userId
-                        onClicked: chat.model.openUserProfile(userId)
+                        onClicked: room.openUserProfile(userId)
                         ToolTip.visible: avatarHover.hovered
                         ToolTip.text: userid
 
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 5a8b5381b..9bc4bef03 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -84,11 +84,10 @@ Item {
                         target: timelineView
                     }
 
-
-                        MessageView {
-                            implicitHeight: msgView.height - typingIndicator.height
-                            Layout.fillWidth: true
-                        }
+                    MessageView {
+                        implicitHeight: msgView.height - typingIndicator.height
+                        Layout.fillWidth: true
+                    }
 
                     Loader {
                         source: CallManager.isOnCall && CallManager.callType != CallType.VOICE ? "voip/VideoCall.qml" : ""
diff --git a/resources/qml/dialogs/ImagePackEditorDialog.qml b/resources/qml/dialogs/ImagePackEditorDialog.qml
index dda2c1ad5..e78213e0e 100644
--- a/resources/qml/dialogs/ImagePackEditorDialog.qml
+++ b/resources/qml/dialogs/ImagePackEditorDialog.qml
@@ -279,7 +279,6 @@ ApplicationWindow {
                         Layout.alignment: Qt.AlignRight
                     }
 
-
                     Item {
                         Layout.columnSpan: 2
                         Layout.fillHeight: true
-- 
GitLab