Skip to content

Commit ccd79f4

Browse files
committed
Mark bottommost message read when window gets focus
fixes #141
1 parent 0f13aba commit ccd79f4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Signal-Windows/Controls/Conversation.xaml.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ private void HandleWindowActivated(object sender, WindowActivatedEventArgs e)
135135
{
136136
Logger.LogTrace("HandleWindowActivated() new activation state {0}", e.WindowActivationState);
137137
ActivationState = e.WindowActivationState;
138+
MarkBottommostMessageRead();
138139
}
139140

140141
public MainPageViewModel GetMainPageVm()
@@ -382,6 +383,14 @@ private void ConversationSettingsButton_Click(object sender, RoutedEventArgs e)
382383
private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
383384
{
384385
if (ActivationState != CoreWindowActivationState.Deactivated)
386+
{
387+
MarkBottommostMessageRead();
388+
}
389+
}
390+
391+
private void MarkBottommostMessageRead()
392+
{
393+
if (Collection != null)
385394
{
386395
int bottomIndex = GetBottommostIndex();
387396
int rawBottomIndex = Collection.GetRawIndex(bottomIndex);
@@ -391,7 +400,7 @@ private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEven
391400
LastMarkReadRequest = rawBottomIndex;
392401
Task.Run(async () =>
393402
{
394-
await App.Handle.SetMessageRead(rawBottomIndex, ((SignalMessageContainer) Collection[bottomIndex]).Message, SignalConversation);
403+
await App.Handle.SetMessageRead(rawBottomIndex, ((SignalMessageContainer)Collection[bottomIndex]).Message, SignalConversation);
395404
});
396405
}
397406
}

0 commit comments

Comments
 (0)