Skip to content

Commit

Permalink
Don't spam update notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
koyuawsmbrtn committed Jan 12, 2024
1 parent d471e8d commit f14a160
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
10 changes: 5 additions & 5 deletions PlaySync/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 26 additions & 23 deletions PlaySync/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using Microsoft.Win32;
using static System.Net.Mime.MediaTypeNames;

namespace PlaySync
{
Expand All @@ -24,7 +25,9 @@ public partial class Main : Form
bool pluggedin = false;
bool syncing = false;
bool cansync = false;
string version = "1";
bool updateshown = false;
bool autostart = false;
string version = "2";
string oldtext = "";
string deviceinfo = "";
string[] games;
Expand Down Expand Up @@ -74,7 +77,6 @@ public Main()
toolStripMenuItem2.Checked = false;
}
string[] args = Environment.GetCommandLineArgs();
bool autostart = false;
foreach (string arg in args)
{
if (arg == "--autostart")
Expand All @@ -84,26 +86,6 @@ public Main()
this.WindowState = FormWindowState.Minimized;
}
}
if (!autostart)
{
try
{
string pubv = new WebClient().DownloadString("https://updates.koyu.space/playsync/latest");
if (pubv.Split('\n')[0] != version)
{
DialogResult result = MessageBox.Show("New update available. Download now?", "New update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
launchUrl("https://updates.koyu.space/playsync/playsync.zip");
}
}
else
{
MessageBox.Show("PlaySync is up to date!", "Up to date", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch { }
}
}

private void readGames(string readfolder)
Expand Down Expand Up @@ -1211,6 +1193,27 @@ private void Main_Load(object sender, EventArgs e)
Environment.Exit(0);
}
notifyIcon1.ContextMenuStrip = contextMenuStrip1;
if (!autostart && !updateshown)
{
updateshown = true;
try
{
string pubv = new WebClient().DownloadString("https://updates.koyu.space/playsync/latest");
if (pubv.Split('\n')[0] != version)
{
Thread t = new Thread(() => {
DialogResult result = MessageBox.Show("New update available. Download now?", "New update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
launchUrl("https://updates.koyu.space/playsync/playsync.zip");
}
}
);
t.Start();
}
}
catch { }
}
}

private void toDeviceToolStripMenuItem_Click(object sender, EventArgs e)
Expand All @@ -1231,7 +1234,7 @@ private void toolStripMenuItem2_Click(object sender, EventArgs e)
else
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rk.SetValue("PlaySync", "\"" + Application.ExecutablePath + "\" --autostart");
rk.SetValue("PlaySync", "\"" + System.Windows.Forms.Application.ExecutablePath + "\" --autostart");
toolStripMenuItem2.Checked = true;
}
}
Expand Down

0 comments on commit f14a160

Please sign in to comment.