-
-
Notifications
You must be signed in to change notification settings - Fork 436
#1070 Can check if the current window is the first one. #1282
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
Conversation
Closes #1070 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code's looking great! Thanks, @kittaakos
I would just add one more thing to this PR:
Here below we are asking the electron backend to check for updates (it is done by every renderer process)
.then(() => this.updater.checkForUpdates(true)) |
and the electron main process is smart enough to return early if the request was already been made by another renderer process so that in the end we only check for updates once.
arduino-ide/arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts
Lines 56 to 59 in bf193b1
if (initialCheck) { | |
if (this.isAlreadyChecked) return Promise.resolve(); | |
this.isAlreadyChecked = true; | |
} |
But with your improvement, now we could avoid sending a request to electron every time a new renderer is spawn.
What do you think?
Thank you for the review!
Exactly, excellent remark! This is my long-term plan, but I did not want to change the service APIs in this PR. I'd prefer handling them in a separate PR, removing the backend part of the survey service, and applying the IDE updater changes you have mentioned. Eventually, I can make the changes here if you think it makes sense. What do you think? |
this sounds like a good plan, let's go for it 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks @kittaakos!
I have tried it and it works as expected. Thanks to this generalized behavior we can avoid creating a custom service implementation just to check if the current window is the first as I did here:
arduino-ide/arduino-ide-extension/src/node/survey-service-impl.ts
Lines 13 to 19 in f5cee97
async isFirstInstance(): Promise<boolean> { | |
if (this.surveyDidShow) { | |
return false; | |
} | |
this.surveyDidShow = true; | |
return this.surveyDidShow; | |
} |
I will modify this implementation accordingly to your improvements.
Thank you for the review @AlbyIanna, @francescospissu 🙏
Sounds great. Let's tackle the API updates afterward. |
Motivation
This is a dev thing. From now on, devs can call a service and check if the current window is the first one or not.
Change description
New service for checking the state of the current window. See #1070 why this is needed.
How to verify?
true
,false
.In action:
is-first-window--final.mp4
Other information
Closes #1070
Reviewer checklist