Skip to content

Commit

Permalink
WIP: Simplify communication
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Dec 11, 2024
1 parent 4409099 commit 7eb2335
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
19 changes: 9 additions & 10 deletions app/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
11 changes: 1 addition & 10 deletions app/lib/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions client/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ export class App extends PureComponent {
unsavedState = this.setUnsaved(tab, properties.unsaved);
}

this._onTabOpened(tab);

return {
...unsavedState,
tabs: [
Expand All @@ -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.
Expand Down Expand Up @@ -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;
};

Expand Down

0 comments on commit 7eb2335

Please sign in to comment.