Disable RPC by default

This commit is contained in:
Serraniel 2018-04-23 21:40:25 +02:00
parent 8ca2ec9b27
commit 7358be85e3
3 changed files with 31 additions and 24 deletions

View file

@ -261,25 +261,28 @@ namespace DML.Application.Classes
} }
} }
Logger.Info("Initializing RPC client"); if (Settings.UseRPC)
Logger.Trace("Registering RPC handlers");
RpcHandlers.readyCallback += RpcReadyCallback;
RpcHandlers.disconnectedCallback += RpcDisconnectedCallback;
RpcHandlers.errorCallback += RpcErrorCallback;
RpcPresence.startTimestamp = DiscordRpcHelper.DateTimeToTimestamp(DateTime.UtcNow);
Logger.Debug("Calling RPC initialize");
DiscordRpc.Initialize("430025401851707393", ref RpcHandlers, true, null);
// Do not await ;)
Task.Run(async () =>
{ {
while (!ShuttingDown) Logger.Info("Initializing RPC client");
Logger.Trace("Registering RPC handlers");
RpcHandlers.readyCallback += RpcReadyCallback;
RpcHandlers.disconnectedCallback += RpcDisconnectedCallback;
RpcHandlers.errorCallback += RpcErrorCallback;
RpcPresence.startTimestamp = DiscordRpcHelper.DateTimeToTimestamp(DateTime.UtcNow);
Logger.Debug("Calling RPC initialize");
DiscordRpc.Initialize("430025401851707393", ref RpcHandlers, true, null);
// Do not await ;)
Task.Run(async () =>
{ {
Logger.Trace("Running RPC callbacks"); while (!ShuttingDown)
await Task.Delay(5000); {
} Logger.Trace("Running RPC callbacks");
}); await Task.Delay(5000);
}
});
}
splash.Close(); splash.Close();

View file

@ -15,6 +15,7 @@ namespace DML.Application.Classes
public string FileNameScheme { get; set; } = @"%guild%\%channel%\%id%"; public string FileNameScheme { get; set; } = @"%guild%\%channel%\%id%";
public bool SkipExistingFiles { get; set; } = true; public bool SkipExistingFiles { get; set; } = true;
public int ThreadLimit { get; set; } = 50; public int ThreadLimit { get; set; } = 50;
public bool UseRPC { get; set; } = false;
public void Store() public void Store()
{ {

View file

@ -252,14 +252,17 @@ namespace DML.Application
lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}"; lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}";
Core.RpcPresence.details = "Downloading media files"; if (Core.Settings.UseRPC)
Core.RpcPresence.state = $"{done} / {totalAttachments} ({pgbProgress.Value}%)"; {
Core.RpcPresence.largeImageKey = "main"; Core.RpcPresence.details = "Downloading media files";
Core.RpcPresence.largeImageText = "Visit discordmedialoader.net"; Core.RpcPresence.state = $"{done} / {totalAttachments} ({pgbProgress.Value}%)";
Core.RpcPresence.smallImageKey = "author"; Core.RpcPresence.largeImageKey = "main";
Core.RpcPresence.smallImageText = "Made by Serraniel"; Core.RpcPresence.largeImageText = "Visit discordmedialoader.net";
Core.RpcPresence.smallImageKey = "author";
Core.RpcPresence.smallImageText = "Made by Serraniel";
Core.RpcUpdatePresence(); Core.RpcUpdatePresence();
}
} }
private void aboutToolStripMenuItem_Click(object sender, System.EventArgs e) private void aboutToolStripMenuItem_Click(object sender, System.EventArgs e)