Skip to content

Commit

Permalink
imp - Used PlatformOpen()
Browse files Browse the repository at this point in the history
---

This is to reduce code repetition and increase consistency as SpecProbe
gets updated.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Dec 19, 2024
1 parent 863cfb3 commit a0eec92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using Textify.General;
using Nitrocid.Kernel;
using Nitrocid.Shell.ShellBase.Commands.ProcessExecution;
using SpecProbe.Software.Platform;

namespace Nitrocid.Extras.MailShell.Tools
{
Expand Down Expand Up @@ -58,12 +59,7 @@ public static void HandleWebAlert(object? sender, WebAlertEventArgs e)
DebugWriter.WriteDebug(DebugLevel.I, "WebAlert URI: {0}", e.WebUri.AbsoluteUri);
TextWriters.Write(e.Message, true, KernelColorType.Warning);
TextWriterColor.Write(Translate.DoTranslation("Opening URL... Make sure to follow the steps shown on the screen."));
if (KernelPlatform.IsOnWindows())
ProcessExecutor.ExecuteProcess("cmd.exe", $"/c \"start {e.WebUri.AbsoluteUri}\"");
else if (KernelPlatform.IsOnMacOS())
ProcessExecutor.ExecuteProcess("open", e.WebUri.AbsoluteUri);
else
ProcessExecutor.ExecuteProcess("xdg-open", e.WebUri.AbsoluteUri);
PlatformHelper.PlatformOpen(e.WebUri.AbsoluteUri);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Nitrocid.Languages;
using Nitrocid.Shell.ShellBase.Commands;
using Nitrocid.Shell.ShellBase.Commands.ProcessExecution;
using SpecProbe.Software.Platform;

namespace Nitrocid.Extras.RssShell.RSS.Commands
{
Expand Down Expand Up @@ -53,12 +54,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal
else if (!string.IsNullOrWhiteSpace(article.ArticleLink))
{
DebugWriter.WriteDebug(DebugLevel.I, "Opening web browser to {0}...", article.ArticleLink);
if (KernelPlatform.IsOnWindows())
ProcessExecutor.ExecuteProcess("cmd.exe", $"/c \"start {article.ArticleLink}\"");
else if (KernelPlatform.IsOnMacOS())
ProcessExecutor.ExecuteProcess("open", article.ArticleLink);
else
ProcessExecutor.ExecuteProcess("xdg-open", article.ArticleLink);
PlatformHelper.PlatformOpen(article.ArticleLink);
return 0;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using Nitrocid.Shell.ShellBase.Commands.ProcessExecution;
using Nitrocid.Kernel;
using Nitrocid.ConsoleBase.Colors;
using SpecProbe.Software.Platform;

namespace Nitrocid.Extras.RssShell.RSS.Interactive
{
Expand Down Expand Up @@ -138,12 +139,7 @@ internal void OpenArticleLink(RSSArticle? item)
// Now, open the host browser
try
{
if (KernelPlatform.IsOnWindows())
ProcessExecutor.ExecuteProcess("cmd.exe", $"/c \"start {item.ArticleLink}\"");
else if (KernelPlatform.IsOnMacOS())
ProcessExecutor.ExecuteProcess("open", item.ArticleLink);
else
ProcessExecutor.ExecuteProcess("xdg-open", item.ArticleLink);
PlatformHelper.PlatformOpen(item.ArticleLink);
}
catch (Exception e)
{
Expand Down

0 comments on commit a0eec92

Please sign in to comment.