This repository was archived by the owner on Oct 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Desktop app #2825
Merged
Merged
Desktop app #2825
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c24da14
create desktop application
spartDev 0f1469a
Add missing dependency
mxstbr 34e4176
add app autoUpdate
spartDev 7be7a8c
remove unused require
spartDev 8564ebd
rename to desktop & create build et publish scripts
spartDev 96d960f
dmg installer enhancement
spartDev b2a66b0
fix dev environement
spartDev 9405fed
fix splash screen
spartDev cd9b093
add about dialog
spartDev 105ded3
rename dev:elctron script by dev:desktop
spartDev 9fa08e8
fix missing resources folder in release build
spartDev d592f46
update appId to be more consistent
spartDev 2a4b54e
simplify the development script
spartDev 319e9f3
update documentation
spartDev a669d75
fix desktop dev script
spartDev 58a1521
add new icons
spartDev 9575846
update background dmg installer
spartDev e3166ff
Merge branch 'alpha' into electron-wrapper
superbryntendo 105e61c
Merge branch 'alpha' into electron-wrapper
mxstbr cfb9309
Fix variable name
mxstbr cfbf1f8
Implement push notifications in desktop app
mxstbr 4f97c28
Merge branch 'alpha' into electron-wrapper
mxstbr 4dc5de0
Add build:desktop
mxstbr 9815c97
Fix unit tests for notification-to-text util
mxstbr 2e7b363
Dont send push notifications if the desktop app is focused
mxstbr 0cfe8dd
Fix linux build
mxstbr 0b25824
Fix windows build
mxstbr e989f4d
Build desktop apps on CircleCI
mxstbr 2a0a26c
Fix yaml
mxstbr 019eb77
Install desktop deps on circle
mxstbr b9695a2
Adapt electron builder options
mxstbr 61b676f
Remove accidentally committed patch
mxstbr 50f9c03
Cleanup
mxstbr 472b708
Fix cannot read property error
mxstbr 96488f6
Fix width and height values
mxstbr f3e645a
Fix ci error
mxstbr 41bdad7
Make sure were not running in Cypress
mxstbr 374eaec
Move desktop push sending method out of src/index.js
mxstbr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Desktop | ||
|
|
||
| **This folder contains all sources used to build spectrum desktop application.** | ||
|
|
||
| The project uses [Electron](https://electronjs.org/) to build cross platform desktop apps with JavaScript, HTML, and CSS. | ||
|
|
||
| ## Directory Structure | ||
|
|
||
| * `release/` - the release build for each platform (mac, win, linux). | ||
| * `resources/` - the resources folder (icons, images ...). | ||
| * `src/` the source code of electron application. | ||
| * `package.json` - dependencies & devdependencies. | ||
| * `yarn.lock` - Yarn lockfile to get consistent installs across machine. | ||
|
|
||
| ## Scripts | ||
|
|
||
| The project uses [Electron-builder](https://www.electron.build/) to package & build a ready for distribution Electron app for macOS, Windows and Linux with “auto update” support out of the box. | ||
|
|
||
| * `dev` - run electron app in development mode. | ||
| * `package` - Build unpacked dir. Useful to test. | ||
| * `package:<target>` build electron app for target platform (mac, linux, win). | ||
| * `package:all` - build electron app for all platform. | ||
| * `ship` - build and publish artifacts (to GitHub Releases). See https://goo.gl/tSFycD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| { | ||
| "name": "Spectrum", | ||
| "description": "The community platform for the future.", | ||
| "homepage": "https://spectrum.chat", | ||
| "author": { | ||
| "name": "Space Program Inc.", | ||
| "email": "hey@spectrum.chat" | ||
| }, | ||
| "version": "1.0.0", | ||
| "main": "src/main.js", | ||
| "private": true, | ||
| "dependencies": { | ||
| "electron-is-dev": "^0.3.0", | ||
| "electron-log": "^2.2.14", | ||
| "electron-updater": "^2.21.4" | ||
| }, | ||
| "devDependencies": { | ||
| "electron": "^1.8.4", | ||
| "electron-builder": "^20.8.1" | ||
| }, | ||
| "scripts": { | ||
| "dev": "electron ./src/main.js", | ||
| "package": "build --dir", | ||
| "package:mac": "build --mac", | ||
| "package:linux": "build --linux", | ||
| "package:win": "build --win --x64", | ||
| "package:all": "build -mwl", | ||
| "ship": "build -p always" | ||
| }, | ||
| "build": { | ||
| "productName": "Spectrum", | ||
| "appId": "chat.spectrum", | ||
| "copyright": "Copyright © 2018 Space Program Inc.", | ||
| "files": [ | ||
| "src/**/*", | ||
| "node_modules/**/*", | ||
| "resources/**/*", | ||
| "package.json" | ||
| ], | ||
| "directories": { | ||
| "buildResources": "resources", | ||
| "output": "release" | ||
| }, | ||
| "mac": { | ||
| "category": "public.app-category.social-networking", | ||
| "target": "default", | ||
| "icon": "resources/icons/mac/icon.icns" | ||
| }, | ||
| "dmg": { | ||
| "background": "resources/background.tiff", | ||
| "iconTextSize": 14, | ||
| "contents": [ | ||
| { | ||
| "x": 158, | ||
| "y": 213, | ||
| "type": "file" | ||
| }, | ||
| { | ||
| "x": 385, | ||
| "y": 213, | ||
| "type": "link", | ||
| "path": "/Applications" | ||
| } | ||
| ] | ||
| }, | ||
| "linux": { | ||
| "icon": "resources/icons/png/icon-512x512.png", | ||
| "category": "Network", | ||
| "target": [ | ||
| "AppImage", | ||
| "deb" | ||
| ] | ||
| }, | ||
| "win": { | ||
| "target": "nsis", | ||
| "icon": "resources/icons/win/icon.ico" | ||
| } | ||
| } | ||
| } | ||
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| const { app, dialog } = require('electron'); | ||
| const { autoUpdater } = require('electron-updater'); | ||
| const log = require('electron-log'); | ||
|
|
||
| // Setup logger | ||
| autoUpdater.logger = log; | ||
| autoUpdater.logger.transports.file.level = 'info'; | ||
|
|
||
| log.info('App starting...'); | ||
|
|
||
| // Setup update event | ||
| autoUpdater.on('checking-for-update', () => { | ||
| log.info('Checking for update... Please wait.'); | ||
| }); | ||
| autoUpdater.on('update-available', info => { | ||
| log.info('Update available.'); | ||
| log.info('Vesrion', info.version); | ||
| log.info('Release date', info.releaseDate); | ||
| }); | ||
| autoUpdater.on('update-not-available', info => { | ||
| log.info('Update not available.'); | ||
| }); | ||
| autoUpdater.on('download-progress', progress => { | ||
| log.info(`Download progress: ${Math.floor(progress.percent)}`); | ||
| }); | ||
| autoUpdater.on('update-downloaded', info => { | ||
| log.info('Update downloaded'); | ||
| }); | ||
| autoUpdater.on('error', error => { | ||
| log.info('Update error', error); | ||
| }); | ||
|
|
||
| function updateDownloaded() { | ||
| // Ask user to update the app | ||
| dialog.showMessageBox( | ||
| { | ||
| type: 'question', | ||
| message: 'A new version of ' + app.getName() + ' has been downloaded', | ||
| buttons: ['Install and Relaunch', 'Later'], | ||
| defaultId: 0, | ||
| }, | ||
| response => { | ||
| if (response === 1) { | ||
| dialog.showMessageBox({ | ||
| title: 'Installing Later', | ||
| message: 'Update will be installed when you exit the app', | ||
| }); | ||
| } else { | ||
| autoUpdater.quitAndInstall(); | ||
| } | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| function checkForUpdates() { | ||
| autoUpdater.on('update-downloaded', updateDownloaded); | ||
|
|
||
| // init for updates | ||
| autoUpdater.checkForUpdates(); | ||
| } | ||
|
|
||
| module.exports = checkForUpdates; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| const { app } = require('electron'); | ||
| const { resolve } = require('path'); | ||
|
|
||
| /** | ||
| * Applications Configuration | ||
| **/ | ||
|
|
||
| module.exports = { | ||
| APP_NAME: 'Spectrum', | ||
| APP_VERSION: app.getVersion(), | ||
| APP_REMOTE_URL: 'https://spectrum.chat/', | ||
| APP_DEV_URL: 'http://localhost:3000', | ||
|
|
||
| GITHUB_URL: 'https://github.com/withspectrum/spectrum', | ||
| GITHUB_URL_LICENSE: | ||
| 'https://github.com/withspectrum/spectrum/blob/alpha/LICENSE', | ||
| GITHUB_URL_ISSUES: 'https://github.com/withspectrum/spectrum/issues', | ||
|
|
||
| WINDOW_MIN_HEIGHT: 500, | ||
| WINDOW_MIN_WIDTH: 770, | ||
| WINDOW_BG_COLOR: '#FFFFFF', | ||
|
|
||
| ICON: resolve(__dirname, '../resources/icons/png/icon-512x512.png'), | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| const { app, BrowserWindow, Menu, shell, ipcMain } = require('electron'); | ||
| const isDev = require('electron-is-dev'); | ||
| const https = require('https'); | ||
| const path = require('path'); | ||
| const url = require('url'); | ||
|
|
||
| const checkForUpdates = require('./autoUpdate'); | ||
| const buildMenu = require('./menu'); | ||
| const CONFIG = require('./config'); | ||
|
|
||
| // Keep a global reference of the window object, if you don't, the window will | ||
| // be closed automatically when the JavaScript object is garbage collected. | ||
| let win; | ||
|
|
||
| const startUrl = isDev ? CONFIG.APP_DEV_URL : CONFIG.APP_REMOTE_URL; | ||
|
|
||
| function createWindow() { | ||
| if (!isDev) { | ||
| // trigger autoupdate check | ||
| checkForUpdates(); | ||
| } | ||
|
|
||
| // create a `splash` window | ||
| splash = new BrowserWindow({ | ||
| width: 768, | ||
| height: 408, | ||
| transparent: true, | ||
| frame: false, | ||
| alwaysOnTop: true, | ||
| }); | ||
| splash.loadURL(`file://${__dirname}/splash.html`); | ||
|
|
||
| // Create the main browser window. | ||
| mainWindow = new BrowserWindow({ | ||
| height: 800, | ||
| width: 1300, | ||
| minHeight: CONFIG.WINDOW_MIN_HEIGHT, | ||
| minWidth: CONFIG.WINDOW_MIN_WIDTH, | ||
| backgroundColor: CONFIG.WINDOW_BG_COLOR, | ||
| /** | ||
| * Disable Electron's Node integration to prevent untrusted client | ||
| * code from having access to the process and file system: | ||
| * - https://github.com/atom/electron/issues/254 | ||
| * - https://github.com/atom/electron/issues/1753 | ||
| */ | ||
| webPreferences: { | ||
| nodeIntegration: false, | ||
| preload: __dirname + '/preload.js', | ||
| }, | ||
| show: false, | ||
| }); | ||
|
|
||
| // Load Remote Url | ||
| mainWindow.loadURL(startUrl); | ||
|
|
||
| // Build application menu | ||
| buildMenu(); | ||
|
|
||
| mainWindow.on('closed', () => { | ||
| win = null; | ||
| }); | ||
|
|
||
| // if main window is ready to show, then destroy the splash window and show up the main window | ||
| mainWindow.once('ready-to-show', () => { | ||
| splash.destroy(); | ||
| mainWindow.show(); | ||
| }); | ||
| } | ||
|
|
||
| // This method will be called when Electron has finished | ||
| // initialization and is ready to create browser windows. | ||
| // Some APIs can only be used after this event occurs. | ||
| app.on('ready', createWindow); | ||
|
|
||
| // Quit when all windows are closed. | ||
| app.on('window-all-closed', () => { | ||
| // On OS X it is common for applications and their menu bar | ||
| // to stay active until the user quits explicitly with Cmd + Q | ||
| if (process.platform !== 'darwin') { | ||
| app.quit(); | ||
| } | ||
| }); | ||
|
|
||
| app.on('activate', () => { | ||
| // On OS X it's common to re-create a window in the app when the | ||
| // dock icon is clicked and there are no other windows open. | ||
| if (mainWindow === null) { | ||
| createWindow(); | ||
| } | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.