-
Notifications
You must be signed in to change notification settings - Fork 732
feat: improve UX handling when multiple main files detected #1700
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
base: main
Are you sure you want to change the base?
Conversation
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.
Hi @nilayarya, thank you for your PR, but it seems to be incomplete. From the current PR, I can only temporarily consider this as an improvement for the edge case when there are multiple mainEntryPoints in the gist. When I create another mainEntryPoint from the left sidebar, it throws an error. According to the description in #1508, I believe @dsanders11 is hoping for a complete mainEntryPoint switching mechanism.

fiddle/src/renderer/editor-mosaic.ts
Lines 284 to 290 in 3838dd5
const entryPoint = this.mainEntryPointFile(); | |
if (isMainEntryPoint(id) && entryPoint) { | |
throw new Error( | |
`Cannot add file "${id}": Main entry point ${entryPoint} exists`, | |
); | |
} |
if (!this.mainEntryPoint || !this.files.get(this.mainEntryPoint)) { | ||
const entryPoint = Array.from(this.files.keys()).find((id) => | ||
isMainEntryPoint(id), | ||
); | ||
if (entryPoint) this.mainEntryPoint = entryPoint; | ||
return entryPoint; | ||
} | ||
return this.mainEntryPoint; |
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.
if (!this.mainEntryPoint || !this.files.get(this.mainEntryPoint)) { | |
const entryPoint = Array.from(this.files.keys()).find((id) => | |
isMainEntryPoint(id), | |
); | |
if (entryPoint) this.mainEntryPoint = entryPoint; | |
return entryPoint; | |
} | |
return this.mainEntryPoint; | |
public mainEntryPointFile(): EditorId | null { | |
if (this.mainEntryPoint && this.files.get(this.mainEntryPoint)) { | |
return this.mainEntryPoint; | |
} | |
for (const [id] of this.files) { | |
if (isMainEntryPoint(id)) { | |
this.mainEntryPoint = id; | |
break; | |
} | |
} | |
return this.mainEntryPoint; |
Make the code more intuitive and optimize performance a bit.
Description of Change
Suggests UI changes to resolve #1508
Some gifs:
gist-url: https://gist.github.com/nilayarya/dfac02c9af5c699f3efc146ddf946f9f
CC @dsanders11
Checklist
yarn test
passes