Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Fix program crash when discord client is not initialized and user attempts to change file on editor. #39

Merged
merged 3 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,19 @@ public void UpdateWindowTitle()

outString += " - SPCode";

Program.discordClient.SetPresence(new RichPresence
if (Program.discordClient.IsInitialized)
{
Timestamps = Program.discordTime,
State = someEditorIsOpen ? $"Editing {Path.GetFileName(ee.FullFilePath)}" : "Idle",
Assets = new Assets
Program.discordClient.SetPresence(new RichPresence
{
LargeImageKey = "immagine",
}
});

Timestamps = Program.discordTime,
State = someEditorIsOpen ? $"Editing {Path.GetFileName(ee.FullFilePath)}" : "Idle",
Assets = new Assets
{
LargeImageKey = "immagine",
}
});
}

if (ServerIsRunning) outString = $"{outString} | ({Program.Translations.GetLanguage("ServerRunning")})";
Title = outString;
}
Expand Down
12 changes: 1 addition & 11 deletions UI/Windows/OptionsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,7 @@ private void DiscordPresence_Changed(object sender, RoutedEventArgs e)
// Init Discord RPC
Program.discordClient.Initialize();


// Set default presence
Program.discordClient.SetPresence(new RichPresence
{
State = "Idle",
Timestamps = Program.discordTime,
Assets = new Assets
{
LargeImageKey = "immagine"
}
});
Program.MainWindow.UpdateWindowTitle();
}
else if (!val && Program.discordClient.IsInitialized)
{
Expand Down