-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect OS and provide download link #236
Comments
I would like to take up this issue. |
Sure. I have assigned this to you. |
@ritz078 can you suggest what should I do? |
Nested ternary operator is never a good idea. Why not simplify the code: var platformOs = platform.os.toString();
var linuxDownloadButton = (
<a href={linuxUrl} target="_blank">
<button className="download-button">
<Icon path={mdiLinux} size={1.2} />
</button>
</a>
);
var macOSDownloadButton = (
<a href={macUrl} target="_blank">
<button className="download-button">
<Icon path={mdiApple} size={1.2} />
</button>
</a>
);
var windowsDownloadButton = (
<button title="Coming soon" disabled className="download-button">
<Icon path={mdiMicrosoftWindows} size={1.2} />
</button>
);
var githubRepoButton = (
<a href="https://github.com/ritz078/moose" target="_blank">
<button className="download-button">
<Icon path={mdiGithub} size={1.2} />
</button>
</a>
);
return (
<div>
....
<div>
<img className="logo" src="/logo.svg" alt="" />
<span>A torrent client to download, stream and cast torrents.</span>
<div className="downloads">
{platformOs.match(/Mac OS/i) && macOSDownloadButton}
{platformOs.match(/Win/i) && macOSDownloadButton}
{platformOs.match(/Linux/i) && linuxDownloadButton}
{githubRepoButton}
</div>
</div>
....
</div>
); |
@ritz078 Ohh, that looks very neat. ✨ |
You should have directly opened a PR. We can discuss code changes in the PR. Issue is just for discussing the problem. Not improving the code.
|
Go ahead and open a PR. I will be able to see this in action there. |
Yeah will do now. Was a bit confused about that.. |
Oh. See the code again. There's a typo. 😛 <div className="downloads">
{platformOs.match(/Mac OS/i) && macOSDownloadButton}
- {platformOs.match(/Win/i) && macOSDownloadButton}
+ {platformOs.match(/Win/i) && windowsDownloadButton}
{platformOs.match(/Linux/i) && linuxDownloadButton}
{githubRepoButton}
</div> Line no 3 should be |
Right now we show all the download links for different OS. We should automatically detect the OS, the user is on and provide a single download link.
The text was updated successfully, but these errors were encountered: