mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-14 11:34:08 +02:00
Move update notification trigger code to TweetDeckBrowser
This commit is contained in:
parent
33f8eafbcf
commit
cedc52cdf5
@ -238,8 +238,13 @@ private static void plugins_Executed(object sender, PluginErrorEventArgs e){
|
||||
private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||
this.InvokeAsyncSafe(() => {
|
||||
e.Result.Handle(update => {
|
||||
if (!update.IsUpdateNew && !update.IsUpdateDismissed){
|
||||
updates.StartTimer();
|
||||
if (!update.IsUpdateDismissed){
|
||||
if (update.IsUpdateNew){
|
||||
browser.ShowUpdateNotification(update.VersionTag, update.ReleaseNotes);
|
||||
}
|
||||
else{
|
||||
updates.StartTimer();
|
||||
}
|
||||
}
|
||||
}, ex => {
|
||||
// TODO show error and ask if the user wants to temporarily disable checks -- or maybe only do that for the first check of the day
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
@ -145,6 +146,8 @@ private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
UpdateProperties();
|
||||
TweetDeckBridge.RestoreSessionData(frame);
|
||||
ScriptLoader.ExecuteFile(frame, "code.js", browser);
|
||||
ScriptLoader.ExecuteFile(frame, "update.js", browser);
|
||||
|
||||
InjectBrowserCSS();
|
||||
ReinjectCustomCSS(Program.UserConfig.CustomBrowserCSS);
|
||||
UserConfig_SoundNotificationInfoChanged(null, EventArgs.Empty);
|
||||
@ -246,5 +249,9 @@ public void PlaySoundNotification(){
|
||||
public void ApplyROT13(){
|
||||
browser.ExecuteScriptAsync("TDGF_applyROT13()");
|
||||
}
|
||||
|
||||
public void ShowUpdateNotification(string versionTag, string releaseNotes){
|
||||
browser.ExecuteScriptAsync("TDUF_displayNotification", versionTag, Convert.ToBase64String(Encoding.GetEncoding("iso-8859-1").GetBytes(releaseNotes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
using CefSharp;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Other.Interfaces;
|
||||
using TweetDuck.Data;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Updates.Events;
|
||||
|
||||
namespace TweetDuck.Updates{
|
||||
@ -32,7 +29,6 @@ public UpdateHandler(ITweetDeckBrowser browser, UpdaterSettings settings){
|
||||
this.client = new UpdateCheckClient(settings);
|
||||
|
||||
this.browser = browser;
|
||||
this.browser.OnFrameLoaded(OnFrameLoaded);
|
||||
this.browser.RegisterBridge("$TDU", new Bridge(this));
|
||||
|
||||
this.timer = new Timer();
|
||||
@ -68,10 +64,6 @@ public void StartTimer(){
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFrameLoaded(IFrame frame){
|
||||
ScriptLoader.ExecuteFile(frame, "update.js"); // TODO can't show error on failure
|
||||
}
|
||||
|
||||
public int Check(bool force){
|
||||
if (Program.UserConfig.EnableUpdateCheck || force){
|
||||
if (force){
|
||||
@ -129,8 +121,6 @@ private void HandleUpdateCheckSuccessful(int eventId, UpdateInfo info){
|
||||
CleanupDownload();
|
||||
lastUpdateInfo = info;
|
||||
lastUpdateInfo.BeginSilentDownload();
|
||||
|
||||
browser.ExecuteFunction("TDUF_displayNotification", lastUpdateInfo.VersionTag, Convert.ToBase64String(Encoding.GetEncoding("iso-8859-1").GetBytes(lastUpdateInfo.ReleaseNotes))); // TODO move browser stuff outside
|
||||
}
|
||||
|
||||
CheckFinished?.Invoke(this, new UpdateCheckEventArgs(eventId, new Result<UpdateInfo>(info)));
|
||||
|
Loading…
Reference in New Issue
Block a user