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

Disable export button in UI while exporting #179

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lucasdinonolte
Copy link
Contributor

@lucasdinonolte lucasdinonolte commented Jun 5, 2023

A tiny quality of life change to the UI.

  • The Export and Generate buttons are disabled while an export is running to more clearly communicate to the user that something is happening
  • This is done by allowing the UI to subscribe to events from the mechanic runtime
  • This could thus easily be extended to emit events on every frame to present the user with a growing number or progress bar while exporting

@netlify
Copy link

netlify bot commented Jun 5, 2023

Deploy Preview for dsi-logo-maker ready!

Name Link
🔨 Latest commit 71c90e1
🔍 Latest deploy log https://app.netlify.com/sites/dsi-logo-maker/deploys/647da873b6ce8a0008052067
😎 Deploy Preview https://deploy-preview-179--dsi-logo-maker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@lucasdinonolte lucasdinonolte changed the title Export state in UI Disable export button in UI while exporting Jun 5, 2023
Copy link
Contributor

@fdoflorenzano fdoflorenzano left a comment

Choose a reason for hiding this comment

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

I love the idea, and the events approach is interesting to me. Some other features could be approached from this point.

Tho, I think it's not working, specifically the try to catch the startDownload moment. I ran it locally with a fresh new project, I export once and the button then remains disabled.

The approach here tries subscribing on the lastRun object, which already ran the engine, and therefore the download part.

I feel like there's space here then to re-factor how the mechanic object run cycle behaves. Cause right now, it's the UI, saying to the iframe to run the engine, it's the engine who creates the mechanic object instance with all the values and other things, it validates things but also goes ahead and runs the DF. Then after that it returns to the UI the result of the run. I think there's space to reconsider how that life-cycle works, maybe the mechanic instance is begun in the UI with the information it has at the moment, there's time to subscribe to events before actually running the DF, and then telling the iframe to run. Also with the events idea, I feel like there's room to also map out the lifecycle as an internal state based lifecycle, which the UI responds to based on subscriptions.

Tho this might be a bit much before the 2.0.0 update. So maybe let's reconsider if any other "simpler" options come to mind.

off(event, listener) {
let idx;

if (typeof this.events[event] === "object") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (typeof this.events[event] === "object") {
if (Array.isArray(this.events[event])) {

I'm under the impression that this is more accurate to what we want to do here.

emit(event, ...args) {
let i, listeners, length;

if (typeof this.events[event] === "object") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (typeof this.events[event] === "object") {
if (Array.isArray(this.events[event])) {

Same here

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.

None yet

2 participants