Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix Mapeo window randomly not opening at startup #465

Merged
merged 35 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5ce9c53
chore: Add incremental Typescript checking
gmaclennan Mar 1, 2021
bb76bff
Refactor app startup code & background processes
gmaclennan Mar 28, 2021
1f83433
Manage background processes together, and time async startup actions
gmaclennan Mar 28, 2021
e8baeb8
Read backend state in main window
gmaclennan Mar 28, 2021
a39358a
Startup sequence in parallel
gmaclennan Mar 28, 2021
475c0be
remove console.log
gmaclennan Mar 28, 2021
8985c9c
Fix startup sequence
gmaclennan Mar 28, 2021
233e67e
Fix background state updates (emit after state is updated)
gmaclennan Mar 28, 2021
b267455
Update to latest electron@9
gmaclennan Mar 29, 2021
3fe762e
Fix ipc message validation
gmaclennan Mar 29, 2021
45ad431
Fix settings extraction
gmaclennan Mar 29, 2021
f775d1d
Wait for first render before showing main window
gmaclennan Mar 29, 2021
4d1ca7e
Improve logging
gmaclennan Mar 29, 2021
529f2ed
fixes for breaking mkdirp change
gmaclennan Mar 29, 2021
03215a0
add note about React devtools
gmaclennan Mar 30, 2021
d05ee85
fix lint error
gmaclennan Mar 30, 2021
1c79516
chore(tsconfig): fix typo
hackergrrl Mar 30, 2021
811b106
fix packaging config
gmaclennan Jun 4, 2021
6a15be8
fix: Fix errors from Wifi Status display and disable on MacOS
gmaclennan Jun 7, 2021
e64e519
Merge branch 'fix/wifi-info' into fix/startup-flow
gmaclennan Jun 7, 2021
e5180c2
fix: Package default config with app, rather than extracting at runtime
gmaclennan Jun 7, 2021
fc7cb2d
fix: Fix IPC messaging with main process - call port.start()
gmaclennan Jun 7, 2021
1a3eb56
fix: Fix "zoom to data": include deletions and correct density calc
gmaclennan Jun 8, 2021
06c8660
fix: Fix crash when syncing by removing non-transferable objects from…
gmaclennan Jun 8, 2021
7416619
Add message error handlers to IPC
gmaclennan Jun 8, 2021
eac2158
fix: Fix reload of Mapeo when config changes
gmaclennan Jun 8, 2021
bf1af11
Merge branch 'master' into fix/startup-flow
gmaclennan Jun 9, 2021
f7a141f
chore: update ecstatic & dedupe
gmaclennan Jun 9, 2021
6db35a0
Fix package-lock
gmaclennan Jun 9, 2021
2192e05
Catch errors on startup
gmaclennan Jun 10, 2021
f3b8004
Extend background process start timeout
gmaclennan Jun 10, 2021
425e630
throw error if starting background process fails
gmaclennan Jun 10, 2021
c33a7c7
Pass through error events from background processes
gmaclennan Jun 10, 2021
fb234ad
Cleanup subscriptions
gmaclennan Jun 10, 2021
130595e
Clear closing timeout
gmaclennan Jun 10, 2021
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ translations
storybook-static
updates
flow-typed
/**/*.d.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ bin/test-data
translations
storybook-static
updates
temp-resources
3 changes: 1 addition & 2 deletions bin/build-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ const fs = require('fs')

const readFile = util.promisify(fs.readFile)
const writeFile = util.promisify(fs.writeFile)
const mkdirpPromise = util.promisify(mkdirp)

async function readJson (file) {
return JSON.parse(await readFile(file))
}

async function writeJson (file, data) {
await mkdirpPromise(path.dirname(file))
await mkdirp(path.dirname(file))
await writeFile(file, JSON.stringify(data, null, 2))
}

Expand Down
19 changes: 19 additions & 0 deletions bin/extract-presets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const path = require('path')
const mkdirp = require('mkdirp')
const fs = require('fs-extra')
const { DEFAULT_CONFIG_DIR } = require('../config')

// This is a really hacky fix to an annoying problem. Currently mapeo-server has
// a fallbackPresetsDir option, but it expects the presets to be in a `default`
// subfolder inside that. In production we copy mapeo-default-settings into the
// app resources folder, with a `default` subfolder, but in dev we need to copy
// the default presets into a subfolder so we can use them in dev. TODO: Fix the
// API for mapeo-server

// Sorry about confusing naming, working around hard-coded paths in @mapeo/settings
const defaultConfigFolder = path.join(DEFAULT_CONFIG_DIR, 'default')
mkdirp(defaultConfigFolder)
fs.copySync(
path.dirname(require.resolve('mapeo-default-settings')),
defaultConfigFolder
)
9 changes: 6 additions & 3 deletions builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const config = {
{
from: 'build/app-update.yml',
to: 'app-update.yml'
},
{
from: path.dirname(require.resolve('mapeo-default-settings')),
to: 'presets/default'
}
]
}
Expand All @@ -75,9 +79,8 @@ const files = [
// Don't ship built sourcemaps, because they are 25Mb
'!static/*.map',
// Include everything in src/ apart from src/renderer
'src/main/**/*',
'src/background/**/**/*.{js,html}',
'src/*.js',
'src/**/*',
'!src/renderer/**/*',
// but also include src/renderer/index-preload.js since this is not included
// in the renderer bundle
'src/renderer/index-preload.js',
Expand Down
28 changes: 22 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
var path = require('path')
var APP_NAME = 'Mapeo'
var APP_TEAM = 'Digital Democracy'
var APP_VERSION = require('./package.json').version

module.exports = {
APP_NAME: APP_NAME,
APP_TEAM: APP_TEAM,
APP_VERSION: APP_VERSION,
var isElectron = typeof process.type === 'string'
// Is `true` when running from Node
var isDev = isElectron ? require('electron-is-dev') : true

MAPBOX_ACCESS_TOKEN: 'pk.eyJ1IjoiZ21hY2xlbm5hbiIsImEiOiJSaWVtd2lRIn0.ASYMZE2HhwkAw4Vt7SavEg',
// Sorry about this! In production the default config is shipped in the app
// resources folder, but for development we need to copy them into a temporary
// "resources" folder.
var RESOURCES_DIR = isDev
? path.join(__dirname, 'temp-resources')
: process.resourcesPath

module.exports = {
APP_NAME,
APP_TEAM,
APP_VERSION,
RESOURCES_DIR,
// This is super confusing... due to hard-coded paths in @mapeo/settings
// TODO: Clean all of this up in mapeo-server and @mapeo/settings
DEFAULT_CONFIG_DIR: path.join(RESOURCES_DIR, 'presets'),
MAPBOX_ACCESS_TOKEN:
'pk.eyJ1IjoiZ21hY2xlbm5hbiIsImEiOiJSaWVtd2lRIn0.ASYMZE2HhwkAw4Vt7SavEg',
GITHUB_URL: 'https://github.com/digidem/mapeo-desktop',
GITHUB_URL_RAW: 'https://raw.githubusercontent.com/digidem/mapeo-desktop/master'
GITHUB_URL_RAW:
'https://raw.githubusercontent.com/digidem/mapeo-desktop/master'
}
Loading