diff --git a/src/main/base/app.ts b/src/main/base/app.ts index 1856fe10..4ce18bd9 100644 --- a/src/main/base/app.ts +++ b/src/main/base/app.ts @@ -4,6 +4,12 @@ import * as path from 'path'; import * as log from 'electron-log'; import {utils} from './utils'; +/** + * @file Creates App instance + * @author CiderCollective + */ + +/** @namespace */ export class AppEvents { private protocols: string[] = [ "ame", @@ -17,6 +23,7 @@ export class AppEvents { private tray: any = undefined; private i18n: any = undefined; + /** @constructor */ constructor() { this.start(); } @@ -90,6 +97,7 @@ export class AppEvents { /*********************************************************************************************************************** * Protocols **********************************************************************************************************************/ + /** */ if (process.defaultApp) { if (process.argv.length >= 2) { this.protocols.forEach((protocol: string) => { diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index b629ef8b..316a0e01 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -16,7 +16,12 @@ import {utils} from './utils'; const fileWatcher = require('chokidar'); const AdmZip = require("adm-zip"); +/** + * @file Creates the BrowserWindow + * @author CiderCollective + */ +/** @namespace */ export class BrowserWindow { public static win: any | undefined = null; private devMode: boolean = !app.isPackaged; @@ -273,6 +278,9 @@ export class BrowserWindow { /** * Creates the browser window + * @generator + * @function createWindow + * @yields {object} Electron browser window */ async createWindow(): Promise { this.clientPort = await getPort({port: 9000}); @@ -926,11 +934,11 @@ export class BrowserWindow { ipcMain.on('get-remote-pair-url', (_event, _) => { let url = `http://${BrowserWindow.getIP()}:${this.remotePort}`; - if (app.isPackaged) { + //if (app.isPackaged) { BrowserWindow.win.webContents.send('send-remote-pair-url', (`https://cider.sh/pair-remote?url=${Buffer.from(encodeURI(url)).toString('base64')}`).toString()); - } else { - BrowserWindow.win.webContents.send('send-remote-pair-url', (`http://127.0.0.1:5500/pair-remote.html?url=${Buffer.from(encodeURI(url)).toString('base64')}`).toString()); - } + //} else { + // BrowserWindow.win.webContents.send('send-remote-pair-url', (`http://127.0.0.1:5500/pair-remote.html?url=${Buffer.from(encodeURI(url)).toString('base64')}`).toString()); + //} }); if (process.platform === "darwin") { @@ -957,6 +965,7 @@ export class BrowserWindow { await utils.checkForUpdate(); }); + ipcMain.on('disable-update', (event) => { // Check if using app store builds so people don't get pissy wen button go bonk if (app.isPackaged && !process.mas || !process.windowsStore) { @@ -966,6 +975,8 @@ export class BrowserWindow { } }) + + ipcMain.on('share-menu', async (_event, url) => { if (process.platform != 'darwin') return; //https://www.electronjs.org/docs/latest/api/share-menu diff --git a/src/main/base/plugins.ts b/src/main/base/plugins.ts index a4affdde..ddaebf7c 100644 --- a/src/main/base/plugins.ts +++ b/src/main/base/plugins.ts @@ -3,6 +3,18 @@ import * as path from 'path'; import * as electron from 'electron' import {utils} from './utils'; +// +// Hello, this our loader for the various plugins that the Cider Development Team built for our +// numerous plugins internally and ones made by the community +// +// To learn how to make your own, visit https://github.com/ciderapp/Cider/wiki/Plugins +// +/** + * @class + * Plugin Loading + * @author booploops#7139 + * @see {@link https://github.com/ciderapp/Cider/wiki/Plugins|Documentation} + */ export class Plugins { private basePluginsPath = path.join(__dirname, '../plugins'); private userPluginsPath = path.join(electron.app.getPath('userData'), 'Plugins'); diff --git a/src/main/base/utils.ts b/src/main/base/utils.ts index 126f5e15..81bf8637 100644 --- a/src/main/base/utils.ts +++ b/src/main/base/utils.ts @@ -2,7 +2,7 @@ import * as fs from "fs"; import * as path from "path"; import {Store} from "./store"; import {BrowserWindow as bw} from "./browserwindow"; -import {app, dialog} from "electron"; +import {app, dialog, ipcMain, Notification, shell } from "electron"; import fetch from "electron-fetch"; import {AppImageUpdater, NsisUpdater} from "electron-updater"; import * as log from "electron-log"; @@ -115,7 +115,13 @@ export class utils { * Checks the application for updates */ static async checkForUpdate(): Promise { - + if (!app.isPackaged) { + new Notification({ title: "Application Update", body: "Can't update as app is in DEV mode. Please build or grab a copy by clicking me"}) + .on('click', () => {shell.openExternal('https://download.cider.sh/?utm_source=app&utm_medium=dev-mode-warning')}) + .show() + bw.win.webContents.send('update-response', "update-error") + return; + } // Get the artifacts const response = await fetch(`https://circleci.com/api/v1.1/project/gh/ciderapp/Cider/latest/artifacts?branch=${utils.getStoreValue('general.update_branch')}&filter=successful`) if (response.status != 200) { @@ -141,6 +147,10 @@ export class utils { autoUpdater = await new AppImageUpdater(options) //Linux and Mac (AppImages work on macOS btw) } + autoUpdater.on('checking-for-update', () => { + new Notification({ title: "Cider Update", body: "Cider is currently checking for updates."}).show() + }) + autoUpdater.on('error', (error: any) => { console.error(`[AutoUpdater] Error: ${error}`) bw.win.webContents.send('update-response', "update-error") @@ -150,6 +160,9 @@ export class utils { console.log('[AutoUpdater] Update not available.') bw.win.webContents.send('update-response', "update-not-available"); }) + autoUpdater.on('download-progress', (event: any, progress: any) => { + bw.win.setProgressBar(progress.percent / 100) + }) autoUpdater.on('update-downloaded', (info: any) => { console.log('[AutoUpdater] Update downloaded.') @@ -165,6 +178,9 @@ export class utils { dialog.showMessageBox(dialogOpts).then((returnValue) => { if (returnValue.response === 0) autoUpdater.quitAndInstall() }) + new Notification({ title: "Application Update", body: info}).on('click', () => { + bw.win.show() + }).show() }) log.transports.file.level = "debug" diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 279d69b3..eba7b124 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -3,7 +3,7 @@ import {store} from './vuex-store.js'; Vue.use(VueHorizontal); Vue.use(VueObserveVisibility); Vue.use(BootstrapVue) - +/* @namespace */ const app = new Vue({ store: store, data: { @@ -290,6 +290,13 @@ const app = new Vue({ this.lz = ipcRenderer.sendSync("get-i18n", lang) this.mklang = await this.MKJSLang() }, + /** + * Grabs translation for localization. + * @param {string} message - The key to grab the translated term + * @param {object} options - Optional options + * @author booploops#7139 + * @memberOf app + */ getLz(message, options = {}) { if (this.lz[message]) { if (options["count"]) { @@ -3993,6 +4000,8 @@ const app = new Vue({ }, checkForUpdate() { ipcRenderer.send('check-for-update') + document.getElementById('settings.option.general.updateCider.check').innerHTML = 'Checking...' + notyf.success('Checking for update in background...') ipcRenderer.on('update-response', (event, res) => { if (res === "update-not-available") { notyf.error(app.getLz(`settings.notyf.updateCider.${res}`)) @@ -4003,7 +4012,7 @@ const app = new Vue({ } else if (res === "update-timeout") { notyf.error(app.getLz(`settings.notyf.updateCider.${res}`)) } - + document.getElementById('settings.option.general.updateCider.check').innerHTML = app.getLz('term.check') }) }, } diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index c313d661..f8b3d5f2 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -731,7 +731,7 @@ {{$root.getLz('settings.option.general.updateCider')}}
-