Skip to content

Commit a5e410a

Browse files
committed
Package app for release GH release.
1 parent 920156e commit a5e410a

File tree

7 files changed

+83
-7
lines changed

7 files changed

+83
-7
lines changed

src/ReactChat/ReactChat.AppWinForms/App.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@
1616
<!-- Create Twitter App at: https://dev.twitter.com/apps -->
1717
<add key="oauth.twitter.ConsumerKey" value="6APZQFxeVVLobXT2wRZArerg0" />
1818
<add key="oauth.twitter.ConsumerSecret" value="bKwpp31AS90MUBw1s1w0pIIdYdVEdPLa1VvobUr7IXR762hdUn" />
19+
20+
<!-- Autoupdate config-->
21+
<add key="EnableAutoUpdate" value="true" />
22+
<add key="UpdateManagerUrl" value="https://github.com/ServiceStackApps/ReactChatApps"/>
1923
</appSettings>
2024
</configuration>

src/ReactChat/ReactChat.AppWinForms/NativeHost.cs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
using System.Threading;
1+
using System;
2+
using System.Threading;
23
using System.Windows.Forms;
34
using CefSharp;
45
using CefSharp.WinForms.Internals;
56
using ServiceStack;
7+
using ServiceStack.Configuration;
8+
using Squirrel;
69

710
namespace ReactChat.AppWinForms
811
{
@@ -140,6 +143,56 @@ public void Ready()
140143
formMain.Controls.Remove(formMain.SplashPanel);
141144
});
142145
}
146+
147+
public void CheckForUpdates()
148+
{
149+
var appSettings = new AppSettings();
150+
var checkForUpdates = appSettings.Get<bool>("EnableAutoUpdate");
151+
if (!checkForUpdates)
152+
return;
153+
154+
var releaseFolderUrl = appSettings.GetString("UpdateManagerUrl");
155+
try
156+
{
157+
var updatesAvailableTask = AppUpdater.CheckForUpdates(releaseFolderUrl);
158+
updatesAvailableTask.ContinueWith(isAvailable =>
159+
{
160+
isAvailable.Wait(TimeSpan.FromMinutes(1));
161+
bool updatesAvailable = isAvailable.Result;
162+
//Only check once one launch then release UpdateManager.
163+
if (!updatesAvailable)
164+
{
165+
AppUpdater.Dispose();
166+
return;
167+
}
168+
if (formMain == null)
169+
{
170+
return;
171+
}
172+
// Notify web client updates are available.
173+
formMain.InvokeOnUiThreadIfRequired(() =>
174+
{
175+
formMain.ChromiumBrowser.GetMainFrame().ExecuteJavaScriptAsync("window.updateAvailable();");
176+
});
177+
});
178+
}
179+
catch (Exception e)
180+
{
181+
// Error reaching update server
182+
}
183+
}
184+
185+
public void PerformUpdate()
186+
{
187+
AppUpdater.ApplyUpdates(new AppSettings().GetString("UpdateManagerUrl")).ContinueWith(t =>
188+
{
189+
formMain.InvokeOnUiThreadIfRequired(() =>
190+
{
191+
formMain.Close();
192+
});
193+
UpdateManager.RestartApp();
194+
});
195+
}
143196
}
144197

145198
#if DEBUG
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
$(document).ready(function () {
22
window.nativeHost.ready();
3-
});
3+
//Wait 5 seconds then check for available updates
4+
setTimeout(function () {
5+
window.nativeHost.checkForUpdates();
6+
}, 5000);
7+
});
8+
9+
window.updateAvailable = function () {
10+
$('#announce')
11+
.fadeIn("fast")
12+
.html('Update available! <button type="button" class="btn btn-success" onclick="performUpdate();">Update</button>');
13+
};
14+
15+
window.performUpdate = function () {
16+
$('#announce').html('Updating.. Application will restart..');
17+
window.nativeHost.performUpdate();
18+
};

src/ReactChat/ReactChat.Resources/default.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<html>
33
<head lang="en">
44
<meta charset="UTF-8">
5+
<link rel="stylesheet" href="lib/css/lib.min.css">
56
<link rel="stylesheet" href="css/app.min.css">
67
<title>ReactChat</title>
78
</head>
89
<body>
9-
<div class="container">
10+
<div>
1011
<div id="app"></div>
1112
</div>
1213

src/ReactChat/ReactChat.Resources/lib/css/lib.min.css

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ReactChat/ReactChat/default.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
<html>
33
<head lang="en">
44
<meta charset="UTF-8">
5+
<!--build:css lib/css/lib.min.css -->
6+
<link rel="stylesheet" href="jspm_packages/npm/bootstrap@3.2.0/css/bootstrap.css" />
7+
<!-- endbuild -->
58
<!--build:css css/app.min.css-->
69
<link rel="stylesheet" href="css/app.css" />
710
<!-- endbuild -->
811
<title>ReactChat</title>
912
</head>
1013
<body>
11-
<div class="container">
14+
<div>
1215
<div id="app"></div>
1316
</div>
1417

src/lib/ReactChat.Resources.dll

19 KB
Binary file not shown.

0 commit comments

Comments
 (0)