From 7eb233538804d9f7f236f8eae21a0b6b031f54d5 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Wed, 11 Dec 2024 11:01:00 +0100 Subject: [PATCH] WIP: Simplify communication --- app/lib/index.js | 19 +++++++++---------- app/lib/preload.js | 11 +---------- client/src/app/App.js | 9 +++++---- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/app/lib/index.js b/app/lib/index.js index 3f09367f5f..54acd4ee74 100644 --- a/app/lib/index.js +++ b/app/lib/index.js @@ -757,19 +757,18 @@ function bootstrap() { // (11) file context const fileContext = new FileContext(Log('app:file-context')); - function onIndexerUpdated() { - const items = fileContext._indexer.getItems(); - - renderer.send('file-context:indexer-items-updated', items.map(({ file, metadata = {} }) => { - return { - file, - metadata - }; - })); + /** + * @param { import('./file-context/types').IndexItem } item + */ + function onIndexerUpdated(item) { + + renderer.send('file-context:changed', { + file: item.file, + metadata: item.metadata + }); } fileContext.on('indexer:updated', onIndexerUpdated); - fileContext.on('indexer:removed', onIndexerUpdated); app.on('quit', () => fileContext.close()); diff --git a/app/lib/preload.js b/app/lib/preload.js index 9197681a12..79aa2e0f31 100644 --- a/app/lib/preload.js +++ b/app/lib/preload.js @@ -52,16 +52,7 @@ const allowedEvents = [ 'zeebe:deploy', 'zeebe:getGatewayVersion', 'zeebe:run', - 'file-context:add-root', - 'file-context:remove-root', - 'file-context:add-file', - 'file-context:update-file', - 'file-context:remove-file', - 'file-context:file-opened', // TODO: fix naming (this event is renderer -> main) - 'file-context:file-content-changed', // TODO: fix naming (this event is renderer -> main) - 'file-context:file-closed', // TODO: fix naming (this event is renderer -> main) - 'file-context:indexer-get-items', // TODO: fix naming (this event is renderer -> main) - 'file-context:indexer-items-updated' // TODO: fix naming (this event is main -> renderer) + 'file-context:changed' ]; let executed = false; diff --git a/client/src/app/App.js b/client/src/app/App.js index 653a4a3f25..a7f38c2ebd 100644 --- a/client/src/app/App.js +++ b/client/src/app/App.js @@ -217,6 +217,8 @@ export class App extends PureComponent { unsavedState = this.setUnsaved(tab, properties.unsaved); } + this._onTabOpened(tab); + return { ...unsavedState, tabs: [ @@ -230,6 +232,9 @@ export class App extends PureComponent { return tab; } + _onTabOpened(tab) { + console.log('FIX ME: send to backend'); + } /** * Navigate shown tabs in given direction. @@ -728,10 +733,6 @@ export class App extends PureComponent { } } - openedTabs.forEach(tab => { - // this.getGlobal('backend').send('file-context:add-file', tab.file.path); - }); - return openedTabs; };