mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-01 17:34:10 +02:00
Add a -debugupdates command line argument to allow prereleases in update checker
This commit is contained in:
parent
e0fe39195d
commit
391a90e1df
@ -35,7 +35,7 @@ private static UserConfig Config{
|
|||||||
|
|
||||||
private FormWindowState prevState;
|
private FormWindowState prevState;
|
||||||
|
|
||||||
public FormBrowser(PluginManager pluginManager){
|
public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName;
|
Text = Program.BrandName;
|
||||||
@ -73,7 +73,7 @@ public FormBrowser(PluginManager pluginManager){
|
|||||||
|
|
||||||
UpdateTrayIcon();
|
UpdateTrayIcon();
|
||||||
|
|
||||||
this.updates = new UpdateHandler(browser, this);
|
this.updates = new UpdateHandler(browser, this, updaterSettings);
|
||||||
this.updates.UpdateAccepted += updates_UpdateAccepted;
|
this.updates.UpdateAccepted += updates_UpdateAccepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
using TweetDck.Core.Other.Settings.Export;
|
using TweetDck.Core.Other.Settings.Export;
|
||||||
using TweetDck.Core.Handling;
|
using TweetDck.Core.Handling;
|
||||||
using TweetDck.Core.Other;
|
using TweetDck.Core.Other;
|
||||||
|
using TweetDck.Updates;
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
namespace TweetDck{
|
namespace TweetDck{
|
||||||
@ -153,7 +154,10 @@ private static void Main(){
|
|||||||
plugins.PluginChangedState += (sender, args) => UserConfig.Save();
|
plugins.PluginChangedState += (sender, args) => UserConfig.Save();
|
||||||
plugins.Reload();
|
plugins.Reload();
|
||||||
|
|
||||||
FormBrowser mainForm = new FormBrowser(plugins);
|
FormBrowser mainForm = new FormBrowser(plugins, new UpdaterSettings{
|
||||||
|
AllowPreReleases = Args.HasFlag("-debugupdates")
|
||||||
|
});
|
||||||
|
|
||||||
Application.Run(mainForm);
|
Application.Run(mainForm);
|
||||||
|
|
||||||
if (mainForm.UpdateInstallerPath != null){
|
if (mainForm.UpdateInstallerPath != null){
|
||||||
|
@ -12,7 +12,12 @@
|
|||||||
//
|
//
|
||||||
// Constant: Url that returns JSON data about latest version.
|
// Constant: Url that returns JSON data about latest version.
|
||||||
//
|
//
|
||||||
const updateCheckUrl = "https://api.github.com/repos/chylex/"+$TDU.brandName+"/releases/latest";
|
const updateCheckUrlLatest = "https://api.github.com/repos/chylex/"+$TDU.brandName+"/releases/latest";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constant: Url that returns JSON data about all versions, including prereleases.
|
||||||
|
//
|
||||||
|
const updateCheckUrlAll = "https://api.github.com/repos/chylex/"+$TDU.brandName+"/releases";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function: Creates the update notification element. Removes the old one if already exists.
|
// Function: Creates the update notification element. Removes the old one if already exists.
|
||||||
@ -135,14 +140,20 @@
|
|||||||
clearTimeout(updateCheckTimeoutID);
|
clearTimeout(updateCheckTimeoutID);
|
||||||
updateCheckTimeoutID = setTimeout(runUpdateCheck, 1000*60*60); // 1 hour
|
updateCheckTimeoutID = setTimeout(runUpdateCheck, 1000*60*60); // 1 hour
|
||||||
|
|
||||||
if (!$TDU.updateCheckEnabled && !force)return;
|
if (!$TDU.updateCheckEnabled && !force){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$.getJSON(updateCheckUrl, function(response){
|
var allowPre = $TDU.allowPreReleases;
|
||||||
var tagName = response.tag_name;
|
|
||||||
var hasUpdate = tagName !== $TDU.versionTag && tagName !== $TDU.dismissedVersionTag && response.assets.length > 0;
|
$.getJSON(allowPre ? updateCheckUrlAll : updateCheckUrlLatest, function(response){
|
||||||
|
var release = allowPre ? response[0] : response;
|
||||||
|
|
||||||
|
var tagName = release.tag_name;
|
||||||
|
var hasUpdate = tagName !== $TDU.versionTag && tagName !== $TDU.dismissedVersionTag && release.assets.length > 0;
|
||||||
|
|
||||||
if (hasUpdate){
|
if (hasUpdate){
|
||||||
var obj = response.assets.find(asset => asset.name === updateFileName) || response.assets[0];
|
var obj = release.assets.find(asset => asset.name === updateFileName) || release.assets[0];
|
||||||
createUpdateNotificationElement(tagName, obj.browser_download_url);
|
createUpdateNotificationElement(tagName, obj.browser_download_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +238,7 @@
|
|||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Resources\ScriptLoader.cs" />
|
<Compile Include="Resources\ScriptLoader.cs" />
|
||||||
|
<Compile Include="Updates\UpdaterSettings.cs" />
|
||||||
<None Include="Configuration\app.config" />
|
<None Include="Configuration\app.config" />
|
||||||
<None Include="Configuration\packages.config" />
|
<None Include="Configuration\packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -10,15 +10,18 @@ namespace TweetDck.Updates{
|
|||||||
class UpdateHandler{
|
class UpdateHandler{
|
||||||
private readonly ChromiumWebBrowser browser;
|
private readonly ChromiumWebBrowser browser;
|
||||||
private readonly FormBrowser form;
|
private readonly FormBrowser form;
|
||||||
|
private readonly UpdaterSettings settings;
|
||||||
|
|
||||||
public event EventHandler<UpdateAcceptedEventArgs> UpdateAccepted;
|
public event EventHandler<UpdateAcceptedEventArgs> UpdateAccepted;
|
||||||
public event EventHandler<UpdateCheckEventArgs> CheckFinished;
|
public event EventHandler<UpdateCheckEventArgs> CheckFinished;
|
||||||
|
|
||||||
private int lastEventId;
|
private int lastEventId;
|
||||||
|
|
||||||
public UpdateHandler(ChromiumWebBrowser browser, FormBrowser form){
|
public UpdateHandler(ChromiumWebBrowser browser, FormBrowser form, UpdaterSettings settings){
|
||||||
this.browser = browser;
|
this.browser = browser;
|
||||||
this.form = form;
|
this.form = form;
|
||||||
|
this.settings = settings;
|
||||||
|
|
||||||
browser.FrameLoadEnd += browser_FrameLoadEnd;
|
browser.FrameLoadEnd += browser_FrameLoadEnd;
|
||||||
browser.RegisterJsObject("$TDU", new Bridge(this));
|
browser.RegisterJsObject("$TDU", new Bridge(this));
|
||||||
}
|
}
|
||||||
@ -71,6 +74,12 @@ public string DismissedVersionTag{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AllowPreReleases{
|
||||||
|
get{
|
||||||
|
return owner.settings.AllowPreReleases;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsSystemSupported{
|
public bool IsSystemSupported{
|
||||||
get{
|
get{
|
||||||
return Environment.OSVersion.Version >= new Version("6.1"); // 6.1 NT version = Windows 7
|
return Environment.OSVersion.Version >= new Version("6.1"); // 6.1 NT version = Windows 7
|
||||||
|
5
Updates/UpdaterSettings.cs
Normal file
5
Updates/UpdaterSettings.cs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
namespace TweetDck.Updates{
|
||||||
|
class UpdaterSettings{
|
||||||
|
public bool AllowPreReleases { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user