Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c24da14
create desktop application
spartDev Apr 11, 2018
0f1469a
Add missing dependency
mxstbr Apr 14, 2018
34e4176
add app autoUpdate
spartDev Apr 15, 2018
7be7a8c
remove unused require
spartDev Apr 15, 2018
8564ebd
rename to desktop & create build et publish scripts
spartDev Apr 15, 2018
96d960f
dmg installer enhancement
spartDev Apr 15, 2018
b2a66b0
fix dev environement
spartDev Apr 16, 2018
9405fed
fix splash screen
spartDev Apr 16, 2018
cd9b093
add about dialog
spartDev Apr 16, 2018
105ded3
rename dev:elctron script by dev:desktop
spartDev Apr 16, 2018
9fa08e8
fix missing resources folder in release build
spartDev Apr 16, 2018
d592f46
update appId to be more consistent
spartDev Apr 20, 2018
2a4b54e
simplify the development script
spartDev Apr 20, 2018
319e9f3
update documentation
spartDev Apr 20, 2018
a669d75
fix desktop dev script
spartDev Apr 20, 2018
58a1521
add new icons
spartDev Apr 22, 2018
9575846
update background dmg installer
spartDev Apr 22, 2018
e3166ff
Merge branch 'alpha' into electron-wrapper
superbryntendo May 15, 2018
105e61c
Merge branch 'alpha' into electron-wrapper
mxstbr May 25, 2018
cfb9309
Fix variable name
mxstbr May 28, 2018
cfbf1f8
Implement push notifications in desktop app
mxstbr May 28, 2018
4f97c28
Merge branch 'alpha' into electron-wrapper
mxstbr May 28, 2018
4dc5de0
Add build:desktop
mxstbr May 28, 2018
9815c97
Fix unit tests for notification-to-text util
mxstbr May 28, 2018
2e7b363
Dont send push notifications if the desktop app is focused
mxstbr May 28, 2018
0cfe8dd
Fix linux build
mxstbr May 28, 2018
0b25824
Fix windows build
mxstbr May 28, 2018
e989f4d
Build desktop apps on CircleCI
mxstbr May 28, 2018
2a0a26c
Fix yaml
mxstbr May 28, 2018
019eb77
Install desktop deps on circle
mxstbr May 28, 2018
b9695a2
Adapt electron builder options
mxstbr May 29, 2018
61b676f
Remove accidentally committed patch
mxstbr May 29, 2018
50f9c03
Cleanup
mxstbr May 29, 2018
472b708
Fix cannot read property error
mxstbr May 29, 2018
96488f6
Fix width and height values
mxstbr May 29, 2018
f3e645a
Fix ci error
mxstbr May 29, 2018
41bdad7
Make sure were not running in Cypress
mxstbr May 29, 2018
374eaec
Move desktop push sending method out of src/index.js
mxstbr May 29, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ aliases:
- &yarn
|
yarn
cd ./mobile && yarn && yarn setup
cd ./mobile && yarn && yarn setup && cd ..
cd ./desktop && yarn && cd ..

- &install-rethinkdb
name: Install RethinkDB 2.3.5
Expand Down Expand Up @@ -110,6 +111,9 @@ jobs:
- run:
name: Run Unit Tests
command: yarn run test:ci
- run:
name: Build desktop apps
command: yarn run build:desktop
- run:
name: Run E2E Tests
command: test $CYPRESS_RECORD_KEY && yarn run test:e2e -- --record || yarn run test:e2e
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ build-mercury
build-vulcan
build-hyperion
build-pluto
build-electron
build-analytics
package-lock.json
.vscode
Expand All @@ -32,6 +33,7 @@ api/.env
.expo
mobile/.expo
test-results.json
desktop/release
public/uploads
cypress/screenshots/
cypress/videos/
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ spectrum/
├── api # API server
├── athena # Worker server (notifications and general processing)
├── chronos # Worker server (cron jobs)
├── desktop # desktop apps (build with electron)
├── docs
├── email-templates
├── hermes # Worker server (email sending)
Expand Down Expand Up @@ -241,6 +242,14 @@ To develop the frontend and web UI run
yarn run dev:web
```

#### Develop the desktop app

To develop the desktop app you have to have the dev web server running in the background (`yarn run dev:web`) and then, in another terminal tab, run:

```
yarn run dev:desktop
```

#### Develop the mobile apps

To start the mobile apps run:
Expand Down Expand Up @@ -269,4 +278,3 @@ Refer to [the Expo documentation on how to install the simulators](https://docs.
## License

BSD 3-Clause, see the [LICENSE](./LICENSE) file.

6 changes: 3 additions & 3 deletions api/models/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ const hasChanged = (field: string) =>
.row('old_val')(field)
.ne(db.row('new_val')(field));

const MODIFIED_AT_CHANGED = hasChanged('entityAddedAt');
const ENTITY_ADDED = hasChanged('entityAddedAt');

const getNewNotificationsChangefeed = () =>
db
.table('usersNotifications')
.changes({
includeInitial: false,
})
.filter(NEW_DOCUMENTS.or(MODIFIED_AT_CHANGED))('new_val')
.filter(NEW_DOCUMENTS.or(ENTITY_ADDED))('new_val')
.eqJoin('notificationId', db.table('notifications'))
.without({
left: ['notificationId', 'createdAt', 'id', 'entityAddedAt'],
Expand All @@ -100,7 +100,7 @@ const getNewDirectMessageNotificationsChangefeed = () =>
.changes({
includeInitial: false,
})
.filter(NEW_DOCUMENTS.or(MODIFIED_AT_CHANGED))('new_val')
.filter(NEW_DOCUMENTS.or(ENTITY_ADDED))('new_val')
.eqJoin('notificationId', db.table('notifications'))
.without({
left: ['notificationId', 'createdAt', 'id', 'entityAddedAt'],
Expand Down
2 changes: 1 addition & 1 deletion athena/utils/push-notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const debug = require('debug')('athena:utils:send-push-notifications');
import { getSubscriptions } from '../../models/web-push-subscription';
import { getExpoSubscriptions } from 'api/models/expo-push-subscription';
import formatNotification from './notification-formatting';
import formatNotification from 'shared/notification-to-text';
import { sendWebPushNotification } from './send-web-push-notification';
import { sendExpoPushNotifications } from './send-expo-push-notifications';
import type { DBNotificationsJoin } from 'shared/types';
Expand Down
23 changes: 23 additions & 0 deletions desktop/README.md
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
79 changes: 79 additions & 0 deletions desktop/package.json
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",

This comment was marked as resolved.

This comment was marked as resolved.

"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 added desktop/resources/background.tiff
Binary file not shown.
Binary file added desktop/resources/icons/mac/icon.icns
Binary file not shown.
Binary file added desktop/resources/icons/png/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop/resources/icons/win/icon.ico
Binary file not shown.
62 changes: 62 additions & 0 deletions desktop/src/autoUpdate.js
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;
24 changes: 24 additions & 0 deletions desktop/src/config.js
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'),
};
90 changes: 90 additions & 0 deletions desktop/src/main.js
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();
}
});
Loading