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

Commit 252407c

Browse files
Merge pull request #39 from Natanel-Shitrit/master
1. Fix program crash when discord client is not initialized and user attempts to change file on editor. 2. Now Discord RPC will show active file when re-activeted
2 parents 8a46806 + 86a8742 commit 252407c

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

UI/MainWindow.xaml.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,19 @@ public void UpdateWindowTitle()
311311

312312
outString += " - SPCode";
313313

314-
Program.discordClient.SetPresence(new RichPresence
314+
if (Program.discordClient.IsInitialized)
315315
{
316-
Timestamps = Program.discordTime,
317-
State = someEditorIsOpen ? $"Editing {Path.GetFileName(ee.FullFilePath)}" : "Idle",
318-
Assets = new Assets
316+
Program.discordClient.SetPresence(new RichPresence
319317
{
320-
LargeImageKey = "immagine",
321-
}
322-
});
323-
318+
Timestamps = Program.discordTime,
319+
State = someEditorIsOpen ? $"Editing {Path.GetFileName(ee.FullFilePath)}" : "Idle",
320+
Assets = new Assets
321+
{
322+
LargeImageKey = "immagine",
323+
}
324+
});
325+
}
326+
324327
if (ServerIsRunning) outString = $"{outString} | ({Program.Translations.GetLanguage("ServerRunning")})";
325328
Title = outString;
326329
}

UI/Windows/OptionsWindow.xaml.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,17 +425,7 @@ private void DiscordPresence_Changed(object sender, RoutedEventArgs e)
425425
// Init Discord RPC
426426
Program.discordClient.Initialize();
427427

428-
429-
// Set default presence
430-
Program.discordClient.SetPresence(new RichPresence
431-
{
432-
State = "Idle",
433-
Timestamps = Program.discordTime,
434-
Assets = new Assets
435-
{
436-
LargeImageKey = "immagine"
437-
}
438-
});
428+
Program.MainWindow.UpdateWindowTitle();
439429
}
440430
else if (!val && Program.discordClient.IsInitialized)
441431
{

0 commit comments

Comments
 (0)