Skip to content

Commit

Permalink
ReSharper Code Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed May 21, 2019
1 parent dec9c2d commit dbb3f64
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
20 changes: 5 additions & 15 deletions GameFinder/DiscordHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiscordRPC;
using DiscordRPC.Logging;

Expand All @@ -15,17 +11,11 @@ public class DiscordHelper

public static void Initialize()
{
Client = new DiscordRpcClient(DiscordClientId) { Logger = new ConsoleLogger() { Level = LogLevel.Warning } };
Client = new DiscordRpcClient(DiscordClientId) { Logger = new ConsoleLogger { Level = LogLevel.Warning } };

Client.OnReady += (sender, e) =>
{
Console.WriteLine($"Discord ready! {e.User.Username}");
};
Client.OnReady += (sender, e) => { Console.WriteLine($"Discord ready! {e.User.Username}"); };

Client.OnPresenceUpdate += (sender, e) =>
{
Console.WriteLine($"Presence updated: {e.Presence}");
};
Client.OnPresenceUpdate += (sender, e) => { Console.WriteLine($"Presence updated: {e.Presence}"); };

Client.Initialize();
}
Expand All @@ -41,12 +31,12 @@ public static void SetPresence(string status)
{
Details = "GitHub: mrousavy/GameFinder",
State = status,
Assets = new Assets()
Assets = new Assets
{
LargeImageKey = "icon",
LargeImageText = "Steam GameFinder by mrousavy"
}
});
}
}
}
}
5 changes: 4 additions & 1 deletion GameFinder/Finder/FinderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ private async Task Load(PlayerSummaryModel you, ICollection<PlayerSummaryModel>
{
return;
}
DiscordHelper.SetPresence(profiles.Count > 1 ? $"Matching {profiles.Count} profiles" : $"Matching {profiles.Count} profile");

DiscordHelper.SetPresence(profiles.Count > 1
? $"Matching {profiles.Count} profiles"
: $"Matching {profiles.Count} profile");

DialogViewModel = new LoadingDialogViewModel("Matching games...");
try
Expand Down
28 changes: 14 additions & 14 deletions GameFinder/FriendChooser/FriendChooserViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
Expand Down Expand Up @@ -34,16 +35,6 @@ public FriendChooserViewModel()
ChosenFriends.CollectionChanged += ChosenFriendsCollectionChanged;
}

private void ChosenFriendsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
string presence = $"Selected {ChosenFriends.Count} friend";
if (ChosenFriends.Count != 1)
{
presence += "s";
}
DiscordHelper.SetPresence(presence);
}

public ObservableCollection<UserSmallViewModel> AllFriends
{
get => _allFriends;
Expand Down Expand Up @@ -78,6 +69,17 @@ public ICommand OkCommand
set => Set(ref _okCommand, value);
}

private void ChosenFriendsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
string presence = $"Selected {ChosenFriends.Count} friend";
if (ChosenFriends.Count != 1)
{
presence += "s";
}

DiscordHelper.SetPresence(presence);
}

private async void OkAction(object o)
{
DialogViewModel = new LoadingDialogViewModel("Loading games...");
Expand All @@ -97,8 +99,7 @@ private async void OkAction(object o)

IsDialogOpen = false;
Extensions.MoveForwards();
}
catch (Exception ex)
} catch (Exception ex)
{
DialogViewModel = new ErrorDialogViewModel(
$"Could not load selected profiles! Perhaps a profile is set to private?\n\r{ex.Message}");
Expand Down Expand Up @@ -126,8 +127,7 @@ private async Task LoadAsync()
AllFriends = new ObservableCollection<UserSmallViewModel>(ordered);

IsDialogOpen = false;
}
catch (Exception ex)
} catch (Exception ex)
{
DialogViewModel = new ErrorDialogViewModel(
$"Could not load friends! Check your API Key, User ID and profile visibility!\n\r{ex.Message}");
Expand Down
6 changes: 2 additions & 4 deletions GameFinder/Login/LoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ private static void ApiKeyAction(object o)
try
{
Process.Start("steam://openurl/https://steamcommunity.com/dev/apikey");
}
catch
} catch
{
Process.Start("https://steamcommunity.com/dev/apikey");
}
Expand All @@ -108,8 +107,7 @@ private void LoginAction(object o)
{
Model.Login(ApiKey, UserId);
IsDialogOpen = false;
}
catch
} catch
{
DialogViewModel = new ErrorDialogViewModel("The given API Key or User ID is invalid!\n\r" +
"Please check your inputs and try again!");
Expand Down

0 comments on commit dbb3f64

Please sign in to comment.