Skip to content

Commit 4f35d08

Browse files
committed
remove toast notifications when the entire conversation is read
1 parent a143adf commit 4f35d08

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

Signal-Windows.Lib/Signal-Windows.Lib.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
<Compile Include="SignalMessageContainer.cs" />
157157
<Compile Include="Storage\DB.cs" />
158158
<Compile Include="Storage\Store.cs" />
159-
<Compile Include="Util\SignalNotificationsUtils.cs" />
159+
<Compile Include="Util\NotificationsUtils.cs" />
160160
<EmbeddedResource Include="Properties\Signal_Windows.Lib.rd.xml" />
161161
</ItemGroup>
162162
<ItemGroup>

Signal-Windows.Lib/Util/NotificationsUtils.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Signal_Windows.Lib
1212
{
1313
public class NotificationsUtils
1414
{
15+
public static ToastNotifier Notifier = ToastNotificationManager.CreateToastNotifier();
1516
public static void Notify(SignalMessage message)
1617
{
1718
TryVibrate(true);
@@ -63,7 +64,7 @@ public static void SendMessageNotification(SignalMessage message)
6364
toastNotification.ExpirationTime = DateTime.Now.Add(TimeSpan.FromSeconds(message.Author.ExpiresInSeconds));
6465
}
6566
toastNotification.Tag = notificationId;
66-
ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
67+
Notifier.Show(toastNotification);
6768
}
6869

6970
private static IList<AdaptiveText> GetNotificationText(SignalMessage message)
@@ -123,5 +124,10 @@ public static void SendTileNotification(SignalMessage message)
123124
}
124125
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
125126
}
127+
128+
public static void Withdraw(string threadId)
129+
{
130+
ToastNotificationManager.History.Remove(threadId);
131+
}
126132
}
127133
}

Signal-Windows/Controls/Conversation.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ private void ConversationSettingsButton_Click(object sender, RoutedEventArgs e)
319319
private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
320320
{
321321
int bottomIndex = GetBottommostIndex();
322-
if (SignalConversation.LastSeenMessageIndex < bottomIndex)
322+
if (Window.Current.CoreWindow.ActivationMode == CoreWindowActivationMode.ActivatedInForeground
323+
&& SignalConversation.LastSeenMessageIndex < bottomIndex)
323324
{
324325
Task.Run(() =>
325326
{

Signal-Windows/Signal-Windows.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@
315315
<Name>Windows Mobile Extensions for the UWP</Name>
316316
</SDKReference>
317317
</ItemGroup>
318-
<ItemGroup />
319318
<ItemGroup>
320319
<ProjectReference Include="..\Signal-Windows.Lib\Signal-Windows.Lib.csproj">
321320
<Project>{1934fd82-a5ea-4b71-b915-a1826593cb6e}</Project>

Signal-Windows/SignalWindowsFrontend.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,20 @@ public void HandleAttachmentStatusChanged(SignalAttachment sa)
7878
public void HandleMessageRead(long messageIndex, SignalConversation conversation)
7979
{
8080
Locator.MainPageInstance.HandleMessageRead(messageIndex, conversation);
81+
if (ApplicationView.GetForCurrentView().Id == App.MainViewId)
82+
{
83+
if (conversation.UnreadCount == 0)
84+
{
85+
NotificationsUtils.Withdraw(conversation.ThreadId);
86+
}
87+
}
8188
}
8289

8390
public void HandleUnreadMessage(SignalMessage message)
8491
{
8592
if (ApplicationView.GetForCurrentView().Id == App.MainViewId)
8693
{
87-
if (message.Author != null)
88-
{
89-
NotificationsUtils.Notify(message);
90-
}
94+
NotificationsUtils.Notify(message);
9195
}
9296
}
9397
}

0 commit comments

Comments
 (0)