diff --git a/MyPractice/Youtube/Server.cs b/MyPractice/Youtube/Server.cs index 6d96fb1..98319fc 100644 --- a/MyPractice/Youtube/Server.cs +++ b/MyPractice/Youtube/Server.cs @@ -29,7 +29,7 @@ public void UploadFinished(object? sender, DataEventArgs e) private void SendNotification() { - if (notificationHandler != null) notificationHandler.Invoke(this, data); + notificationHandler?.Invoke(this, data); } public void ViewReached(object? sender, DataEventArgs e) diff --git a/MyPractice/Youtube/Subscriber.cs b/MyPractice/Youtube/Subscriber.cs index 6944e6a..50f99c7 100644 --- a/MyPractice/Youtube/Subscriber.cs +++ b/MyPractice/Youtube/Subscriber.cs @@ -27,9 +27,9 @@ public void WatchVideo(int videoIndex, int times) { _server.data.viewCount.Add(videoIndex, times); } - if (_server.data.viewCount.GetValueOrDefault(videoIndex) >= _trendingThreshold && trendingHandler != null) + if (_server.data.viewCount.GetValueOrDefault(videoIndex) >= _trendingThreshold) { - trendingHandler.Invoke(this, _server.data); + trendingHandler?.Invoke(this, _server.data); } } else diff --git a/MyPractice/Youtube/Youtuber.cs b/MyPractice/Youtube/Youtuber.cs index deaf51b..182a454 100644 --- a/MyPractice/Youtube/Youtuber.cs +++ b/MyPractice/Youtube/Youtuber.cs @@ -29,7 +29,7 @@ private void UploadToServer(int videoIndex, string videoTitle) { _server.data.videoIndex = videoIndex; _server.data.videoTitle = videoTitle; - if (uploadHandler != null) uploadHandler.Invoke(this, _server.data); + uploadHandler?.Invoke(this, _server.data); } public void WatchVideo(int videoIndex, int times) @@ -49,9 +49,9 @@ public void WatchVideo(int videoIndex, int times) { _server.data.viewCount.Add(videoIndex, times); } - if (_server.data.viewCount.GetValueOrDefault(videoIndex) >= _server.TrendingThreshold && trendingHandler != null) + if (_server.data.viewCount.GetValueOrDefault(videoIndex) >= _server.TrendingThreshold) { - trendingHandler.Invoke(this, _server.data); + trendingHandler?.Invoke(this, _server.data); } } }