Skip to content

Commit

Permalink
Package app for release GH release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Layoric committed Apr 28, 2016
1 parent 920156e commit a5e410a
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/ReactChat/ReactChat.AppWinForms/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
<!-- Create Twitter App at: https://dev.twitter.com/apps -->
<add key="oauth.twitter.ConsumerKey" value="6APZQFxeVVLobXT2wRZArerg0" />
<add key="oauth.twitter.ConsumerSecret" value="bKwpp31AS90MUBw1s1w0pIIdYdVEdPLa1VvobUr7IXR762hdUn" />

<!-- Autoupdate config-->
<add key="EnableAutoUpdate" value="true" />
<add key="UpdateManagerUrl" value="https://github.com/ServiceStackApps/ReactChatApps"/>
</appSettings>
</configuration>
55 changes: 54 additions & 1 deletion src/ReactChat/ReactChat.AppWinForms/NativeHost.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Threading;
using System;
using System.Threading;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms.Internals;
using ServiceStack;
using ServiceStack.Configuration;
using Squirrel;

namespace ReactChat.AppWinForms
{
Expand Down Expand Up @@ -140,6 +143,56 @@ public void Ready()
formMain.Controls.Remove(formMain.SplashPanel);
});
}

public void CheckForUpdates()
{
var appSettings = new AppSettings();
var checkForUpdates = appSettings.Get<bool>("EnableAutoUpdate");
if (!checkForUpdates)
return;

var releaseFolderUrl = appSettings.GetString("UpdateManagerUrl");
try
{
var updatesAvailableTask = AppUpdater.CheckForUpdates(releaseFolderUrl);
updatesAvailableTask.ContinueWith(isAvailable =>
{
isAvailable.Wait(TimeSpan.FromMinutes(1));
bool updatesAvailable = isAvailable.Result;
//Only check once one launch then release UpdateManager.
if (!updatesAvailable)
{
AppUpdater.Dispose();
return;
}
if (formMain == null)
{
return;
}
// Notify web client updates are available.
formMain.InvokeOnUiThreadIfRequired(() =>
{
formMain.ChromiumBrowser.GetMainFrame().ExecuteJavaScriptAsync("window.updateAvailable();");
});
});
}
catch (Exception e)
{
// Error reaching update server
}
}

public void PerformUpdate()
{
AppUpdater.ApplyUpdates(new AppSettings().GetString("UpdateManagerUrl")).ContinueWith(t =>
{
formMain.InvokeOnUiThreadIfRequired(() =>
{
formMain.Close();
});
UpdateManager.RestartApp();
});
}
}

#if DEBUG
Expand Down
17 changes: 16 additions & 1 deletion src/ReactChat/ReactChat.AppWinForms/platform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
$(document).ready(function () {
window.nativeHost.ready();
});
//Wait 5 seconds then check for available updates
setTimeout(function () {
window.nativeHost.checkForUpdates();
}, 5000);
});

window.updateAvailable = function () {
$('#announce')
.fadeIn("fast")
.html('Update available! <button type="button" class="btn btn-success" onclick="performUpdate();">Update</button>');
};

window.performUpdate = function () {
$('#announce').html('Updating.. Application will restart..');
window.nativeHost.performUpdate();
};
3 changes: 2 additions & 1 deletion src/ReactChat/ReactChat.Resources/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="lib/css/lib.min.css">
<link rel="stylesheet" href="css/app.min.css">
<title>ReactChat</title>
</head>
<body>
<div class="container">
<div>
<div id="app"></div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions src/ReactChat/ReactChat.Resources/lib/css/lib.min.css

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/ReactChat/ReactChat/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
<html>
<head lang="en">
<meta charset="UTF-8">
<!--build:css lib/css/lib.min.css -->
<link rel="stylesheet" href="jspm_packages/npm/bootstrap@3.2.0/css/bootstrap.css" />
<!-- endbuild -->
<!--build:css css/app.min.css-->
<link rel="stylesheet" href="css/app.css" />
<!-- endbuild -->
<title>ReactChat</title>
</head>
<body>
<div class="container">
<div>
<div id="app"></div>
</div>

Expand Down
Binary file modified src/lib/ReactChat.Resources.dll
Binary file not shown.

0 comments on commit a5e410a

Please sign in to comment.