@@ -53,18 +53,9 @@ public static void SetAllNotificationTimers(bool set, bool reRun)
5353 }
5454 if ( set )
5555 {
56- if ( Account . NotificationSettings . Matches )
57- {
58- Account . BackgroundThreads [ keyArray [ 0 ] ] = new Timer ( MatchOrLikeNotification , MatchOrLike . Matched , 0 , 5000 ) ;
59- }
60- if ( Account . NotificationSettings . Likes )
61- {
62- Account . BackgroundThreads [ keyArray [ 1 ] ] = new Timer ( MatchOrLikeNotification , MatchOrLike . Liked , 0 , 5000 ) ;
63- }
64- if ( Account . NotificationSettings . Chat )
65- {
66- Account . BackgroundThreads [ keyArray [ 2 ] ] = new Timer ( ChatNotifications , null , 0 , 1000 ) ;
67- }
56+ Account . BackgroundThreads [ keyArray [ 0 ] ] = new Timer ( MatchOrLikeNotification , MatchOrLike . Matched , 0 , 5000 ) ;
57+ Account . BackgroundThreads [ keyArray [ 1 ] ] = new Timer ( MatchOrLikeNotification , MatchOrLike . Liked , 0 , 5000 ) ;
58+ Account . BackgroundThreads [ keyArray [ 2 ] ] = new Timer ( ChatNotifications , null , 0 , 1000 ) ;
6859 }
6960 }
7061
@@ -125,18 +116,21 @@ private static void MatchOrLikeNotification(object matchOrLike)
125116 // If the amounts are different OR there is at least 1 new user...
126117 if ( current . Count != previous . Count || current . Count > 0 )
127118 {
119+ bool notificationsOn ;
128120 // ...reload the profiles
129121 if ( ( MatchOrLike ) matchOrLike == MatchOrLike . Matched )
130122 {
131123 ViewModelMediators . Matches = MatchHelper . LoadProfilesOfMatches ( Account . UserID . Value ) ;
124+ notificationsOn = Account . NotificationSettings . Matches ;
132125 }
133126 else
134127 {
135128 ViewModelMediators . Likes = MatchHelper . LoadProfilesOfLikes ( Account . UserID . Value ) ;
129+ notificationsOn = Account . NotificationSettings . Likes ;
136130 }
137131
138- // If the current amount are more (so there is a new user instead of an user who removed you)...
139- if ( current . Count > 0 )
132+ // If the current amount are more (so there is a new user instead of an user who removed you) and notifications are turned on ...
133+ if ( notificationsOn && current . Count > 0 )
140134 {
141135 // Throw new notification with amount of new matches or likes
142136 ThrowMatchOrLikeNotification ( ( MatchOrLike ) matchOrLike , current . Count ) ;
@@ -185,18 +179,22 @@ private static void ChatNotifications(object state)
185179 ViewModelMediators . Matches = MatchHelper . LoadProfilesOfMatches ( Account . UserID . Value ) ;
186180 }
187181
188- // Throw notifications for every new chat message
189- foreach ( ChatMessage c in unreadChatMessages )
182+ // Throw notifications for every new chat message if notifications are on
183+ if ( Account . NotificationSettings . Chat )
190184 {
191- Profile chatProfile = Account . Matches . FirstOrDefault ( p => p . UserID == c . FromUserId ) ;
192- ThrowChatMessageNotification ( chatProfile . FirstName ,
193- chatProfile . LastName ,
194- chatProfile . FirstUserMedia ,
195- c . Content ,
196- chatProfile . UserID ) ;
197- c . Seen = true ;
185+ foreach ( ChatMessage c in unreadChatMessages )
186+ {
187+ Profile chatProfile = Account . Matches . FirstOrDefault ( p => p . UserID == c . FromUserId ) ;
188+ ThrowChatMessageNotification ( chatProfile . FirstName ,
189+ chatProfile . LastName ,
190+ chatProfile . FirstUserMedia ,
191+ c . Content ,
192+ chatProfile . UserID ) ;
193+ c . Seen = true ;
194+ }
198195 }
199196
197+ // Set the NotifiedChatMessages to the newly obtained chat messages list
200198 Account . NotifiedChatMessages = newChatMessages ;
201199 }
202200 }
0 commit comments