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

activate fix #1782

Merged
merged 4 commits into from
Aug 19, 2021
Merged

activate fix #1782

merged 4 commits into from
Aug 19, 2021

Conversation

mason-fish
Copy link
Contributor

fixes #1770

Part of the activation handler was still conditional to there being zero windows rendered, which should ideally never exist since there should always be at least a hidden window. This adjusts the logic accordingly. I also found a way to render multiple hidden windows using this activation flow, so I've included some protection around that as well.

Signed-off-by: Mason Fish <[email protected]>
Comment on lines 73 to 75
log.info("activate fired! window count: ", this.windows.count())
if (this.windows.count() === 0 || this.windows.count() === 1)
this.windows.init()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a method called this.windows.getVisible().length I think that would help this read more clearly.

Comment on lines 212 to 213
if (this.getWindows().find((w) => w.name === "hidden")) return
this.openWindow("hidden")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make methods called

getAll()

getVisible()

getHidden()

Then we could use them in all the places that make sense.

@@ -47,7 +47,7 @@ export default function windowManager(
return {
init() {
// hidden renderer/window is never persisted, so always open it with rest
this.openWindow("hidden")
this.openHidden()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be called ensureHiddenRenderer?

manager.openHidden()
windows = manager.getWindows()
expect(windows).toHaveLength(1)
expect(windows[0].name).toEqual("hidden")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -69,7 +70,9 @@ export class BrimMain {
}

activate() {
if (this.windows.count() === 0) this.windows.init()
log.info("activate fired! window count: ", this.windows.count())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need this log line?

Signed-off-by: Mason Fish <[email protected]>
Signed-off-by: Mason Fish <[email protected]>
Copy link
Member

@jameskerr jameskerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right on!

@mason-fish mason-fish merged commit f42a36b into main Aug 19, 2021
@mason-fish mason-fish deleted the 1770-activate-bug branch August 19, 2021 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Activating Brim on Mac with no existing windows does nothing
2 participants