Skip to content

Commit 2dbc450

Browse files
committed
wrap suspicious part of ScrollViewer_ViewChanged() into a try/catch block
1 parent 678e98b commit 2dbc450

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Signal-Windows/Controls/Conversation.xaml.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,23 @@ private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEven
331331
{
332332
int bottomIndex = GetBottommostIndex();
333333
Logger.LogTrace("ScrollViewer_ViewChanged() bottomIndex={}", bottomIndex);
334-
if (Window.Current.CoreWindow.ActivationMode == CoreWindowActivationMode.ActivatedInForeground &&
335-
SignalConversation.LastSeenMessageIndex < bottomIndex &&
336-
LastMarkReadRequest < bottomIndex)
334+
try
337335
{
338-
Logger.LogTrace("ScrollViewer_ViewChanged() setting index {0} as read", bottomIndex);
339-
LastMarkReadRequest = bottomIndex;
340-
Task.Run(async () =>
336+
if (Window.Current.CoreWindow.ActivationMode == CoreWindowActivationMode.ActivatedInForeground &&
337+
SignalConversation.LastSeenMessageIndex < bottomIndex &&
338+
LastMarkReadRequest < bottomIndex)
341339
{
342-
await App.Handle.SetMessageRead(bottomIndex, SignalConversation);
343-
});
340+
Logger.LogTrace("ScrollViewer_ViewChanged() setting index {0} as read", bottomIndex);
341+
LastMarkReadRequest = bottomIndex;
342+
Task.Run(async () =>
343+
{
344+
await App.Handle.SetMessageRead(bottomIndex, SignalConversation);
345+
});
346+
}
347+
}
348+
catch(Exception ex)
349+
{
350+
Logger.LogError("ScrollViewer_ViewChanged() failed: {0}\n{1}", ex.Message, ex.StackTrace);
344351
}
345352
}
346353
}

0 commit comments

Comments
 (0)