fix: prevent duplicate docker ipc registeration#16
Merged
invisal merged 5 commits intoouterbase:masterfrom Dec 19, 2024
Merged
Conversation
Collaborator
|
This does not truly solve the problem because we need https://github.com/outerbase/studio-desktop/blob/master/electron/main.ts#L57 Make the win inside the object and we can pass the object to dockerIpc. Then we can do |
Collaborator
Author
|
Got it |
invisal
requested changes
Dec 19, 2024
electron/main.ts
Outdated
Comment on lines
+57
to
+61
| const application: { | ||
| win?: BrowserWindow; | ||
| } = { | ||
| win: undefined, | ||
| }; |
Collaborator
There was a problem hiding this comment.
You can create OuterbaseApplication type to be {win?: BrowserWindow | null} so that you can reuse it in the dockerIpc
electron/ipc/docker.ts
Outdated
| if (handlersBound) return; // Prevent duplicate registrations | ||
| handlersBound = true; | ||
|
|
||
| export function bindDockerIpc({ win }: { win?: BrowserWindow }) { |
Collaborator
There was a problem hiding this comment.
Destructure this way will lose the reference. Imagine:
const ref = {
count: 1
}
function bar({count}) {
setInterval(() => console.log('Count is', count), 1000);
}
bar(ref);
// This will print count 1 every second
ref.count = 2;
// Now I update new value, but as you can see, it will still print 1 every second instead of print 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.