diff --git a/public/app/listeners/index.js b/public/app/listeners/index.js index ecf7a276..2e8aa801 100644 --- a/public/app/listeners/index.js +++ b/public/app/listeners/index.js @@ -3,11 +3,10 @@ const saveSpace = require('./saveSpace'); const getSpace = require('./getSpace'); const getSpaces = require('./getSpaces'); const deleteSpace = require('./deleteSpace'); +const exportSpace = require('./exportSpace'); const showSyncSpacePrompt = require('./showSyncSpacePrompt'); const syncSpace = require('./syncSpace'); -const exportSpace = require('./exportSpace'); -const getGeolocationEnabled = require('./getGeolocationEnabled'); -const setGeolocationEnabled = require('./setGeolocationEnabled'); +const showLoadSpacePrompt = require('./showLoadSpacePrompt'); module.exports = { loadSpace, @@ -18,6 +17,5 @@ module.exports = { syncSpace, deleteSpace, exportSpace, - getGeolocationEnabled, - setGeolocationEnabled, + showLoadSpacePrompt, }; diff --git a/public/app/listeners/showLoadSpacePrompt.js b/public/app/listeners/showLoadSpacePrompt.js new file mode 100644 index 00000000..68ac471d --- /dev/null +++ b/public/app/listeners/showLoadSpacePrompt.js @@ -0,0 +1,11 @@ +// eslint-disable-next-line import/no-extraneous-dependencies +const { dialog } = require('electron'); +const { RESPOND_LOAD_SPACE_PROMPT_CHANNEL } = require('../config/channels'); + +const showLoadSpacePrompt = mainWindow => (event, options) => { + dialog.showOpenDialog(null, options, filePaths => { + mainWindow.webContents.send(RESPOND_LOAD_SPACE_PROMPT_CHANNEL, filePaths); + }); +}; + +module.exports = showLoadSpacePrompt; diff --git a/public/electron.js b/public/electron.js index bba66e4e..60ef70b1 100644 --- a/public/electron.js +++ b/public/electron.js @@ -37,7 +37,6 @@ const { SHOW_DELETE_SPACE_PROMPT_CHANNEL, SHOW_EXPORT_SPACE_PROMPT_CHANNEL, SHOW_LOAD_SPACE_PROMPT_CHANNEL, - RESPOND_LOAD_SPACE_PROMPT_CHANNEL, SAVE_SPACE_CHANNEL, GET_USER_FOLDER_CHANNEL, GET_LANGUAGE_CHANNEL, @@ -66,6 +65,7 @@ const { getSpace, deleteSpace, exportSpace, + showLoadSpace, getGeolocationEnabled, setGeolocationEnabled, } = require('./app/listeners'); @@ -181,6 +181,7 @@ const standardFileSubmenu = [ // automatically show info from package.json package_json_dir: path.join(__dirname, '../'), bug_link_text: 'Report a Bug/Issue', + // we cannot use homepage from package.json as // create-react-app uses it to build the frontend homepage: 'https://graasp.eu/', @@ -308,11 +309,7 @@ app.on('ready', async () => { ipcMain.on(EXPORT_SPACE_CHANNEL, exportSpace(mainWindow, db)); // prompt when loading a space - ipcMain.on(SHOW_LOAD_SPACE_PROMPT_CHANNEL, (event, options) => { - dialog.showOpenDialog(null, options, filePaths => { - mainWindow.webContents.send(RESPOND_LOAD_SPACE_PROMPT_CHANNEL, filePaths); - }); - }); + ipcMain.on(SHOW_LOAD_SPACE_PROMPT_CHANNEL, showLoadSpace(mainWindow, db)); // prompt when exporting a space ipcMain.on(SHOW_EXPORT_SPACE_PROMPT_CHANNEL, (event, spaceTitle) => {