Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1066 from OpenBazaar/1028
Browse files Browse the repository at this point in the history
offering a download latest link when updates are not supported
  • Loading branch information
jjeffryes authored Oct 25, 2017
2 parents eff4895 + 49ad588 commit 44d4934
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
1 change: 1 addition & 0 deletions js/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
"client": "Client",
"server": "Server",
"btnUpdateCheck": "Check for Update",
"downloadLatest": "Download Latest",
"donationsTab": {
"linkText": "Donations",
"sectionHeader": "Donations",
Expand Down
2 changes: 1 addition & 1 deletion js/models/ServerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,6 @@ export default class extends BaseModel {

isTorPwRequired() {
return ['win', 'darwin'].indexOf(remote.process.platform) > -1 &&
this.isLocalServer() && remote.getGlobal('isBundledApp')();
this.isLocalServer() && remote.getGlobal('isBundledApp');
}
}
6 changes: 3 additions & 3 deletions js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ app.connectionManagmentModal = new ConnectionManagement({
app.serverConfigs.fetch().done(() => {
if (!app.serverConfigs.length) {
// no saved server configurations
if (remote.getGlobal('isBundledApp')()) {
if (remote.getGlobal('isBundledApp')) {
// for a bundled app, we'll create a
// "default" one and try to connect
const defaultConfig = new ServerConfig({
Expand Down Expand Up @@ -604,7 +604,7 @@ app.serverConfigs.fetch().done(() => {
activeServer = app.serverConfigs.activeServer = app.serverConfigs.at(0);
}

if (activeServer.get('default') && !remote.getGlobal('isBundledApp')()) {
if (activeServer.get('default') && !remote.getGlobal('isBundledApp')) {
// Your active server is the locally bundled server, but you're
// not running the bundled app. You have bad data!
activeServer.set('default', false);
Expand Down Expand Up @@ -775,7 +775,7 @@ ipcRenderer.on('close-attempt', (e) => {
// initialize our listing delete handler
listingDeleteHandler();

if (remote.getGlobal('isBundledApp')()) {
if (remote.getGlobal('isBundledApp')) {
console.log(`%c${app.polyglot.t('consoleWarning.heading')}`,
'color: red; font-weight: bold; font-size: 50px;');
console.log(`%c${app.polyglot.t('consoleWarning.line1')}`, 'color: red;');
Expand Down
12 changes: 9 additions & 3 deletions js/templates/modals/about/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ <h2 id=tabTitle class="h3 clrT txCtr flexExpand"></h2>
<% } %>
</div>
<% if (ob.isBundledApp) { %>
<a class="btn clrP clrBAttGrad clrBrDec1 clrTOnEmph js-checkForUpdate">
<%= ob.polyT('about.btnUpdateCheck') %>
</a>
<% if (ob.updatesSupported) { %>
<a class="btn clrP clrBAttGrad clrBrDec1 clrTOnEmph js-checkForUpdate">
<%= ob.polyT('about.btnUpdateCheck') %>
</a>
<% } else { %>
<a class="btn clrP clrBAttGrad clrBrDec1 clrTOnEmph" href="https://www.openbazaar.org/download/">
<%= ob.polyT('about.downloadLatest') %>
</a>
<% } %>
<% } %>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion js/views/modals/about/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default class extends BaseModal {
};

this.currentTabName = 'Story';
this.isBundledApp = remote.getGlobal('isBundledApp')();
this.isBundledApp = remote.getGlobal('isBundledApp');
this.updatesSupported = remote.getGlobal('updatesSupported');
}

className() {
Expand Down Expand Up @@ -95,6 +96,7 @@ export default class extends BaseModal {
...this.options,
version,
isBundledApp: this.isBundledApp,
updatesSupported: this.updatesSupported,
}));
super.render();

Expand Down
26 changes: 16 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { argv } from 'yargs';
import path from 'path';
import fs from 'fs';
import childProcess from 'child_process';
import _ from 'underscore';
import { guid } from './js/utils';
import LocalServer from './js/utils/localServer';
import { bindLocalServerEvent } from './js/utils/mainProcLocalServerEvents';
Expand Down Expand Up @@ -89,11 +88,11 @@ if (handleStartupEvent()) {
const serverPath = `${__dirname}${path.sep}..${path.sep}openbazaar-go${path.sep}`;
const serverFilename = process.platform === 'darwin' || process.platform === 'linux' ?
'openbazaard' : 'openbazaard.exe';
const isBundledApp = _.once(() => fs.existsSync(serverPath + serverFilename));
const isBundledApp = fs.existsSync(serverPath + serverFilename);
global.isBundledApp = isBundledApp;
let localServer;

if (isBundledApp()) {
if (isBundledApp) {
global.localServer = localServer = new LocalServer({
serverPath,
serverFilename,
Expand All @@ -106,6 +105,9 @@ if (isBundledApp()) {
global.authCookie = guid();
}

const updatesSupported = process.platform === 'win32' || process.platform === 'darwin';
global.updatesSupported = updatesSupported;

// set the client data path
let defaultUserDataPath;

Expand All @@ -126,7 +128,7 @@ const userDataPath = argv.userData || defaultUserDataPath;
// Otherwise, if you're using the bundled app, we'll use a custom data dir (as defined
// in the switch above). Otherwise (running client from source), we won't update the data
// dir and the electron default will be used.
if (isBundledApp() || argv.userData) {
if (isBundledApp || argv.userData) {
try {
app.setPath('userData', userDataPath);
} catch (e) {
Expand All @@ -142,7 +144,7 @@ crashReporter.start({
submitURL: 'http://104.131.17.128:1127/post',
autoSubmit: true,
extra: {
bundled: isBundledApp(),
bundled: isBundledApp,
},
});

Expand Down Expand Up @@ -181,12 +183,16 @@ function createWindow() {
},
];

if (isBundledApp()) {
if (isBundledApp) {
helpSubmenu = [
{
label: 'Check for Updates...',
label: updatesSupported ? 'Check for Updates...' : 'Download Latest',
click() {
checkForUpdates();
if (updatesSupported) {
checkForUpdates();
} else {
shell.openExternal('https://www.openbazaar.org/download/');
}
},
},
{
Expand Down Expand Up @@ -497,7 +503,7 @@ function createWindow() {
* the software then they will send an IPC message back to the main process and we will
* begin to download the file and update the software.
*/
if (isBundledApp()) {
if (isBundledApp) {
autoUpdater.on('checking-for-update', () => {
mainWindow.send('updateChecking');
mainWindow.send('consoleMsg', `Checking for update at ${autoUpdater.getFeedURL()}`);
Expand Down Expand Up @@ -541,7 +547,7 @@ function createWindow() {

mainWindow.webContents.on('dom-ready', () => {
// Check for an update once the DOM is ready so the update dialog box can be shown
if (isBundledApp()) checkForUpdates();
if (isBundledApp) checkForUpdates();
});

// Set up protocol
Expand Down

0 comments on commit 44d4934

Please sign in to comment.